mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-22 10:19:20 +00:00
LibJS: Allow escaped 'async' as identifier
Since 'async' is only special if it occurs before a function it can be used as escaped identifier in all cases.
This commit is contained in:
parent
e751dcea43
commit
c57721cf83
Notes:
sideshowbarker
2024-07-17 23:18:46 +09:00
Author: https://github.com/davidot
Commit: c57721cf83
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 19 additions and 9 deletions
|
@ -9,6 +9,10 @@ describe("parsing freestanding async functions", () => {
|
|||
expect(`async function foo() { await; }`).not.toEval();
|
||||
expect(`function foo() { await bar(); }`).not.toEval();
|
||||
expect(`function foo() { await; }`).toEval();
|
||||
|
||||
expect(`\\u0061sync function foo() { await bar(); }`).not.toEval();
|
||||
expect(`\\u0061sync function foo() { \\u0061wait bar(); }`).not.toEval();
|
||||
expect(`async function foo() { \\u0061wait bar(); }`).not.toEval();
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -82,11 +86,15 @@ describe("async arrow functions", () => {
|
|||
expect("async (b = await) => await b;").not.toEval();
|
||||
expect("async (b = await 3) => await b;").not.toEval();
|
||||
|
||||
// Cannot escape the async keyword.
|
||||
// Cannot escape the async keyword and get an async arrow function.
|
||||
expect("\\u0061sync () => await 3").not.toEval();
|
||||
|
||||
expect("for (async of => {};;) {}").toEval();
|
||||
expect("for (async of => {};false;) {}").toEval();
|
||||
expect("for (async of []) {}").not.toEval();
|
||||
|
||||
expect("for (\\u0061sync of []) {}").toEval();
|
||||
expect("for (\\u0061sync of => {};false;) {}").not.toEval();
|
||||
expect("for (\\u0061sync => {};false;) {}").toEval();
|
||||
});
|
||||
|
||||
test("async within a for-loop", () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue