-
Notifications
You must be signed in to change notification settings - Fork 381
Cannot run macros within comptime code #5575
Copy link
Copy link
Closed
Description
Aim
comptime fn foo(x: Field) {
let cond = quote { x == 5 };
assert(std::meta::unquote!(cond));
}Expected Behavior
The code to run correctly assuming x = 5
Bug
We get an error that x is not a comptime variable.
This is because the function is elaborated before it is interpreted. The elaborator sees the macro call and tries to run it but doesn't know the value of x yet. If we instead delay this expansion until the interpreter is called then we can't resolve the x == 5 snippet since the interpreter itself can't elaborate code.
To Reproduce
Project Impact
None
Impact Context
No response
Workaround
None
Workaround Description
No response
Additional Context
No response
Installation Method
None
Nargo Version
No response
NoirJS Version
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels