Skip to content

Commit

Permalink
fix regression in error line numbers
Browse files Browse the repository at this point in the history
see e.g. #922

(cherry picked from commit 35c5234)
  • Loading branch information
JeffBezanson authored and tkelman committed Sep 25, 2015
1 parent 14fb0a7 commit ad4a961
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4750,6 +4750,7 @@ static Function *emit_function(jl_lambda_info_t *lam)
}
if (do_coverage)
coverageVisitLine(filename, lno);
ctx.lineno = lno;
}
if (jl_is_labelnode(stmt)) {
if (prevlabel) continue;
Expand Down
23 changes: 23 additions & 0 deletions test/backtrace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,26 @@ linenum = @__LINE__; f12977(; args...) = ()
loc = functionloc(f12977)
@test endswith(loc[1], "backtrace.jl")
@test loc[2] == linenum

code_loc(p, skipC=true) = ccall(:jl_lookup_code_address, Any, (Ptr{Void},Cint), p, skipC)

@noinline function test_throw_commoning(x)
if x==1; throw(AssertionError()); end
if x==2; throw(AssertionError()); end
end

let
local b1, b2
try
test_throw_commoning(1)
catch
b1 = catch_backtrace()
end
try
test_throw_commoning(2)
catch
b2 = catch_backtrace()
end
@test code_loc(b1[4])[1] == code_loc(b2[4])[1] == :test_throw_commoning
@test code_loc(b1[4])[3] != code_loc(b2[4])[3]
end

0 comments on commit ad4a961

Please sign in to comment.