Repository navigation
Drop statements a top-level await reparse consumed to the end of the file - #64993
Draft
Will Cory (roninjin10) wants to merge 1 commit into
Draft
Will Cory (roninjin10) wants to merge 1 commit into
Will Cory (roninjin10) wants to merge 1 commit into
Conversation
…file
When a module's statements that may contain `await` are reparsed in an
await context, a reparsed statement can read past the span it started in.
If the reparse reached the end of the file, reparseTopLevelAwait still
copied the original statements after the last span it had advanced to, so
the source file kept statements overlapping the reparsed one: in
`export {}; await + f(const 0 await !x`, `x` was both inside the reparsed
call and a statement of its own.
Once the reparse reaches the end of the file, no original statement is left
to copy or reparse.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
|
@microsoft-github-policy-service agree company="Tevm Inc" |
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.
Fixes #64999
Problem. In a module,
reparseTopLevelAwaitreparses the statements that may containawaitin an await context, and a reparsed statement can read past its span. When the reparse reached the end of the file, the function still copied the original statements after the last span it had advanced to. Forthe source file keeps an
ExpressionStatementforxat [36, 37) beside the reparsed statement at [10, 37), which already containsx. TypeScript 6.0.3's JavaScript parser also produces overlapping statements on this input, so this is not a port regression.Change. Once the reparse reaches the end of the file, no original statement is left to copy or reparse, so
reparseTopLevelAwaitstops there.Tests.
TestReparseTopLevelAwaitThroughEndOfFilefails without the change (statement 2 [36, 37) overlaps statement 1 [10, 37)) and passes with it.go test ./internal/parser/passes, and so do the 440TestLocalsubtests of the compiler and conformance tests whose names containawait.npx hereby validate --allhas not been run.Found by fuzzing the parser with a sibling-order invariant (each node starts at or after the end of its previous sibling) in a fork of this repository.
This patch was written by Claude Code (Claude Opus 5.5), disclosed as CONTRIBUTING.md asks.
🤖 Generated with Claude Code