mirror of
https://github.com/RGBCube/serenity
synced 2025-06-28 21:02:07 +00:00
LibJS: Disallow await keywords in static init blocks
In static init blocks 'await' cannot be used. Note that this does not cover all the cases since the parser currently cannot distinguish between expressions within parenthesis and direct expressions.
This commit is contained in:
parent
7624c3de0e
commit
cbbfcd35e7
2 changed files with 29 additions and 3 deletions
|
@ -168,3 +168,19 @@ describe("non async function declaration usage of async still works", () => {
|
|||
expect(evalResult).toBeTrue();
|
||||
});
|
||||
});
|
||||
|
||||
describe("await cannot be used in class static init blocks", () => {
|
||||
test("directly", () => {
|
||||
expect("class A{ static { await; } }").not.toEval();
|
||||
expect("class A{ static { let await = 3; } }").not.toEval();
|
||||
expect("class A{ static { call(await); } }").not.toEval();
|
||||
expect("class A{ static { for(const await = 1; false ;) {} } }").not.toEval();
|
||||
});
|
||||
|
||||
test("via declaration", () => {
|
||||
expect("class A{ static { class await {} } }").not.toEval();
|
||||
expect("class A{ static { function await() {} } }").not.toEval();
|
||||
expect("class A{ static { function* await() {} } }").not.toEval();
|
||||
expect("class A{ static { async function* await() {} } }").not.toEval();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue