Skip to content

Nim 2.0: default values for object fields #129

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

Closed
anderflash opened this issue Aug 23, 2023 · 3 comments
Closed

Nim 2.0: default values for object fields #129

anderflash opened this issue Aug 23, 2023 · 3 comments

Comments

@anderflash
Copy link

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
Copy link
Contributor

RSDuck commented Aug 23, 2023

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

@anderflash
Copy link
Author

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.

@anderflash
Copy link
Author

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

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

2 participants