Skip to content

macro hygine escape stripped late for macros calling macros #23221

@c42f

Description

@c42f

In julia 0.7, escaping with esc seems to be stripped out later than in julia 0.6.
This means that macros which are called by other macros need to have code for
dealing with input ASTs including Expr(:escape, ...). For example:

macro a(ex)
    # ex will be Expr(:escape, :(x=10)) on julia 0.7, but :(x=10) on 0.6.
    @show ex
    esc(ex)
end

macro b(ex)
    quote
        @a $(esc(ex)) # esc() required for julia 0.6.0
        #@a $ex       # Can be used in 0.7.0-DEV.1300
    end
end

@b x=10
x

Is this intentional? From a user perspective the 0.6 behavior made more sense
to me, as it allowed the inner macro to work with surface syntax not including
Expr(:escape, ...) nodes. It also meant that the outer macro would be required
to properly escape $ex in the example above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions