mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-04 18:23:39 +00:00
LibJS: Disallow 'continue' & 'break' outside of their respective scopes
'continue' is no longer allowed outside of a loop, and an unlabeled 'break' is not longer allowed outside of a loop or switch statement. Labeled 'break' statements are still allowed everywhere, even if the label does not exist.
This commit is contained in:
parent
b85af075b7
commit
e49ea1b520
Notes:
sideshowbarker
2024-07-19 01:58:28 +09:00
Author: https://github.com/mattco98
Commit: e49ea1b520
Pull-request: https://github.com/SerenityOS/serenity/pull/3718
Issue: https://github.com/SerenityOS/serenity/issues/3608
3 changed files with 44 additions and 5 deletions
18
Libraries/LibJS/Tests/break-continue-syntax-errors.js
Normal file
18
Libraries/LibJS/Tests/break-continue-syntax-errors.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
test("'break' syntax errors", () => {
|
||||
expect("break").not.toEval();
|
||||
expect("break label").not.toEval();
|
||||
expect("{ break }").not.toEval();
|
||||
// FIXME: Parser does not throw error on nonexistent label
|
||||
// expect("{ break label }.not.toEval();
|
||||
expect("label: { break label }").toEval();
|
||||
});
|
||||
|
||||
test("'continue' syntax errors", () => {
|
||||
expect("continue").not.toEval();
|
||||
expect("continue label").not.toEval();
|
||||
expect("{ continue }").not.toEval();
|
||||
expect("{ continue label }").not.toEval();
|
||||
expect("label: { continue label }").not.toEval();
|
||||
|
||||
expect("switch (true) { case true: continue; }").not.toEval();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue