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

Abierto
#64,999 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@roninjin10 ya está trabajando en esto.

Desde el 28/10/2026.

  • #64993 de @roninjin10 — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
1-2 días
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
go, typescript
Área
compilers

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
Go
Estrellas
112k
Forks
15.4k
Merge medio
3 d 6 h
PR fusionados (30 d)
136

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microsoft/TypeScript

Todos los issues de microsoft/TypeScript

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.