@@ -113,7 +113,7 @@ function Base.showerror(io::IO, exc::MacroExpansionError)
113113 highlight (io, src. file, byterange, note= exc. msg)
114114end
115115
116- function eval_macro_name (ctx, ex)
116+ function eval_macro_name (ctx:: MacroExpansionContext , ex:: SyntaxTree )
117117 # `ex1` might contain a nontrivial mix of scope layers so we can't just
118118 # `eval()` it, as it's already been partially lowered by this point.
119119 # Instead, we repeat the latter parts of `lower()` here.
@@ -127,7 +127,7 @@ function eval_macro_name(ctx, ex)
127127 eval (mod, expr_form)
128128end
129129
130- function expand_macro (ctx, ex)
130+ function expand_macro (ctx:: MacroExpansionContext , ex:: SyntaxTree )
131131 @assert kind (ex) == K " macrocall"
132132
133133 macname = ex[1 ]
@@ -148,12 +148,13 @@ function expand_macro(ctx, ex)
148148 # TODO : Allow invoking old-style macros for compat
149149 invokelatest (macfunc, macro_args... )
150150 catch exc
151+ # TODO : Using rethrow() is kinda ugh. Is there a way to avoid it?
152+ # NOTE: Although currently rethrow() is necessary to allow outside catchers to access full stacktrace information
151153 if exc isa MacroExpansionError
152154 # Add context to the error.
153- # TODO : Using rethrow() is kinda ugh. Is there a way to avoid it?
154155 rethrow (MacroExpansionError (mctx, exc. ex, exc. msg, exc. position))
155156 else
156- throw (MacroExpansionError (mctx, ex, " Error expanding macro" , :all ))
157+ rethrow (MacroExpansionError (mctx, ex, " Error expanding macro" , :all ))
157158 end
158159 end
159160
@@ -237,7 +238,7 @@ function expand_forms_1(ctx::MacroExpansionContext, ex::SyntaxTree)
237238 @chk numchildren (ex) == 1
238239 # TODO : Upstream should set a general flag for detecting parenthesized
239240 # expressions so we don't need to dig into `green_tree` here. Ugh!
240- plain_symbol = has_flags (ex, JuliaSyntax. COLON_QUOTE) &&
241+ plain_symbol = has_flags (ex, JuliaSyntax. COLON_QUOTE) &&
241242 kind (ex[1 ]) == K " Identifier" &&
242243 (sr = sourceref (ex); sr isa SourceRef && kind (sr. green_tree[2 ]) != K " parens" )
243244 if plain_symbol
@@ -337,4 +338,3 @@ function expand_forms_1(mod::Module, ex::SyntaxTree)
337338 ctx. current_layer)
338339 return ctx2, reparent (ctx2, ex2)
339340end
340-
0 commit comments