From 0ab4fe4de445890aaacdc62a7b7c2be05be60959 Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Thu, 7 Mar 2019 14:51:29 +0100 Subject: [PATCH] pop top frame from stack if we throw evaluating it (#111) * pop top frame from stack if we error evaluating it * add breakpoint test --- src/interpret.jl | 7 ++++++- test/breakpoints.jl | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/interpret.jl b/src/interpret.jl index b72acdefd0ca24..284c0201d6c7c2 100644 --- a/src/interpret.jl +++ b/src/interpret.jl @@ -212,7 +212,12 @@ function evaluate_call!(stack, frame::JuliaStackFrame, call_expr::Expr, pc; exec push!(stack, newframe) return BreakpointRef(newframe.code, newframe.pc[]) end - ret = exec!(stack, newframe) + ret = try + exec!(stack, newframe) + catch e + pop!(stack) + rethrow(e) + end isa(ret, BreakpointRef) && return ret pop!(stack) push!(junk, newframe) # rather than going through GC, just re-use it diff --git a/test/breakpoints.jl b/test/breakpoints.jl index f78641bc06b754..5282bfdb7b3f33 100644 --- a/test/breakpoints.jl +++ b/test/breakpoints.jl @@ -118,6 +118,7 @@ end frame = JuliaInterpreter.enter_call(f_exc_outer); v = JuliaInterpreter.finish_and_return!(stack, frame) @test v isa ErrorException + @test isempty(stack) finally JuliaInterpreter.break_on_error[] = false end