saem / vscode-nim

Other
177 stars 23 forks source link

Nimscript get incorrect errors #72

Closed TheSimpleZ closed 2 years ago

TheSimpleZ commented 2 years ago

I'm trying to use a standalone nimscript. The following script:

mode = ScriptMode.Verbose

proc build() =
  echo "building nim... "
  exec "sleep 10"
  echo getCurrentDir()

echo "hello"

Looks like this: image

It's reporting that:

I'd expect it to only report that the build proc is unused.

All errors disappear if I simply call the build proc at the end of the script.

saem commented 2 years ago

What happens if you run nim check against it just like the extension does, but manually on the command line?

TheSimpleZ commented 2 years ago

Hmm.. I see. Most likely an issue with nim check then, since it's reporting the same issues.

$ nim check nim.nims
hello
Hint: used config file '~/.choosenim/toolchains/nim-1.6.2/config/nim.cfg' [Conf]
Hint: used config file '~/.choosenim/toolchains/nim-1.6.2/config/config.nims' [Conf]
Hint: used config file '~/Documents/monorepo-manager/ci/nim.nims' [Conf]
.........................................................
~/Documents/monorepo-manager/ci/nim.nims(1, 1) Error: undeclared identifier: 'mode'
candidates (edit distance, scope distance); see '--spellSuggest': 
 (1, 2): 'mod' [proc declared in ~/.choosenim/toolchains/nim-1.6.2/lib/system/arithmetics.nim(216, 6)]
 (1, 2): 'mod' [proc declared in ~/.choosenim/toolchains/nim-1.6.2/lib/system/arithmetics.nim(225, 6)]
 (1, 2): 'mod' [proc declared in ~/.choosenim/toolchains/nim-1.6.2/lib/system/arithmetics.nim(226, 6)]
 (1, 2): 'mod' [proc declared in ~/.choosenim/toolchains/nim-1.6.2/lib/system/arithmetics.nim(227, 6)]
 (1, 2): 'mod' [proc declared in ~/.choosenim/toolchains/nim-1.6.2/lib/system/arithmetics.nim(228, 6)]
 (1, 2): 'mod' [proc declared in ~/.choosenim/toolchains/nim-1.6.2/lib/system/arithmetics.nim(394, 6)]
 (1, 2): 'mod' [proc declared in ~/.choosenim/toolchains/nim-1.6.2/lib/system/arithmetics.nim(397, 6)]
 (1, 2): 'mod' [proc declared in ~/.choosenim/toolchains/nim-1.6.2/lib/system/arithmetics.nim(398, 6)]
 (1, 2): 'mod' [proc declared in ~/.choosenim/toolchains/nim-1.6.2/lib/system/arithmetics.nim(399, 6)]
 (1, 2): 'mod' [proc declared in ~/.choosenim/toolchains/nim-1.6.2/lib/system/arithmetics.nim(400, 6)]
 (1, 2): 'move' [proc declared in ~/.choosenim/toolchains/nim-1.6.2/lib/system.nim(286, 6)]
~/Documents/monorepo-manager/ci/nim.nims(1, 1) Error: expression 'mode' has no type (or is ambiguous)
~/Documents/monorepo-manager/ci/nim.nims(1, 1) Error: 'mode' cannot be assigned to
~/Documents/monorepo-manager/ci/nim.nims(5, 3) Error: undeclared identifier: 'exec'
candidates (edit distance, scope distance); see '--spellSuggest': 
 (2, 4): 'dec' [proc declared in ~/.choosenim/toolchains/nim-1.6.2/lib/system/arithmetics.nim(31, 6)]
 (2, 4): 'excl' [func declared in ~/.choosenim/toolchains/nim-1.6.2/lib/system/setops.nim(21, 6)]
 (2, 4): 'excl' [template declared in ~/.choosenim/toolchains/nim-1.6.2/lib/system/setops.nim(30, 10)]
~/Documents/monorepo-manager/ci/nim.nims(5, 8) Error: attempting to call routine: 'exec'
  found 'exec' [unknown declared in ~/Documents/monorepo-manager/ci/nim.nims(5, 3)]
~/Documents/monorepo-manager/ci/nim.nims(5, 8) Error: attempting to call routine: 'exec'
  found 'exec' [unknown declared in ~/Documents/monorepo-manager/ci/nim.nims(5, 3)]
~/Documents/monorepo-manager/ci/nim.nims(5, 8) Error: expression 'exec' cannot be called
~/Documents/monorepo-manager/ci/nim.nims(6, 8) Error: undeclared identifier: 'getCurrentDir'
candidates (edit distance, scope distance); see '--spellSuggest': 
 (8, 5): 'declared' [proc declared in ~/.choosenim/toolchains/nim-1.6.2/lib/system.nim(169, 8)]
 (8, 5): 'getCurrentException' [proc declared in ~/.choosenim/toolchains/nim-1.6.2/lib/system.nim(2407, 8)]
 (8, 5): 'getFrameState' [proc declared in ~/.choosenim/toolchains/nim-1.6.2/lib/system/excpt.nim(88, 6)]
 (8, 5): 'getFreeMem' [proc declared in ~/.choosenim/toolchains/nim-1.6.2/lib/system/alloc.nim(1061, 8)]
~/Documents/monorepo-manager/ci/nim.nims(6, 21) Error: attempting to call routine: 'getCurrentDir'
  found 'getCurrentDir' [unknown declared in ~/Documents/monorepo-manager/ci/nim.nims(6, 8)]
~/Documents/monorepo-manager/ci/nim.nims(6, 21) Error: attempting to call routine: 'getCurrentDir'
  found 'getCurrentDir' [unknown declared in ~/Documents/monorepo-manager/ci/nim.nims(6, 8)]
~/Documents/monorepo-manager/ci/nim.nims(6, 21) Error: expression 'getCurrentDir' cannot be called
~/Documents/monorepo-manager/ci/nim.nims(3, 6) Hint: 'build' is declared but not used [XDeclaredButNotUsed]

I guess I should report the issue at https://github.com/nim-lang/Nim ?

saem commented 2 years ago

Yup, hopefully it gets fixed.