Skip to content

Commit 209fd47

Browse files
pfitzsebKristofferC
authored andcommitted
handle codeloc==0 in linenumber (#65)
* handle `codeloc==0` in `linenumber` * return `nothing` instead
1 parent a4ae7bf commit 209fd47

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/interpret.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,13 +613,19 @@ end
613613

614614
isgotonode(node) = isa(node, GotoNode) || isexpr(node, :gotoifnot)
615615

616-
linenumber(frame) = linenumber(frame, frame.pc[])
617-
function linenumber(frame, pc)
616+
"""
617+
linenumber(frame, pc=frame.pc[])
618+
619+
Return line number for `frame` at `pc` or `nothing` if it cannot be determined.
620+
"""
621+
function linenumber(frame, pc=frame.pc[])
618622
codeloc = frame.code.code.codelocs[pc.next_stmt]
623+
codeloc == 0 && return nothing
619624
return frame.code.scope isa Method ?
620625
frame.code.code.linetable[codeloc].line :
621626
codeloc
622627
end
628+
623629
function next_line!(stack, frame, dbstack = nothing)
624630
initial = linenumber(frame)
625631
first = true

0 commit comments

Comments
 (0)