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
Inner proc in macro breaks parameters #9509
Comments
This is not limited to static parameters. Regular AST parameters will be read as |
/cc @narimiran Was it you who pasted an example on the IRC where for an AST var e, you had to first assign e[0] to a new var e0, and so on .. ? |
Yes, it was me. (Nice memory! :)) Here is the full example: macro with(obj: MyObject, body: untyped): untyped =
result = newStmtList()
for b in body:
let
b0 = b[0]
b1 = b[1]
result.add quote do:
# `obj`.`b[0]` = `b[1]`
`obj`.`b0` = `b1` We cannot do the thing that is commented out, so we must introduce |
maybe also a fix for this would test for bug from closed as duplicate issue #9656 : BUG: code below prints macro dispatchGen7*(forwardResult: static bool = true): untyped =
echo "forwardResult1:", forwardResult # BUG: will show: forwardResult1:false
proc callWrapped(): NimNode =
let ignore = forwardResult # comment this => will show: forwardResult1:true
discard
let callWrapd=callWrapped()
dispatchGen7(forwardResult=true) |
This issue has been automatically marked as stale because it has not had recent activity. If you think it is still a valid issue, write a comment below; otherwise it will be closed. Thank you for your contributions. |
Still an issue.. |
When using a static parameter in an inner proc of a macro, that parameter will somehow have the value
0
(if usingstatic[int]
) instead of the value passed to the macro.edit: @zah mentioned this happens for nim nodes, too.
Example
Current Output
Expected Output
Workaround
Can be avoided by assigning to a local variable first.
The text was updated successfully, but these errors were encountered: