Skip to content

Allow JavaScript property named await in async functions - #22500

Open
hvitved with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-codeql-parse-error-await
Open

Allow JavaScript property named await in async functions#22500
hvitved with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-codeql-parse-error-await

Conversation

Copilot AI commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

CodeQL reported a JavaScript parse error for valid property access expressions named await inside async functions. This affected code such as:

const results = await pool.await();
  • Parser

    • Keep contextual await/yield identifier restrictions for ordinary identifiers.
    • Allow liberal identifier parsing to accept reserved/contextual words when used as property names.
  • Regression coverage

    • Add a focused QL extraction test for .await property access inside an async function.

DCA verifies that this change resolves somes spurious syntax errors.

Co-authored-by: hvitved <3667920+hvitved@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix CodeQL parse error for property named 'await' in JavaScript Allow JavaScript property named await in async functions Sep 3, 2026
Copilot AI requested a review from hvitved September 3, 2026 12:58
@github-actions github-actions Bot added the JS label Sep 3, 2026
@hvitved
hvitved marked this pull request as ready for review September 3, 2026 18:58
@hvitved
hvitved requested review from a team as code owners September 3, 2026 18:58
@hvitved
hvitved requested review from asgerf and a balanced review from Copilot September 3, 2026 18:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The regression query cannot detect tolerated parse errors, and the changed yield behavior is untested.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Updates JavaScript parsing to allow contextual keywords as property names inside async/generator functions.

Changes:

  • Restricts await/yield errors to non-liberal identifier parsing.
  • Adds regression coverage for .await property access.
File summaries
File Description
javascript/extractor/src/com/semmle/jcorn/Parser.java Adjusts contextual identifier validation.
javascript/ql/test/library-tests/AwaitPropertyName/tst.js Adds the .await fixture.
javascript/ql/test/library-tests/AwaitPropertyName/AwaitPropertyName.ql Runs the regression query.
javascript/ql/test/library-tests/AwaitPropertyName/AwaitPropertyName.expected Defines empty expected output.
Review details
  • Files reviewed: 3/4 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +3 to +5
from Expr e
where e.toString() = "this expression should not exist"
select e
|| inputSubstring(this.start, this.end).indexOf("\\") == -1))
this.raiseRecoverable(this.start, "The keyword '" + this.value + "' is reserved");
if (!isPrivateField && this.inGenerator && this.value.equals("yield"))
if (!liberal && !isPrivateField && this.inGenerator && this.value.equals("yield"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CodeQL confused by property named "await" in JavaScript code

3 participants