-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
I'm using macros to create types with quote do: but added pragmas are not working correctly since backticked variables are interpreted incorrectly.
Example
import macros
var
typ {.compiletime.} = "struct ABC"
name {.compiletime.} = "ABC".newIdentNode()
macro abc(): untyped =
result = newNimNode(nnkStmtList)
result.add(quote do:
type `name` {.importc: `typ`.} = object
)
echo result.repr
abc()Current Output
type
ABC {.importc: 3.} = object
Expected Output
type
ABC {.importc: "struct ABC".} = object
Note that name is interpreted correctly, only contents in side the pragma section are misinterpreted. If you add more elements - e.g. header or something else, you get numbers again.