-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
template/macro pragmas don't work in templates (eg: byaddr
, since
etc)
#15920
Comments
There are some problems with using user-defined pragmas in templates template pro(a: untyped) =
discard
template test() =
var y {.pro.} = 10
test() They are both related to |
I've been tracking this + related issues, this isn't specific to byaddr but is more general:
template foo(lhs, typ, expr) =
let lhs = expr
proc fun1()=
let a {.foo.} = 1
template fun2()=
let a {.foo.} = 1
fun1() # ok
fun2() # BUG: Error: invalid pragma: foo
template bar(a, body: untyped) {.dirty, used.} = discard
proc fun1() {.bar: 1.} = discard # ok
template fun2() {.bar: 1.} = discard # error: Error: cannot attach a custom pragma to 'fun2'
when false: # ditto with these
template bar2(body: untyped) {.dirty, used.} = discard
template bar3(body: untyped) = discard
template fun2() {.bar2.} = discard
template fun3() {.bar3.} = discard
template fun(body: untyped): untyped = echo "ok1"
{.pragma: callfun, fun.}
proc bar1() {.fun.} = echo "ok2" # ok
proc bar2() {.callfun.} = echo "ok2" # Error: invalid pragma: fun related WIP PR's |
byaddr
in template fails to compilebyaddr
, since
etc)
…n `foo` is overloaded) (#13869) * fix: `var a{.foo.} = expr` inside templates * add test * improve tdecls test * improve tests * add failing test * PRTEMP * fixup
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.
* 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
…cept when `foo` is overloaded) (nim-lang#13869) * fix: `var a{.foo.} = expr` inside templates * add test * improve tdecls test * improve tests * add failing test * PRTEMP * fixup
* 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
Using
byaddr
in a template does not compile while the same code inside ablock
works.Example
Current Output
Expected Output
$ nim -v
[EDIT]
The text was updated successfully, but these errors were encountered: