I've created a template and I'm getting an error from the compiler that I can't understand how to remedy.
template declareFoo(fooName: untyped, value: uint) =
const `fooName Value`* = value
declareFoo(FOO, 0x70000000)
declareFoo(BAR, 0x80000000)
https://play.nim-lang.org/#pasty=RVXxKUURAnAz
Error message:
/usercode/in.nim(5, 12) Error: undeclared identifier: 'BAR'
I don't understand why FOO works, but BAR gives an error. If I change the value argument to anything below 0x8000_0000, then BAR's error goes away. I'm expecting the template to emit constants FOOValue and BARValue; however, echo $FOOValue and echo $BARValue result in an undeclared identifier.
This works:
template declareFoo(fooName: untyped, v: uint) =
const `fooName Value`* {.inject.} = v
declareFoo(FOO, 0x70000000'u32)
declareFoo(BAR, 0x80000000'u32)
echo FOOValue
But report it on github please, I'm not entirely sure what is going on.