mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:58:11 +00:00
LibJS: Fix cases where we incorrectly allowed 'in' in for loops
We needed to propagate the forbidden token set to all parsing functions that can call back into parse_expression.
This commit is contained in:
parent
5da3063a39
commit
f55d7bf6f3
3 changed files with 69 additions and 50 deletions
19
Userland/Libraries/LibJS/Tests/syntax/for-loop-invalid-in.js
Normal file
19
Userland/Libraries/LibJS/Tests/syntax/for-loop-invalid-in.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
test("The use of the 'in' keyword is restricted in for loop headers", () => {
|
||||
expect("for (a ? a : a in a; false; ) ;").not.toEval();
|
||||
expect("for (a + a in b);").not.toEval();
|
||||
expect("for (a in a of a);").not.toEval();
|
||||
expect("for(a = a in a; false;);").not.toEval();
|
||||
expect("for(a += a in a; false;);").not.toEval();
|
||||
expect("for(a -= a in a; false;);").not.toEval();
|
||||
expect("for(a *= a in a; false;);").not.toEval();
|
||||
expect("for(a /= a in a; false;);").not.toEval();
|
||||
expect("for(a &= a in a; false;);").not.toEval();
|
||||
expect("for(a |= a in a; false;);").not.toEval();
|
||||
expect("for(a ^= a in a; false;);").not.toEval();
|
||||
expect("for(a ^^= a in a; false;);").not.toEval();
|
||||
expect("for(a == a in a; false;);").not.toEval();
|
||||
expect("for(a != a in a; false;);").not.toEval();
|
||||
expect("for(a === a in a; false;);").not.toEval();
|
||||
expect("for(a !== a in a; false;);").not.toEval();
|
||||
expect("for (a ?? b in c;;);").not.toEval();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue