saem/vscode-nim

Nim 2.0: default values for object fields

anderflash opened this issue · 3 comments

type
  Circle = object
    radius: float = 1.0 # Nim 2.0 adds default values for object fields at construction
    
when isMainModule:
  var circle = Circle()
  echo circle.radius

The extension is complaining, although it's a correct code for 2.0:
"Error: initialization not allowed here"

RSDuck commented

probably either a nim check issue or one in your setup. Try running nim check yourfile.nim to see whether the name error appears.

I have nimble (v2.0) and Archlinux nim package (v1.6). It seems that /usr/bin/nim was being used. So I removed the Archlinux package and kept only local nimble installation. The syntax highlighting doesn't complain anymore, but I don't get no hover interaction, no goto definition. It seems that it's related to #97 and #102. If I show the developer console on vs code, I get:
nimex_error

If I run on bash:

$ nimsuggest --epc --v2 animation.nim
44233

However, the error persists.

In that case, I'll close this issue, and perhaps re-post my last comment into the proper issue. Thanks!