mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 12:49:19 +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
Notes:
sideshowbarker
2024-07-17 23:18:37 +09:00
Author: https://github.com/davidot
Commit: cbbfcd35e7
Pull-request: https://github.com/SerenityOS/serenity/pull/11088
Issue: https://github.com/SerenityOS/serenity/issues/11078
Reviewed-by: https://github.com/IdanHo
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/linusg ✅
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