Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nimsuggest sug wrongly reports all symbols on buggy code #99

Closed
timotheecour opened this issue Nov 15, 2018 · 3 comments
Closed

nimsuggest sug wrongly reports all symbols on buggy code #99

timotheecour opened this issue Nov 15, 2018 · 3 comments

Comments

@timotheecour
Copy link
Member

originally reported here: #93 (comment)

echo "sug bugs/nimsuggest/t01d.nim:3:6" | $nimc_D/bin/nimsuggest --stdin bugs/nimsuggest/t01d.nim

bugs/nimsuggest/t01d.nim:

macro mapLiterals(a: untyped): untyped =
  echo a.kind
mapLiterals(0)

yes, the above code is buggy (kind not defined) but nimsuggest shouldn't return all symbols here

@nc-x
Copy link

nc-x commented Dec 17, 2018

https://github.com/nim-lang/Nim/blob/0409f2348e2ac69a717e4ec7628a99c49fd42f0d/compiler/suggest.nim#L567-L586

proc suggestSentinel*(c: PContext) =
  if c.config.ideCmd != ideSug or c.module.position != c.config.m.trackPos.fileIndex.int32: return
  if c.compilesContextId > 0: return
  inc(c.compilesContextId)
  var outputs: Suggestions = @[]
  # suggest everything:                          <===============================
  var isLocal = true
  var scopeN = 0
  for scope in walkScopes(c.currentScope):
    if scope == c.topLevelScope: isLocal = false
    dec scopeN
    for it in items(scope.symbols):
      var pm: PrefixMatch
      if filterSymNoOpr(it, nil, pm):
        outputs.add(symToSuggest(c.config, it, isLocal = isLocal, ideSug,
            newLineInfo(c.config.m.trackPos.fileIndex, -1, -1), 0,
            PrefixMatch.None, false, scopeN))

  dec(c.compilesContextId)
produceOutput(outputs, c.config)

Seems to be intentional. No idea why though.
cc @Araq

@narimiran
Copy link
Member

Seems to be intentional.

So "it is not a bug, it is a feature" :) a.k.a it works as expected.

@Araq
Copy link
Member

Araq commented Mar 29, 2019

Seems to be intentional. No idea why though.

Because a list of options to choose from is better than no list. If I don't want suggestions then why would I invoke nimsuggest?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants