File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -555,16 +555,18 @@ behaviors:
555
555
"""
556
556
function handle_err (@nospecialize (recurse), frame, err)
557
557
data = frame. framedata
558
+ err_will_be_thrown_to_top_level = isempty (data. exception_frames) && ! data. caller_will_catch_err
558
559
if break_on_error[]
559
560
# See if the current frame or a frame in the stack will catch this exception,
560
561
# otherwise this exception would have been thrown to the user and we should
561
562
# return a breakpoint
562
- if isempty (data . exception_frames) && ! data . caller_will_catch_err
563
+ if err_will_be_thrown_to_top_level
563
564
return BreakpointRef (frame. framecode, frame. pc, err)
564
565
end
565
566
end
566
567
if isempty (data. exception_frames)
567
- if frame. caller != = nothing
568
+ is_root_frame = frame. caller === nothing
569
+ if ! is_root_frame && ! err_will_be_thrown_to_top_level
568
570
frame. caller. callee = nothing
569
571
recycle (frame)
570
572
end
Original file line number Diff line number Diff line change @@ -278,7 +278,7 @@ struct B{T} end
278
278
g_inner () = error ()
279
279
fr = JuliaInterpreter. enter_call (f_outer)
280
280
@test_throws ErrorException debug_command (fr, :finish )
281
- @test stacklength (fr) == 1
281
+ @test stacklength (fr) == 3
282
282
283
283
# Break on error
284
284
try
@@ -424,4 +424,21 @@ struct B{T} end
424
424
frame, pc = debug_command (frame, :si )
425
425
@test frame. pc == 1
426
426
end
427
+
428
+
429
+ @testset " preservation of stack when throwing to toplevel" begin
430
+ f () = " αβ" [2 ]
431
+ frame1 = JuliaInterpreter. enter_call (f);
432
+ err = try debug_command (frame1, :c )
433
+ catch err
434
+ err
435
+ end
436
+ try
437
+ break_on (:error )
438
+ frame2, pc = @interpret f ()
439
+ @test leaf (frame2). framecode. scope === leaf (frame1). framecode. scope
440
+ finally
441
+ break_off (:error )
442
+ end
443
+ end
427
444
# end
You can’t perform that action at this time.
0 commit comments