pragmagic / vscode-nim

An extension for VS Code which provides support for the Nim language.
Other
238 stars 37 forks source link

Shows problems even though recursive import works #197

Open bichanna opened 2 years ago

bichanna commented 2 years ago

Recursive import is now supported in Nim, but currently, it shows a bunch of problems (errors?) in the problems panel. (Already checked that the code works.)

Code:

# Module A
type
  T1* = int  # Module A exports the type `T1`
import moduleB     # the compiler starts parsing B

proc main() =
  var i = p(3) # works because B has been parsed completely here

main()
# Module B
import moduleA  # A is not parsed here! Only the already known symbols
          # of A are imported.

proc p*(x: moduleA.T1): moduleA.T1 =
  # this works because the compiler has already
  # added T1 to A's interface symbol table
  result = x + 1

Problems thrown:

moduleA.nim
undeclared identifier: 'p'

candidates (edit distance, scope distance); see '--spellSuggest':
(1, 4): '$' [func declared in /usr/local/Cellar/nim/1.6.2/nim/lib/system/dollars.nim(25, 8)]
(1, 4): '$' [func declared in /usr/local/Cellar/nim/1.6.2/nim/lib/system/dollars.nim(25, 8)]
(1, 4): '$' [func declared in /usr/local/Cellar/nim/1.6.2/nim/lib/system/dollars.nim(25, 8)]
(1, 4): '$' [func declared in /usr/local/Cellar/nim/1.6.2/nim/lib/system/dollars.nim(30, 6)]
This might be caused by a recursive module dependency:
/some/path/moduleB.nim imports /some/path/moduleA.nim
/some/path/moduleA.nim imports /some/path/moduleB.nim
RSDuck commented 2 years ago

did you set a project file?