diff --git a/src/breakpoints.jl b/src/breakpoints.jl index 4d785244fb65d..fe85a575b39b0 100644 --- a/src/breakpoints.jl +++ b/src/breakpoints.jl @@ -165,7 +165,9 @@ function framecode_matches_breakpoint(framecode::FrameCode, bp::BreakpointFileLo return false end else - path, _ = whereis(framecode, 1) + w = whereis(framecode, 1) + w === nothing && return false + path, _ = w path = CodeTracking.maybe_fix_path(path) ispath(path) && (path = realpath(path)) @@ -186,7 +188,6 @@ function shouldbreak(frame::Frame, pc::Int) end function prepare_slotfunction(framecode::FrameCode, body::Union{Symbol,Expr}) - ismeth = framecode.scope isa Method uslotnames = Set{Symbol}() slotnames = Symbol[] for name in framecode.src.slotnames @@ -223,13 +224,14 @@ function prepare_slotfunction(framecode::FrameCode, body::Union{Symbol,Expr}) push!(assignments, :($maxexsym = $maxexpr)) push!(assignments, :($slotname = $maxexsym > 0 ? something($dataname.locals[$maxexsym]) : $default)) end - if ismeth - syms = sparam_syms(framecode.scope) + scope = framecode.scope + if isa(scope, Method) + syms = sparam_syms(scope) for i = 1:length(syms) push!(assignments, Expr(:(=), syms[i], :($dataname.sparams[$i]))) end end - funcname = ismeth ? gensym("slotfunction") : gensym(Symbol(framecode.scope, "_slotfunction")) + funcname = isa(scope, Method) ? gensym("slotfunction") : gensym(Symbol(scope, "_slotfunction")) return Expr(:function, Expr(:call, funcname, framename), Expr(:block, assignments..., body)) end diff --git a/src/interpret.jl b/src/interpret.jl index 37b8bef07c475..178f34f313f61 100644 --- a/src/interpret.jl +++ b/src/interpret.jl @@ -282,7 +282,7 @@ end function structname(frame, node) name = node.args[1] if isa(name, GlobalRef) - mod = name.module + mod = name.mod name = name.name else mod = moduleof(frame) @@ -489,7 +489,7 @@ function step_expr!(@nospecialize(recurse), frame, @nospecialize(node), istoplev elseif node.head === :const g = node.args[1] if isa(g, GlobalRef) - mod, name = g.module, g.name + mod, name = g.mod, g.name else mod, name = moduleof(frame), g::Symbol end diff --git a/src/utils.jl b/src/utils.jl index 1de9eae62d19f..04a188f2273a9 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -299,7 +299,11 @@ function lineoffset(framecode::FrameCode) return offset end -getline(ln) = Int(isexpr(ln, :line) ? ln.args[1] : ln.line)::Int +function getline(ln::Union{LineTypes,Expr}) + _getline(ln::LineTypes) = ln.line + _getline(ln::Expr) = ln.args[1] # assuming ln.head === :line + return Int(_getline(ln))::Int +end # work around compiler error on 1.2 @static if v"1.2.0" <= VERSION < v"1.3" getfile(ln) = begin @@ -317,7 +321,11 @@ getline(ln) = Int(isexpr(ln, :line) ? ln.args[1] : ln.line)::Int CodeTracking.maybe_fixup_stdlib_path(path) end else - getfile(ln) = CodeTracking.maybe_fixup_stdlib_path(String(isexpr(ln, :line) ? ln.args[2] : ln.file)::String) + function getfile(ln::Union{LineTypes,Expr}) + _getfile(ln::LineTypes) = ln.file::Symbol + _getfile(ln::Expr) = ln.args[2]::Symbol # assuming ln.head === :line + return CodeTracking.maybe_fixup_stdlib_path(String(_getfile(ln))) + end end function firstline(ex::Expr)