mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:07:44 +00:00
LibJS: Reset scheduled-jump flag when throwing an exception
Otherwise we might attempt to follow the scheduled jump later
This commit is contained in:
parent
f5645e3c9c
commit
4da5b8ec67
2 changed files with 23 additions and 0 deletions
|
@ -277,6 +277,7 @@ void Interpreter::run_bytecode()
|
||||||
|
|
||||||
if (result.is_error()) [[unlikely]] {
|
if (result.is_error()) [[unlikely]] {
|
||||||
reg(Register::exception()) = *result.throw_completion().value();
|
reg(Register::exception()) = *result.throw_completion().value();
|
||||||
|
m_scheduled_jump = {};
|
||||||
auto const* handler = m_current_block->handler();
|
auto const* handler = m_current_block->handler();
|
||||||
auto const* finalizer = m_current_block->finalizer();
|
auto const* finalizer = m_current_block->finalizer();
|
||||||
if (!handler && !finalizer)
|
if (!handler && !finalizer)
|
||||||
|
|
|
@ -339,3 +339,25 @@ test("labelled break in finally overrides labelled break in try", () => {
|
||||||
|
|
||||||
expect(executionOrder).toEqual([1, 2]);
|
expect(executionOrder).toEqual([1, 2]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("Throw while breaking", () => {
|
||||||
|
const executionOrder = [];
|
||||||
|
try {
|
||||||
|
for (const i = 1337; ; expect().fail("Jumped to for loop update block")) {
|
||||||
|
try {
|
||||||
|
executionOrder.push(1);
|
||||||
|
break;
|
||||||
|
} finally {
|
||||||
|
executionOrder.push(2);
|
||||||
|
throw 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
executionOrder.push(3);
|
||||||
|
}
|
||||||
|
expect(() => {
|
||||||
|
i;
|
||||||
|
}).toThrowWithMessage(ReferenceError, "'i' is not defined");
|
||||||
|
|
||||||
|
expect(executionOrder).toEqual([1, 2, 3]);
|
||||||
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue