mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:07:34 +00:00
parent
7ee47d81ca
commit
2372584b18
2 changed files with 23 additions and 3 deletions
|
@ -2899,9 +2899,14 @@ void Compiler::compile_continue_pending_unwind(Bytecode::Op::ContinuePendingUnwi
|
|||
Assembler::Operand::Register(GPR1),
|
||||
label_for(op.resume_target().block()));
|
||||
|
||||
// finish the pending return from the try block
|
||||
store_vm_register(Bytecode::Register::return_value(), GPR0);
|
||||
jump_to_exit();
|
||||
if (auto const* finalizer = m_current_block->finalizer()) {
|
||||
// The current block has its own finalizer, we have to jump there instead of returning.
|
||||
m_assembler.jump(label_for(*finalizer));
|
||||
} else {
|
||||
// finish the pending return from the try block
|
||||
store_vm_register(Bytecode::Register::return_value(), GPR0);
|
||||
jump_to_exit();
|
||||
}
|
||||
}
|
||||
|
||||
static void cxx_create_lexical_environment(VM& vm)
|
||||
|
|
|
@ -9,3 +9,18 @@ test("return from try followed by finally with function call inside", () => {
|
|||
|
||||
expect(value).toBe(1);
|
||||
});
|
||||
|
||||
test("return from outer finally with nested unwind contexts", () => {
|
||||
let value = (() => {
|
||||
try {
|
||||
try {
|
||||
return 1;
|
||||
} finally {
|
||||
}
|
||||
} finally {
|
||||
return 2;
|
||||
}
|
||||
})();
|
||||
|
||||
expect(value).toBe(2);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue