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

Variable declaration pragma does not work with const #14781

Closed
haxscramper opened this issue Jun 23, 2020 · 1 comment · Fixed by #19406
Closed

Variable declaration pragma does not work with const #14781

haxscramper opened this issue Jun 23, 2020 · 1 comment · Fixed by #19406
Labels

Comments

@haxscramper
Copy link
Contributor

It is possible to use variable declaration pragma with var and let but when using const it fails to compile with Error: cannot attach a custom pragma to ...

Example

macro varPragma(a, b, c: untyped): untyped =
  discard

let v {.varPragma.} = 111
var v {.varPragma.} = 111
const v {.varPragma.} = 111

Current Output

Compilation error on last line in example:

Error: cannot attach a custom pragma to 'v'

Expected Output

No compilation error

Compiler version

$ nim -v
Nim Compiler Version 1.2.2 [Linux: amd64]
Compiled at 2020-06-16
Copyright (c) 2006-2020 by Andreas Rumpf

git hash: be34b5abe23e027b71a3a9da67037aac7afea6bc
active boot switches: -d:release
@timotheecour
Copy link
Member

refs nim-lang/RFCs#220

metagn added a commit to metagn/Nim that referenced this issue Jan 17, 2022
fix nim-lang#15920, close nim-lang#18212, close nim-lang#14781, close nim-lang#6696,
close nim-lang/RFCs#220

Variable macro pragmas have been changed to
only take a unary section node.
They can now also be applied in sections with multiple variables,
as well as `const` sections. They also accept arguments.

Templates now support macro pragmas, mirroring other routine types.

Type and variable macro pragmas have been made experimental.
Symbols without parentheses instatiating nullary macros or templates
has also been documented in the experimental manual.

A check for a redefinition error based on the left hand side of variable
definitions when using variable macro pragmas was disabled.
This nerfs `byaddr` specifically, however this has been documented as
a consequence of the experimental features `byaddr` uses.

Given how simple these changes are I'm worried if I'm missing something.
Araq pushed a commit that referenced this issue Jan 20, 2022
* New/better macro pragmas, make some experimental

fix #15920, close #18212, close #14781, close #6696,
close nim-lang/RFCs#220

Variable macro pragmas have been changed to
only take a unary section node.
They can now also be applied in sections with multiple variables,
as well as `const` sections. They also accept arguments.

Templates now support macro pragmas, mirroring other routine types.

Type and variable macro pragmas have been made experimental.
Symbols without parentheses instatiating nullary macros or templates
has also been documented in the experimental manual.

A check for a redefinition error based on the left hand side of variable
definitions when using variable macro pragmas was disabled.
This nerfs `byaddr` specifically, however this has been documented as
a consequence of the experimental features `byaddr` uses.

Given how simple these changes are I'm worried if I'm missing something.

* accomodate compiler boot

* allow weird pragmas

* add test for #10994

* remove some control flow, try remove some logic
PMunch pushed a commit to PMunch/Nim that referenced this issue Mar 28, 2022
* New/better macro pragmas, make some experimental

fix nim-lang#15920, close nim-lang#18212, close nim-lang#14781, close nim-lang#6696,
close nim-lang/RFCs#220

Variable macro pragmas have been changed to
only take a unary section node.
They can now also be applied in sections with multiple variables,
as well as `const` sections. They also accept arguments.

Templates now support macro pragmas, mirroring other routine types.

Type and variable macro pragmas have been made experimental.
Symbols without parentheses instatiating nullary macros or templates
has also been documented in the experimental manual.

A check for a redefinition error based on the left hand side of variable
definitions when using variable macro pragmas was disabled.
This nerfs `byaddr` specifically, however this has been documented as
a consequence of the experimental features `byaddr` uses.

Given how simple these changes are I'm worried if I'm missing something.

* accomodate compiler boot

* allow weird pragmas

* add test for nim-lang#10994

* remove some control flow, try remove some logic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants