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

Ouverte
#64,999 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

@roninjin10 y travaille déjà.

Depuis le 28/10/2026.

  • #64993 par @roninjin10 — ouverte

Évaluation

Difficulté
4/5
Temps estimé
1-2 jours
Accessibilité débutants
25/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
À l'abandon
Stack technique
go, typescript
Domaine
compilers

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

🔎 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).

Langage dominant
Go
Étoiles
112k
Forks
15.4k
Merge moyen
2 j 21 h
PR mergées (30 j)
126

Préparer son environnement

Ouvrir dans Codespaces

Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de microsoft/TypeScript

Toutes les issues de microsoft/TypeScript

Issues similaires

Plus d'issues Go

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.