mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-11 21:52:53 +00:00
LibJS: Distinguish between statement and declaration
This separates matching/parsing of statements and declarations and fixes a few edge cases where the parser would incorrectly accept a declaration where only a statement is allowed - for example: if (foo) const a = 1; for (var bar;;) function b() {} while (baz) class c {}
This commit is contained in:
parent
f8ae6fa713
commit
80bb62b9cc
Notes:
sideshowbarker
2024-07-19 01:47:04 +09:00
Author: https://github.com/linusg
Commit: 80bb62b9cc
Pull-request: https://github.com/SerenityOS/serenity/pull/3821
Reviewed-by: https://github.com/emanuele6
4 changed files with 73 additions and 30 deletions
Libraries/LibJS/Tests
|
@ -0,0 +1,6 @@
|
|||
test("Declaration in single-statement context is a syntax error", () => {
|
||||
expect("if (0) const foo = 1").not.toEval();
|
||||
expect("while (0) function foo() {}").not.toEval();
|
||||
expect("for (var 0;;) class foo() {}").not.toEval();
|
||||
expect("do let foo = 1 while (0)").not.toEval();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue