@@ -123,7 +123,7 @@ function Base.showerror(io::IO, exc::MacroExpansionError)
123123 end
124124end
125125
126- function eval_macro_name (ctx:: MacroExpansionContext , ex)
126+ function eval_macro_name (ctx:: MacroExpansionContext , ex:: SyntaxTree )
127127 # `ex1` might contain a nontrivial mix of scope layers so we can't just
128128 # `eval()` it, as it's already been partially lowered by this point.
129129 # Instead, we repeat the latter parts of `lower()` here.
@@ -154,7 +154,7 @@ function has_syntax_tree_macro(mac)
154154 Base. methods (mac))
155155end
156156
157- function expand_macro (ctx:: MacroExpansionContext , ex)
157+ function expand_macro (ctx:: MacroExpansionContext , ex:: SyntaxTree )
158158 @assert kind (ex) == K " macrocall"
159159
160160 macname = ex[1 ]
@@ -186,12 +186,13 @@ function expand_macro(ctx::MacroExpansionContext, ex)
186186 expanded = try
187187 invokelatest (macfunc, macro_args... )
188188 catch exc
189+ # TODO : Using rethrow() is kinda ugh. Is there a way to avoid it?
190+ # NOTE: Although currently rethrow() is necessary to allow outside catchers to access full stacktrace information
189191 if exc isa MacroExpansionError
190192 # Add context to the error.
191- # TODO : Using rethrow() is kinda ugh. Is there a way to avoid it?
192193 rethrow (MacroExpansionError (mctx, exc. ex, exc. msg, exc. position))
193194 else
194- throw (MacroExpansionError (mctx, ex, " Error expanding macro" , :all ))
195+ rethrow (MacroExpansionError (mctx, ex, " Error expanding macro" , :all ))
195196 end
196197 end
197198
@@ -282,7 +283,7 @@ function expand_forms_1(ctx::MacroExpansionContext, ex::SyntaxTree)
282283 @chk numchildren (ex) == 1
283284 # TODO : Upstream should set a general flag for detecting parenthesized
284285 # expressions so we don't need to dig into `green_tree` here. Ugh!
285- plain_symbol = has_flags (ex, JuliaSyntax. COLON_QUOTE) &&
286+ plain_symbol = has_flags (ex, JuliaSyntax. COLON_QUOTE) &&
286287 kind (ex[1 ]) == K " Identifier" &&
287288 (sr = sourceref (ex); sr isa SourceRef && kind (sr. green_tree[2 ]) != K " parens" )
288289 if plain_symbol
@@ -404,4 +405,3 @@ function expand_forms_1(mod::Module, ex::SyntaxTree, recurse::Bool=true)
404405 ctx. current_layer)
405406 return ctx2, reparent (ctx2, ex2)
406407end
407-
0 commit comments