diff --git a/base/essentials.jl b/base/essentials.jl index 8673765f0b8c5..82d80ebdcfb05 100644 --- a/base/essentials.jl +++ b/base/essentials.jl @@ -216,10 +216,10 @@ Evaluate an expression with values interpolated into it using `eval`. If two arguments are provided, the first is the module to evaluate in. """ macro eval(ex) - :(Core.eval($__module__, $(Expr(:quote,ex)))) + :(Core.eval($__module__, $(Expr(:escape, Expr(:quote,ex))))) end macro eval(mod, ex) - :(Core.eval($(esc(mod)), $(Expr(:quote,ex)))) + :(Core.eval($(esc(mod)), $(Expr(:escape, Expr(:quote,ex))))) end argtail(x, rest...) = rest diff --git a/src/ast.c b/src/ast.c index fc7cdbbf5e787..759c81bdb5e55 100644 --- a/src/ast.c +++ b/src/ast.c @@ -1017,12 +1017,6 @@ static jl_value_t *jl_expand_macros(jl_value_t *expr, jl_module_t *inmodule, str if (e->head == quote_sym && jl_expr_nargs(e) == 1) { expr = jl_call_scm_on_ast("julia-bq-macro", jl_exprarg(e, 0), inmodule); JL_GC_PUSH1(&expr); - if (macroctx) { - // in a macro, `quote` also implies `escape` - jl_expr_t *e2 = jl_exprn(escape_sym, 1); - jl_array_ptr_set(e2->args, 0, expr); - expr = (jl_value_t*)e2; - } expr = jl_expand_macros(expr, inmodule, macroctx, onelevel); JL_GC_POP(); return expr; diff --git a/stdlib/Distributed/src/macros.jl b/stdlib/Distributed/src/macros.jl index 7e988bc173a91..b53890017d4de 100644 --- a/stdlib/Distributed/src/macros.jl +++ b/stdlib/Distributed/src/macros.jl @@ -202,7 +202,7 @@ macro everywhere(procs, ex) imps = extract_imports(ex) return quote $(isempty(imps) ? nothing : Expr(:toplevel, imps...)) # run imports locally first - let ex = Expr(:toplevel, :(task_local_storage()[:SOURCE_PATH] = $(get(task_local_storage(), :SOURCE_PATH, nothing))), $(Expr(:quote, ex))), + let ex = Expr(:toplevel, :(task_local_storage()[:SOURCE_PATH] = $(get(task_local_storage(), :SOURCE_PATH, nothing))), $(esc(Expr(:quote, ex)))), procs = $(esc(procs)) remotecall_eval(Main, procs, ex) end diff --git a/test/syntax.jl b/test/syntax.jl index 5d2b4642f2eaa..9704978eaf63d 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -2340,3 +2340,12 @@ if isodd(1) && all(iseven(2) for c in ()) else @test false end + +# issue #37540 +macro m37540() + quote + x = 1 + :($x) + end +end +@test @m37540() == 1