Repository navigation
JS: Require binding identifier after await using - #23040
Open
sam-robson wants to merge 1 commit into
Open
sam-robson wants to merge 1 commit into
sam-robson wants to merge 1 commit into
Conversation
sam-robson
force-pushed
the
sam-robson/js-await-using-call
branch
from
November 6, 2026 10:05
681ab26 to
0f912db
Compare
sam-robson
force-pushed
the
sam-robson/js-await-using-call
branch
from
November 6, 2026 10:28
0f912db to
d4eb971
Compare
sam-robson
marked this pull request as ready for review
November 6, 2026 11:53
Contributor
There was a problem hiding this comment.
🟡 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 usingandusingin 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)
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); |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Check that
await using(andusinginforloop initializers) is followed by an identifier on the same line before parsing it as a declaration, so calls likeawait using(...)parse as expressions.