Skip to content

Truly independent web browser

LibJS: Resume at the exception handler when a variable access throws

Tim Ledbetter64d8392dbdcf
diff --git a/Libraries/LibJS/Rust/src/interpreter/slow_paths/bindings.rs b/Libraries/LibJS/Rust/src/interpreter/slow_paths/bindings.rs
index 8b4011be48f..261223ce09f 100644
--- a/Libraries/LibJS/Rust/src/interpreter/slow_paths/bindings.rs
+++ b/Libraries/LibJS/Rust/src/interpreter/slow_paths/bindings.rs
@@ -276,7 +276,7 @@ fn throw_error(
/// What a binding helper returns to continue after its instruction.
fn continue_after_instruction(pc: u32) -> SlowPathControl {
- SlowPathControl::dispatch_at(pc)
+ SlowPathControl::continue_at(pc)
}
fn advance_or_continue(pc: u32, next_pc: SlowPathControl, instruction_length: u32) -> SlowPathControl {
diff --git a/Tests/LibJS/Runtime/try-catch-finally.js b/Tests/LibJS/Runtime/try-catch-finally.js
index 930c0db34dc..60bd3dc5726 100644
--- a/Tests/LibJS/Runtime/try-catch-finally.js
+++ b/Tests/LibJS/Runtime/try-catch-finally.js
@@ -162,6 +162,22 @@ test("try/catch/finally with exception in try, catch and finally", () => {
expect(finallyHasBeenExecuted).toBeTrue();
});
+test("exception from a variable read in a callee is caught by the caller", () => {
+ function call(read) {
+ try {
+ read();
+ } catch (error) {
+ return error;
+ }
+ return null;
+ }
+ for (let padding = 0; padding < 64; ++padding) {
+ const read = new Function(`return () => { ${"debugger; ".repeat(padding)}return x; }; let x;`)();
+ expect(call(read)).toBeInstanceOf(ReferenceError);
+ expect(call(read)).toBeInstanceOf(ReferenceError);
+ }
+});
+
test("try statement must have either 'catch' or 'finally' clause", () => {
expect("try {} catch {}").toEval();
expect("try {} catch (e) {}").toEval();