Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stacktraces for macroexpand #23533

Merged
merged 2 commits into from
Sep 8, 2017
Merged

stacktraces for macroexpand #23533

merged 2 commits into from
Sep 8, 2017

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Aug 31, 2017

This PR allows errors thrown in macroexpand to propagate out directly, rather than discarding their stacktrace in order to wrap them in Expr(:error) constructs. It also makes the flisp-julia interface non-reentrant, allowing us to eliminate some complexity from ast.c.

Obligatory examples:

julia> macro error(msg); error(msg); end
@error (macro with 1 method)

julia> macroexpand(Main, :(@error "in a macro"))
ERROR: LoadError: in a macro
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] @error(::LineNumberNode, ::Module, ::Any) at ./REPL[1]:1
 [3] #macroexpand#39 at ./expr.jl:84 [inlined]
 [4] macroexpand(::Module, ::Any) at ./expr.jl:83
while loading REPL[2], in expression starting on line 1

julia> @printf "%z" b
ERROR: LoadError: ArgumentError: invalid printf format string: "%z"
Stacktrace:
 [1] next_or_die(::String, ::Int64) at ./printf.jl:85
 [2] parse1 at ./printf.jl:126 [inlined]
 [3] parse(::String) at ./printf.jl:46
 [4] gen(::String) at ./printf.jl:14
 [5] _printf(::String, ::Symbol, ::String, ::Tuple{Symbol}) at ./printf.jl:1148
 [6] @printf(::LineNumberNode, ::Module, ::Vararg{Any,N} where N) at ./printf.jl:1218
while loading REPL[8], in expression starting on line 1

@vtjnash vtjnash added compiler:lowering Syntax lowering (compiler front end, 2nd stage) macros @macros labels Aug 31, 2017
@vtjnash vtjnash requested a review from JeffBezanson August 31, 2017 19:46
@vtjnash vtjnash force-pushed the jn/macroexpand-stacktraces branch 2 times, most recently from a79de38 to 1daaa66 Compare September 5, 2017 18:31
cuts down on complexity a bit (it now never needs to transition from Julia -> flisp -> Julia)
and fixes backtraces from macros! (fix #15643)
@vtjnash vtjnash force-pushed the jn/macroexpand-stacktraces branch from 1daaa66 to 0b08a7e Compare September 6, 2017 20:12
@vtjnash vtjnash changed the title RFC: stacktraces for macroexpand stacktraces for macroexpand Sep 6, 2017
@vtjnash vtjnash removed the request for review from JeffBezanson September 6, 2017 20:13
@vtjnash vtjnash merged commit 55292d6 into master Sep 8, 2017
@vtjnash vtjnash deleted the jn/macroexpand-stacktraces branch September 8, 2017 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage) macros @macros
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant