Top-level await reparse keeps statements it already consumed when it reaches the end of the file

オープン
#64,999 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@roninjin10 がすでに取り組んでいます。

2026年10月28日 から。

  • #64993 @roninjin10 による — オープン

評価

難易度
4/5
見積もり時間
1〜2日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
go, typescript
領域
compilers

調査の方向性

Start with the Go parser’s reparseTopLevelAwait path and inspect how it copies original statements after reparsing advances to the end of the file. Reproduce the overlapping statement positions with the provided input and check the regression test in linked pull request #64993; done means no copied statement starts before the end of its preceding statement.

索引モデルが issue の本文から書いたものです。

説明

🔎 Search Terms

top-level await, reparse, reparseTopLevelAwait, overlapping statements, parse tree, sibling

🕗 Version & Regression Information
  • TypeScript 7 at main 4a4b24d5dc96d148641ec6a39c4f5bbf023cbb2f (the Go parser).
  • TypeScript 6.0.3 also keeps overlapping statements for this input: its ExpressionStatement [26, 28) starts before the statement before it ends at 37.
⏯ Playground Link

Not applicable: the problem is in the parse tree's node positions.

💻 Code
export {}; await + f(const 0 await !x
🙁 Actual behavior

The source file's statements are ExportDeclaration [0, 10), ExpressionStatement [10, 37) and ExpressionStatement [36, 37). The last one starts before the previous one ends: x is parsed twice, once inside the reparsed await + f(...) statement and once as a statement of its own.

In a module, reparseTopLevelAwait reparses the statements that may contain await in an await context, and a reparsed statement can read past its span. When the reparse reaches the end of the file, the original statements after the last span it advanced to are still copied into the new statement list.

🙂 Expected behavior

No statement starts before the end of the statement before it: once the reparse reaches the end of the file, no original statement is left to copy.

Additional information about the issue

Found by fuzzing the parser of a fork of this repository with a sibling-order invariant (each node starts at or after the end of its previous sibling). A fix with a regression test is in #64993.

This report was drafted with Claude Code (Claude Opus 5.5).

主要言語
Go
スター
112k
フォーク
16k
平均マージ
3日 6時間
マージ済み PR(30日)
136

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/TypeScript のほかの issue

microsoft/TypeScript の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。