Skip to content

Commit

Permalink
Merge pull request #23533 from JuliaLang/jn/macroexpand-stacktraces
Browse files Browse the repository at this point in the history
stacktraces for macroexpand
  • Loading branch information
vtjnash authored Sep 8, 2017
2 parents 07f132f + 0b08a7e commit 55292d6
Show file tree
Hide file tree
Showing 14 changed files with 409 additions and 312 deletions.
15 changes: 7 additions & 8 deletions base/interactiveutil.jl
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,12 @@ function gen_call_with_extracted_types(__module__, fcn, ex0)
Expr(:call, typesof, map(esc, ex0.args[2:end])...))
end
end
exret = Expr(:none)
is_macro = false
ex = expand(__module__, ex0)
if isa(ex0, Expr) && ex0.head == :macrocall # Make @edit @time 1+2 edit the macro by using the types of the *expressions*
is_macro = true
exret = Expr(:call, fcn, esc(ex0.args[1]), Tuple{#=__source__=#LineNumberNode, #=__module__=#Module, Any[ Core.Typeof(a) for a in ex0.args[3:end] ]...})
elseif !isa(ex, Expr)
return Expr(:call, fcn, esc(ex0.args[1]), Tuple{#=__source__=#LineNumberNode, #=__module__=#Module, Any[ Core.Typeof(a) for a in ex0.args[3:end] ]...})
end
ex = expand(__module__, ex0)
exret = Expr(:none)
if !isa(ex, Expr)
exret = Expr(:call, :error, "expression is not a function call or symbol")
elseif ex.head == :call
if any(e->(isa(e, Expr) && e.head==:(...)), ex0.args) &&
Expand All @@ -445,12 +444,12 @@ function gen_call_with_extracted_types(__module__, fcn, ex0)
end
end
end
if (!is_macro && ex.head == :thunk) || exret.head == :none
if ex.head == :thunk || exret.head == :none
exret = Expr(:call, :error, "expression is not a function call, "
* "or is too complex for @$fcn to analyze; "
* "break it down to simpler parts if possible")
end
exret
return exret
end

for fname in [:which, :less, :edit, :functionloc, :code_warntype,
Expand Down
Loading

0 comments on commit 55292d6

Please sign in to comment.