Handle escaped module names from Julia 1.12 hygienic macro expansion#36
Handle escaped module names from Julia 1.12 hygienic macro expansion#36PatrickHaecker wants to merge 4 commits into
Conversation
|
Thanks for your PR! Would it be possible to write a more realistic test case? You could make a macro, and then let Julia macroexoand it and test the result. |
|
Something like the most recent commit? If not, please feel free to suggest test code directly. For reference, I observed the original problem when using EnumX.jl in a (proprietary) notebook with Julia 1.12. |
|
Thanks! Did you change from |
|
Thanks, @fonsp. I hadn't really understood the I hope this is a step in the right direction. |
Julia 1.12 wraps module names in Expr(:escape, :Name) during hygienic macro expansion. This caused explore_module! to fail because it expected a bare Symbol in the module name position. Use unescape() to unwrap the module name before recording it as an assignment, with a guard for non-Symbol results.
Replace the manually constructed `Expr(:module, true, Expr(:escape, :a), ...)`
test with a macro + macroexpand test mimicking `@enumx`, as suggested by fonsp.
On Julia 1.12, macros that use `esc()` with `:toplevel` produce
`Expr(:escape, :Name)` inside `Expr(Symbol("hygienic-scope"), ...)` after
`macroexpand`.
77185a6 to
90a1776
Compare
|
Anything else I should do so that this PR can be merged? |
Julia 1.12 wraps module names in
Expr(:escape, :Name)during hygienicmacro expansion. This caused
explore_module!to fail because it expecteda bare Symbol in the module name position.
Use
unescape()to unwrap the module name before recording it as anassignment, with a guard for non-Symbol results.
Also widen Aqua test compat to include v1 in the second commit. I can remove this change, if it is not welcomed.
This change was needed to make a notebook work with Julia 1.12 which worked previously without the change with Julia 1.11.
I used Claude Opus 4.6 to create the commit and fine-tuned it afterwards.