Skip to content

Commit 9c5454c

Browse files
authored
Protect error calls from invalidation (#565)
These get called in the absence of knowledge about the second input, so protecting them with `invokelatest` avoids invalidation risk.
1 parent da3fee2 commit 9c5454c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/interpret.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function lookup_or_eval(@nospecialize(recurse), frame, @nospecialize(node))
9999
elseif f === Base.getproperty
100100
return Base.getproperty(ex.args[2], ex.args[3])
101101
else
102-
error("unknown call f ", f)
102+
Base.invokelatest(error, "unknown call f ", f)
103103
end
104104
else
105105
error("unknown expr ", ex)
@@ -129,7 +129,7 @@ function resolvefc(frame, @nospecialize(expr))
129129
(isa(a, QuoteNode) && a.value === Core.tuple) || error("unexpected ccall to ", expr)
130130
return Expr(:call, GlobalRef(Core, :tuple), (expr::Expr).args[2:end]...)
131131
end
132-
error("unexpected ccall to ", expr)
132+
Base.invokelatest(error, "unexpected ccall to ", expr)
133133
end
134134

135135
function collect_args(@nospecialize(recurse), frame::Frame, call_expr::Expr; isfc::Bool=false)
@@ -651,7 +651,7 @@ e.g., [`JuliaInterpreter.finish!`](@ref)).
651651
"""
652652
function get_return(frame)
653653
node = pc_expr(frame)
654-
is_return(node) || error("expected return statement, got ", node)
654+
is_return(node) || Base.invokelatest(error, "expected return statement, got ", node)
655655
return lookup_return(frame, node)
656656
end
657657
get_return(t::Tuple{Module,Expr,Frame}) = get_return(t[end])

0 commit comments

Comments
 (0)