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

Allow let to not have value when using importc #14258

Merged
merged 5 commits into from
May 12, 2020
Merged

Conversation

PMunch
Copy link
Contributor

@PMunch PMunch commented May 7, 2020

This allows a let statement with the {.importc.} pragma to not be
initialised with a value. This allows us to declare C constants as Nim
lets without putting the value in the Nim code (which can lead to
errors, and requires us to go looking for the value). Fixes #14253

This allows a let statement with the `{.importc.}` pragma to not be
initialised with a value. This allows us to declare C constants as Nim
lets without putting the value in the Nim code (which can lead to
errors, and requires us to go looking for the value). Fixes nim-lang#14253
@PMunch
Copy link
Contributor Author

PMunch commented May 7, 2020

Not sure if this is the correct way of accessing pragmas, if it's not please let me know and I'll fix it.

@Araq
Copy link
Member

Araq commented May 7, 2020

Instead check for sfImportc in s.flags

@PMunch
Copy link
Contributor Author

PMunch commented May 7, 2020

What s would that be? Neither n[i] nor any of it's children have anything useful in flags

@cooldome
Copy link
Member

cooldome commented May 7, 2020

check n[i].kind ==nkSym and then sfImportc in n[i].sym

@PMunch
Copy link
Contributor Author

PMunch commented May 7, 2020

n[i].kind is nkIdentDefs in this scenario, can't find a nkSym in the tree either..

Copy link
Member

@timotheecour timotheecour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (but maybe address the styleCheck comment if possible)

@Araq Araq merged commit 9acbf99 into nim-lang:devel May 12, 2020
EchoPouet pushed a commit to EchoPouet/Nim that referenced this pull request Jun 13, 2020
* Allow let to not have value when using importc

This allows a let statement with the `{.importc.}` pragma to not be
initialised with a value. This allows us to declare C constants as Nim
lets without putting the value in the Nim code (which can lead to
errors, and requires us to go looking for the value). Fixes nim-lang#14253

* Proper fix and documentation + changelog entry

* Improve testcase with one from timotheecour

* Add test to verify it working with macros
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

Successfully merging this pull request may close these issues.

Assignment to default leads to assignment for nodecl
4 participants