Skip to content

Commit

Permalink
handle codeloc==0 in linenumber (#65)
Browse files Browse the repository at this point in the history
* handle `codeloc==0` in `linenumber`

* return `nothing` instead
  • Loading branch information
pfitzseb authored and KristofferC committed Feb 25, 2019
1 parent a4ae7bf commit 209fd47
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/interpret.jl
Original file line number Diff line number Diff line change
Expand Up @@ -613,13 +613,19 @@ end

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

linenumber(frame) = linenumber(frame, frame.pc[])
function linenumber(frame, pc)
"""
linenumber(frame, pc=frame.pc[])
Return line number for `frame` at `pc` or `nothing` if it cannot be determined.
"""
function linenumber(frame, pc=frame.pc[])
codeloc = frame.code.code.codelocs[pc.next_stmt]
codeloc == 0 && return nothing
return frame.code.scope isa Method ?
frame.code.code.linetable[codeloc].line :
codeloc
end

function next_line!(stack, frame, dbstack = nothing)
initial = linenumber(frame)
first = true
Expand Down

0 comments on commit 209fd47

Please sign in to comment.