diff --git a/src/interpret.jl b/src/interpret.jl index 12d65146968ea4..a82015925a350b 100644 --- a/src/interpret.jl +++ b/src/interpret.jl @@ -396,10 +396,14 @@ function _step_expr!(stack, frame, @nospecialize(node), pc::JuliaProgramCounter, elseif node.head == :thunk newframe = prepare_thunk(moduleof(frame), node) frame.pc[] = pc - push!(stack, frame) - finish!(stack, newframe, true) - pop!(stack) - push!(junk, newframe) # rather than going through GC, just re-use it + if isa(stack, Compiled) + finish!(stack, newframe, true) + else + push!(stack, frame) + finish!(stack, newframe, true) + pop!(stack) + push!(junk, newframe) # rather than going through GC, just re-use it + end elseif node.head == :global # error("fixme") elseif node.head == :toplevel diff --git a/test/utils.jl b/test/utils.jl index bc759d85e0f769..380f482ee11e1b 100644 --- a/test/utils.jl +++ b/test/utils.jl @@ -175,7 +175,22 @@ function run_test_by_eval(test, fullpath, nstmts) while true ret, nstmtsleft = evaluate_limited!(stack, frame, nstmtsleft) isa(ret, Some{Any}) && break - isa(ret, Aborted) && (push!(aborts, ret); break) + if isa(ret, Aborted) + push!(aborts, ret) + # run the remaining statements in Compiled mode, thus allowing later tests + # to work. Largely fixes #30. Of course this is not perfect, because it + # may repeat some work done previously, but it's a decent start. + # TODO: recurse over stack. The key problem is that the inner-most frame is lost. + frame = frame[3] + pc = frame.pc[] + while true # This is finish!, except we need to run it at top level + new_pc = _step_expr!(Compiled(), frame, pc, true) + new_pc == nothing && break + pc = new_pc + end + frame.pc[] = pc + break + end end end println("Finished ", $test)