Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix returning from LEAVE to surrounding scope
When a LEAVE phaser is run during an unwind, there is no valid return_address set in the LEAVE phasers caller frame. (It return_address is actually set to cur_op which is still the one that started the unwind in some unrelated frame.) Thus when a `return` in a LEAVE happens, the handler of the outer frame is missed, because `search_frame_handlers_lex()` validates that the `return_address` lies in the handlers area. Luckily there is a flag set on the LEAVE's outer frame: MVM_FRAME_FLAG_EXIT_HAND_RUN. We can simply check for that flag and ignore the frame handlers area. This is fine to do, because frames that have an exit handler attached can not be inlined. This fixes: sub s() { LEAVE return 5; return 7; } s() which before this fix printed Attempt to return outside of any Routine in sub s at leave-bug.raku line 2 in block at leave-bug.raku line 5 Fixes MoarVM#1784
- Loading branch information