@@ -80,14 +80,11 @@ struct MacroExpansionError <: Exception
8080 msg:: String
8181 " The source position relative to the node - may be `:begin` or `:end` or `:all`"
8282 position:: Symbol
83- " Error that occurred inside the macro function call (note that this may not be defined )"
83+ " Error that occurred inside the macro function call (`nothing` if no inner exception )"
8484 err
85- MacroExpansionError (
86- context:: Union{Nothing,MacroContext} , ex:: SyntaxTree , msg:: AbstractString , position:: Symbol
87- ) = new (context, ex, msg, position)
8885 MacroExpansionError (
8986 context:: Union{Nothing,MacroContext} , ex:: SyntaxTree , msg:: AbstractString , position:: Symbol ,
90- @nospecialize err
87+ @nospecialize err = nothing
9188 ) = new (context, ex, msg, position, err)
9289end
9390
@@ -161,9 +158,7 @@ function expand_macro(ctx::MacroExpansionContext, ex::SyntaxTree)
161158 catch exc
162159 if exc isa MacroExpansionError
163160 # Add context to the error.
164- newexc = isdefined (exc, :err ) ?
165- MacroExpansionError (mctx, exc. ex, exc. msg, exc. position, exc. err) :
166- MacroExpansionError (mctx, exc. ex, exc. msg, exc. position)
161+ newexc = MacroExpansionError (mctx, exc. ex, exc. msg, exc. position, exc. err)
167162 else
168163 newexc = MacroExpansionError (mctx, ex, " Error expanding macro" , :all , exc)
169164 end
0 commit comments