File tree Expand file tree Collapse file tree 2 files changed +29
-8
lines changed Expand file tree Collapse file tree 2 files changed +29
-8
lines changed Original file line number Diff line number Diff line change @@ -118,14 +118,18 @@ function Base.showerror(io::IO, exc::MacroExpansionError)
118
118
# * How to deal with highlighting trivia? Could provide a token kind or
119
119
# child position within the raw tree? How to abstract this??
120
120
src = sourceref (exc. ex)
121
- fb = first_byte (src)
122
- lb = last_byte (src)
123
- pos = exc. position
124
- byterange = pos == :all ? (fb: lb) :
125
- pos == :begin ? (fb: fb- 1 ) :
126
- pos == :end ? (lb+ 1 : lb) :
127
- error (" Unknown position $pos " )
128
- highlight (io, src. file, byterange, note= exc. msg)
121
+ if src isa LineNumberNode
122
+ highlight (io, src, note= exc. msg)
123
+ else
124
+ fb = first_byte (src)
125
+ lb = last_byte (src)
126
+ pos = exc. position
127
+ byterange = pos == :all ? (fb: lb) :
128
+ pos == :begin ? (fb: fb- 1 ) :
129
+ pos == :end ? (lb+ 1 : lb) :
130
+ error (" Unknown position $pos " )
131
+ highlight (io, src. file, byterange, note= exc. msg)
132
+ end
129
133
if ! isnothing (exc. err)
130
134
print (io, " \n Caused by:\n " )
131
135
showerror (io, exc. err)
Original file line number Diff line number Diff line change @@ -239,6 +239,23 @@ MacroExpansionError while expanding @oldstyle_error in module Main.macros.test_m
239
239
Caused by:
240
240
Some error in old style macro"""
241
241
242
+ # Parsed to prevent this test being sensitive to its line number
243
+ Base. eval (test_mod, JuliaLowering. parsestmt (Expr, """
244
+ macro oldstyle_calls_oldstyle_error()
245
+ :(@oldstyle_error)
246
+ end
247
+ """ ))
248
+ @test try
249
+ JuliaLowering. include_string (test_mod, """
250
+ @oldstyle_calls_oldstyle_error
251
+ """ )
252
+ catch exc
253
+ sprint (showerror, exc)
254
+ end == " MacroExpansionError while expanding @oldstyle_error in module Main.macros.test_mod:
255
+ #= line 2 =# - Error expanding macro
256
+ Caused by:
257
+ Some error in old style macro"
258
+
242
259
# Old-style macros returning non-Expr values
243
260
Base. eval (test_mod, :(
244
261
macro oldstyle_non_Expr ()
You can’t perform that action at this time.
0 commit comments