GeezerVison is showing github.com — JS: Require binding identifier after await using by sam-robson · Pull Request #23040 · github/codeql
Conversation
sam-robson
commented
Nov 6, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Check that await using (and using in for loop initializers) is followed by an identifier on the same line before parsing it as a declaration, so calls like await using(...) parse as expressions.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The new using lookahead mishandles escaped and astral identifiers, valid JavaScript whitespace, and embedded line terminators, causing declarations to be incorrectly accepted or rejected.
3 open issues
What changed in this PR
This PR updates the JavaScript extractor to distinguish resource declarations from expressions such as await using(...) by checking for a following binding identifier on the same line.
Changes:
- Reuses declaration lookahead for
await using and using in loop initializers.
- Adds an awaited-call regression fixture and updates its expected AST.
| File |
Description |
javascript/ql/test/library-tests/AST/ExplicitResource/tst.js |
Adds an await using("foo") expression case. |
javascript/ql/test/library-tests/AST/ExplicitResource/printAst.expected |
Records the expected awaited-call AST. |
javascript/extractor/src/com/semmle/jcorn/Parser.java |
Shares binding lookahead across await and loop declaration checks. |
Review effort: Balanced (auto)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
2635
to
+2636
|
|
Matcher m = Whitespace.skipWhiteSpace.matcher(this.input);
|
|
|
m.find(this.pos);
|
|
|
m.find(pos);
|
|
|
int next = m.end();
|
|
|
return this.input.length() > next &&
|
|
|
!Whitespace.lineBreakG.matcher(inputSubstring(this.pos, next)).matches()
|
|
|
!Whitespace.lineBreakG.matcher(inputSubstring(pos, next)).matches()
|
|
|
return this.input.length() > next &&
|
|
|
!Whitespace.lineBreakG.matcher(inputSubstring(this.pos, next)).matches()
|
|
|
!Whitespace.lineBreakG.matcher(inputSubstring(pos, next)).matches()
|
|
|
&& Identifiers.isIdentifierChar(this.input.codePointAt(next), false);
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
The comments from CCR are technically valid concerns but it's better fixed by refactoring the parsing strategy for await using which is a larger change out of scope for this PR.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
asgerf
asgerf approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.