-
-
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
Backticked vars misinterpreted by quote do: when creating pragmas #9745
Comments
I can reproduce. Until this is fixed/resolved, here is a quick-n-dirty (-n-ugly ;)) version made by using import macros
var
typ {.compiletime.} = "struct ABC"
name {.compiletime.} = "ABC".newIdentNode()
macro abc(): untyped =
result = nnkStmtList.newTree(
nnkTypeSection.newTree(
nnkTypeDef.newTree(
nnkPragmaExpr.newTree(
name,
nnkPragma.newTree(
nnkExprColonExpr.newTree(
newIdentNode("importc"),
newLit(typ)
)
)
),
newEmptyNode(),
nnkObjectTy.newTree(
newEmptyNode(),
newEmptyNode(),
newEmptyNode()
)
)
)
)
echo result.repr
abc() |
Thanks for sharing. If |
https://github.com/alehander42/breeze this might make it a bit easier to build trees too. |
Thanks I'll check it out. For now I'm using parseStmt because it is a bit more readable than building full trees. |
I've also noticed that the symbol pass for importc and exportc is done very early. For example it is done before template are expanded here: #9366. |
current output:
|
I'm using macros to create types with
quote do:
but added pragmas are not working correctly since backticked variables are interpreted incorrectly.Example
Current Output
Expected Output
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.The text was updated successfully, but these errors were encountered: