mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:37:46 +00:00
LibJS: Fix return value of TryStatement with finalizer
Previously we would always return the result of executing the finalizer, however the spec dictates the finalizer result must only be returned for a non-normal completion. I added some more comments along the way, which should make it more clear what's going on - the unwinding and exception flow isn't super straightforward here.
This commit is contained in:
parent
e8cbcc2fbf
commit
7cbede4342
2 changed files with 34 additions and 7 deletions
|
@ -32,3 +32,15 @@ test("return from finally block", () => {
|
|||
}
|
||||
expect(foo()).toBe("baz");
|
||||
});
|
||||
|
||||
test("return from catch block with empty finally", () => {
|
||||
function foo() {
|
||||
try {
|
||||
throw "foo";
|
||||
} catch {
|
||||
return "bar";
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
expect(foo()).toBe("bar");
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue