Open deech opened 4 years ago
@deech you need to annotate aPragma
with {.pragma.} so it can be used as a pragma :)
# a.nim
template aPragma*() {.pragma.}
# b.nim
import a
proc b() {.aPragma.} = discard # works
Yes, that works. As a side note if you want to use the template for metaprogramming and you leave out the initial argument that takes the body of the proc
or you get the same error so you need to do:
template aPragma(body:untyped):untyped = body
proc p() {.aPragma.} = ...
Not totally related to my original issue but might be worth noting in the manual as well.
Another thing I noticed is qualified pragmas don't seem to work even if I have the {.pragma.}
pragma, so proc p() {.a.aPragma.}
fails with identifier expected but found 'a.aPragma'
. Not sure if that's a bug but it surprised me so it might also be worth spelling out in the manual
In any case, thanks! This can be closed
it's a common error; i think we should improve the error message before closing
Example
I also tried"
Current Output
Expected Output