Skip to content

Hygiene and support for macros emitting K"toplevel"Β #39

@c42f

Description

@c42f

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#53515

I 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions