Skip to content

Commit 55292d6

Browse files
authored
Merge pull request #23533 from JuliaLang/jn/macroexpand-stacktraces
stacktraces for macroexpand
2 parents 07f132f + 0b08a7e commit 55292d6

File tree

14 files changed

+409
-312
lines changed

14 files changed

+409
-312
lines changed

base/interactiveutil.jl

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -415,13 +415,12 @@ function gen_call_with_extracted_types(__module__, fcn, ex0)
415415
Expr(:call, typesof, map(esc, ex0.args[2:end])...))
416416
end
417417
end
418-
exret = Expr(:none)
419-
is_macro = false
420-
ex = expand(__module__, ex0)
421418
if isa(ex0, Expr) && ex0.head == :macrocall # Make @edit @time 1+2 edit the macro by using the types of the *expressions*
422-
is_macro = true
423-
exret = Expr(:call, fcn, esc(ex0.args[1]), Tuple{#=__source__=#LineNumberNode, #=__module__=#Module, Any[ Core.Typeof(a) for a in ex0.args[3:end] ]...})
424-
elseif !isa(ex, Expr)
419+
return Expr(:call, fcn, esc(ex0.args[1]), Tuple{#=__source__=#LineNumberNode, #=__module__=#Module, Any[ Core.Typeof(a) for a in ex0.args[3:end] ]...})
420+
end
421+
ex = expand(__module__, ex0)
422+
exret = Expr(:none)
423+
if !isa(ex, Expr)
425424
exret = Expr(:call, :error, "expression is not a function call or symbol")
426425
elseif ex.head == :call
427426
if any(e->(isa(e, Expr) && e.head==:(...)), ex0.args) &&
@@ -445,12 +444,12 @@ function gen_call_with_extracted_types(__module__, fcn, ex0)
445444
end
446445
end
447446
end
448-
if (!is_macro && ex.head == :thunk) || exret.head == :none
447+
if ex.head == :thunk || exret.head == :none
449448
exret = Expr(:call, :error, "expression is not a function call, "
450449
* "or is too complex for @$fcn to analyze; "
451450
* "break it down to simpler parts if possible")
452451
end
453-
exret
452+
return exret
454453
end
455454

456455
for fname in [:which, :less, :edit, :functionloc, :code_warntype,

0 commit comments

Comments
 (0)