Skip to content

Commit 35c5234

Browse files
committed
fix regression in error line numbers
see e.g. #922
1 parent 042c4d5 commit 35c5234

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/codegen.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4974,6 +4974,7 @@ static Function *emit_function(jl_lambda_info_t *lam)
49744974
}
49754975
if (do_coverage)
49764976
coverageVisitLine(filename, lno);
4977+
ctx.lineno = lno;
49774978
}
49784979
if (jl_is_labelnode(stmt)) {
49794980
if (prevlabel) continue;

test/backtrace.jl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,26 @@ linenum = @__LINE__; f12977(; args...) = ()
7171
loc = functionloc(f12977)
7272
@test endswith(loc[1], "backtrace.jl")
7373
@test loc[2] == linenum
74+
75+
code_loc(p, skipC=true) = ccall(:jl_lookup_code_address, Any, (Ptr{Void},Cint), p, skipC)
76+
77+
@noinline function test_throw_commoning(x)
78+
if x==1; throw(AssertionError()); end
79+
if x==2; throw(AssertionError()); end
80+
end
81+
82+
let
83+
local b1, b2
84+
try
85+
test_throw_commoning(1)
86+
catch
87+
b1 = catch_backtrace()
88+
end
89+
try
90+
test_throw_commoning(2)
91+
catch
92+
b2 = catch_backtrace()
93+
end
94+
@test code_loc(b1[4])[1] == code_loc(b2[4])[1] == :test_throw_commoning
95+
@test code_loc(b1[4])[3] != code_loc(b2[4])[3]
96+
end

0 commit comments

Comments
 (0)