Skip to content

Commit dc335ed

Browse files
authored
Fix destructuring signature() return value before nothing check (#142)
In 3b60b6a, the return type of signature() was changed from `Tuple{Union{Nothing, Type}, PC}` to `Tuple{Union{Nothing, MethodInfoKey}, PC}`:(where PC = `Union{Int, BreakpointRef}`), but the check for `nothing` wasn't moved before the destructuring of the `MethodInfoKey`. This cuased the (caught) exception described intimholy/Revise.jl#1002.
1 parent 83a9910 commit dc335ed

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/signatures.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,9 @@ function get_running_name(interp::Interpreter, frame::Frame, pc::Int, name::Glob
446446
pctop -= 1
447447
stmt = pc_expr(frame, pctop)
448448
end # end fix
449-
(mt, sigtparent), lastpcparent = signature(interp, frame, pctop)
450-
sigtparent === nothing && return name, pc, lastpcparent
449+
methinfo, lastpcparent = signature(interp, frame, pctop)
450+
methinfo === nothing && return name, pc, lastpcparent
451+
mt, sigtparent = methinfo
451452
methparent = whichtt(sigtparent, mt)
452453
methparent === nothing && return name, pc, lastpcparent # caller isn't defined, no correction is needed
453454
if isgen
@@ -598,7 +599,7 @@ function methoddef!(interp::Interpreter, signatures::Vector{MethodInfoKey}, fram
598599
end
599600
found || return nothing
600601
while true # methods containing inner methods may need multiple trips through this loop
601-
(mt, sigt), pc = signature(interp, frame, stmt, pc)
602+
methinfo, pc = signature(interp, frame, stmt, pc)
602603
stmt = pc_expr(frame, pc)
603604
while !isexpr(stmt, :method, 3)
604605
pc = next_or_nothing(interp, frame, pc) # this should not check define, we've probably already done this once
@@ -608,7 +609,8 @@ function methoddef!(interp::Interpreter, signatures::Vector{MethodInfoKey}, fram
608609
pc3 = pc
609610
stmt = stmt::Expr
610611
name3 = normalize_defsig(stmt.args[1], frame)
611-
sigt === nothing && (error("expected a signature"); return next_or_nothing(interp, frame, pc)), pc3
612+
methinfo === nothing && (error("expected a signature"); return next_or_nothing(interp, frame, pc)), pc3
613+
mt, sigt = methinfo
612614
# Methods like f(x::Ref{<:Real}) that use gensymmed typevars will not have the *exact*
613615
# signature of the active method. So let's get the active signature.
614616
frame.pc = pc

0 commit comments

Comments
 (0)