-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Normally K"toplevel" expressions don't get into lowering because they're dealt with directly in eval(). However, some macros may emit top level expressions as noted by @mlechu in #33 (comment):
A small fix you may want to include in this PR is a special case for macros returning
Expr(:toplevel, ...)which was added in JuliaLang/julia#53515I implemented this for Expr here: mlechu@80ba20a. Feel free to take that change and anything else you want from that branch (only some of it is JETLS hacking; other parts I intend to upstream eventually)
We should fix this but also make sure this works for new-style macros emitting K"toplevel" as well - I don't know that JuliaLowering's hygiene is currently correct in this case. We currently lower K"toplevel" to a call to eval(), so perhaps all that is required is making sure the correct module is emitted into the eval() call, respecting the scope layer of the toplevel expression as it comes from macro expansion.