Skip to content

Commit

Permalink
propagate the nothing case
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Jul 18, 2024
1 parent b723d6c commit 90a83d1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
34 changes: 18 additions & 16 deletions src/interpret.jl
Original file line number Diff line number Diff line change
Expand Up @@ -457,23 +457,25 @@ function coverage_visit_line!(frame::Frame)
code.report_coverage || return
src = code.src
@static if VERSION v"1.12.0-DEV.173"
lineinfo = linetable(src, pc)
file, line = lineinfo.file, lineinfo.line
if line != frame.last_codeloc
file isa Symbol || (file = Symbol(file)::Symbol)
@ccall jl_coverage_visit_line(file::Cstring, sizeof(file)::Csize_t, line::Cint)::Cvoid
frame.last_codeloc = line
end
lineinfo = linetable(src, pc)
if lineinfo !== nothing
file, line = lineinfo.file, lineinfo.line
if line != frame.last_codeloc
file isa Symbol || (file = Symbol(file)::Symbol)
@ccall jl_coverage_visit_line(file::Cstring, sizeof(file)::Csize_t, line::Cint)::Cvoid
frame.last_codeloc = line
end
end
else # VERSION < v"1.12.0-DEV.173"
codeloc = src.codelocs[pc]
if codeloc != frame.last_codeloc && codeloc != 0
linetable = src.linetable::Vector{Any}
lineinfo = linetable[codeloc]::Core.LineInfoNode
file, line = lineinfo.file, lineinfo.line
file isa Symbol || (file = Symbol(file)::Symbol)
@ccall jl_coverage_visit_line(file::Cstring, sizeof(file)::Csize_t, line::Cint)::Cvoid
frame.last_codeloc = codeloc
end
codeloc = src.codelocs[pc]
if codeloc != frame.last_codeloc && codeloc != 0
linetable = src.linetable::Vector{Any}
lineinfo = linetable[codeloc]::Core.LineInfoNode
file, line = lineinfo.file, lineinfo.line
file isa Symbol || (file = Symbol(file)::Symbol)
@ccall jl_coverage_visit_line(file::Cstring, sizeof(file)::Csize_t, line::Cint)::Cvoid
frame.last_codeloc = codeloc
end
end # @static if
end

Expand Down
3 changes: 2 additions & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,10 @@ function lineoffset(framecode::FrameCode)
return offset
end

function getline(ln::Union{LineTypes,Expr})
function getline(ln::Union{LineTypes,Expr,Nothing})
_getline(ln::LineTypes) = Int(ln.line)
_getline(ln::Expr) = ln.args[1]::Int # assuming ln.head === :line
_getline(::Nothing) = nothing
return _getline(ln)
end
function getfile(ln::Union{LineTypes,Expr})
Expand Down

0 comments on commit 90a83d1

Please sign in to comment.