mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-07 10:06:03 +00:00
LibJS: Defer execution of switch default clause until after case clauses
When we encounter a default clause in a switch statement, we should not execute it immediately, instead we need to wait until all case clauses have been executed as a matching case clause can break from the switch/case. The code is nowhere close to the spec, so instead of fixing it properly I just made it slightly worse, but correct. Needs a complete refactor at some point.
This commit is contained in:
parent
a248ec63e3
commit
ababcc5725
Notes:
sideshowbarker
2024-07-18 03:26:10 +09:00
Author: https://github.com/linusg
Commit: ababcc5725
Pull-request: https://github.com/SerenityOS/serenity/pull/10217
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/awesomekling ✅
2 changed files with 41 additions and 12 deletions
|
@ -0,0 +1,9 @@
|
|||
test("default clause before matching case clause", () => {
|
||||
switch (1 + 2) {
|
||||
default:
|
||||
expect().fail();
|
||||
break;
|
||||
case 3:
|
||||
return;
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue