-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
Description
One of the strangest bugs I've seen with Nim
import macros
macro a*: untyped =
let name = newLit("name")
result = quote:
var b {.importc: `name`.}: int
echo result.treerepr
a()VarSection
IdentDefs
PragmaExpr
Sym "b"
Pragma
ExprColonExpr
Ident ident"importc"
Ident ident"2"
Sym "int"
Empty
You can see instead of a string, we get ident 2 for importc
If you add more importc with quote, you get 3 etc
So I guess it's some kind of index instead of node issue
obviously one can use constant for now ( @zah gave me a workaround:)
import macros
macro a*: untyped =
let name = newLit("name")
let x = ident("x")
result = quote:
const `x` = `name`
var b {.importc: x.}: int
echo result.treerepr
a()