Skip to content

fix(parser): avoid duplicate export in top-level await reparse#22520

Closed
eyupcanakman wants to merge 1 commit into
oxc-project:mainfrom
eyupcanakman:worktree-oxc-22158-dup-export-await
Closed

fix(parser): avoid duplicate export in top-level await reparse#22520
eyupcanakman wants to merge 1 commit into
oxc-project:mainfrom
eyupcanakman:worktree-oxc-22158-dup-export-await

Conversation

@eyupcanakman

Copy link
Copy Markdown
Contributor

Fixes #22158.

In unambiguous mode, export var x = await + 1; reports a false Duplicated export 'x' diagnostic. The parser sees top-level await, queues a reparse, then re-walks the export statement and registers x a second time on the module record.

ModuleRecordBuilder now has a suppressed flag that returns early from every visit_* method, and reparse_potential_top_level_awaits sets the flag around its loop so pass 2 updates the AST without re-recording entries the first parse already captured.

AI assisted.

@codspeed-hq

codspeed-hq Bot commented May 18, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 48 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing eyupcanakman:worktree-oxc-22158-dup-export-await (50e3adb) with main (e431a0e)2

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (f6114d3) during the generation of this report, so e431a0e was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@camc314 camc314 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This adds a lot of overhead to the hot path.

iirc, we can use std::mem::replace after the first reparse to just replace the module record

@eyupcanakman

Copy link
Copy Markdown
Contributor Author

happy for #22524 to land

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parser: false "Duplicated export" when await appears in variable initializer under .js auto-detect

3 participants