Skip to content

fix: don't print duplicate parse diagnostics#35933

Merged
bartlomieju merged 1 commit into
mainfrom
fix/repl-duplicate-parse-error
Jul 10, 2026
Merged

fix: don't print duplicate parse diagnostics#35933
bartlomieju merged 1 commit into
mainfrom
fix/repl-duplicate-parse-error

Conversation

@crowlbot

Copy link
Copy Markdown
Contributor

swc can report the exact same fatal parse diagnostic more than once. deno_ast collects every fatal diagnostic into ParseDiagnosticsError, whose Display prints each one, so the identical error was shown twice:

$ deno
> for (console.log("a") of [1]);
error: SyntaxError: The left-hand side of an assignment expression must be a variable or a property access.
  |
1 | for (console.log("a") of [1]);
  |      ~~~~~~~~~~~~~~~~
    at file:///repl.tsx:1:6

SyntaxError: The left-hand side of an assignment expression must be a variable or a property access.
  |
1 | for (console.log("a") of [1]);
  |      ~~~~~~~~~~~~~~~~
    at file:///repl.tsx:1:6

The same duplication happens for deno run main.ts on that source, since both paths surface deno_ast::TranspileError.

This collapses identical diagnostics (ParseDiagnostic compares specifier + range + kind) while preserving order, at the point the transpile error is produced. Distinct diagnostics are still all reported.

Fixes #27804

swc can report the same fatal parse diagnostic more than once (ex.
`for (console.log("a") of [1]);`). deno_ast surfaces every collected
diagnostic, so the identical error was printed twice, both in the repl
and when running a file.

Collapse identical diagnostics before the transpile error is reported.
@crowlbot
crowlbot requested a review from crowlKats July 10, 2026 11:56

@bartlomieju bartlomieju left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good fix

@bartlomieju
bartlomieju merged commit ddebb90 into main Jul 10, 2026
136 checks passed
@bartlomieju
bartlomieju deleted the fix/repl-duplicate-parse-error branch July 10, 2026 19:02
bartlomieju pushed a commit that referenced this pull request Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Repl prints an error twice

2 participants