Skip to content

Commit bc58415

Browse files
Copilothvitved
andauthored
Allow await property names in async functions
Co-authored-by: hvitved <3667920+hvitved@users.noreply.github.com>
1 parent e3ed273 commit bc58415

4 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎javascript/extractor/src/com/semmle/jcorn/Parser.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2296,9 +2296,9 @@ protected Identifier parseIdent(boolean liberal) {
22962296
&& (this.options.ecmaVersion() >= 6
22972297
|| inputSubstring(this.start, this.end).indexOf("\\") == -1))
22982298
this.raiseRecoverable(this.start, "The keyword '" + this.value + "' is reserved");
2299-
if (!isPrivateField && this.inGenerator && this.value.equals("yield"))
2299+
if (!liberal && !isPrivateField && this.inGenerator && this.value.equals("yield"))
23002300
this.raiseRecoverable(this.start, "Can not use 'yield' as identifier inside a generator");
2301-
if (!isPrivateField && this.inAsync && this.value.equals("await"))
2301+
if (!liberal && !isPrivateField && this.inAsync && this.value.equals("await"))
23022302
this.raiseRecoverable(
23032303
this.start, "Can not use 'await' as identifier inside an async function");
23042304
name = String.valueOf(this.value);

‎javascript/ql/test/library-tests/AwaitPropertyName/AwaitPropertyName.expected‎

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import javascript
2+
3+
from Expr e
4+
where e.toString() = "this expression should not exist"
5+
select e
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const pool = { await() { return 42; } };
2+
3+
async function issue22499() {
4+
return await pool.await();
5+
}

0 commit comments

Comments
 (0)