Skip to content

fix(parser): reject module export names containing a lone surrogate - #26953

Merged
graphite-app[bot] merged 1 commit into
mainfrom
parser-fatal-export-name
Sep 23, 2026
Merged

graphite-app[bot] merged 1 commit into
mainfrom
parser-fatal-export-name

Conversation

@Dunqing

@Dunqing Dunqing commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

A module export name that is not well-formed Unicode is an early error (ModuleExportName : StringLiteral is a Syntax Error if IsStringWellFormedUnicode of its value is false), and the parser reported it, but it still built the node and returned the recovered AST. Every consumer of ModuleExportName::name therefore had to tolerate an export name that cannot exist in a valid module. Acorn rejects the input outright, and Babel does the same unless error recovery is enabled.

Make the error fatal, so no AST carries an ill-formed export name. Consumers can treat the name as well-formed by construction. This is preparation for the JSStr stack (#26242), where ModuleExportName::name keeps returning UTF-8 text and currently needs a fallback for exactly this case; with this change the fallback becomes dead and is removed there.

Example

export { x as "\uD800" };

Before, the error was reported and parsing continued with a recovered AST. After, the same diagnostic is reported and parsing stops:

x An export name cannot include a unicode lone surrogate

The test262 negative test early-export-ill-formed-string.js still fails to parse; it now reports only its first error instead of three, and a duplicate-export diagnostic that printed the surrogate as marker text disappears with it. Verified with four new misc fixtures covering the export, re-export, namespace re-export, and import forms, the parser, semantic, codegen, and lexer conformance runs, and the parser, semantic, and linter test suites.

Implemented with AI assistance.

Dunqing commented Sep 23, 2026

Copy link
Copy Markdown
Member Author

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions Bot added the A-parser Area - JS/TS parsing and syntax errors, oxc_parser label Sep 23, 2026
@codspeed

codspeed Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 87 untouched benchmarks
⏩ 9 skipped benchmarks1


Comparing parser-fatal-export-name (e25a1d5) with main (591966d)2

Open in CodSpeed

Footnotes

  1. 9 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 (d77d5bf) during the generation of this report, so 591966d was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@Dunqing
Dunqing marked this pull request as ready for review September 23, 2026 01:57
@Dunqing
Dunqing requested a review from Boshen September 23, 2026 01:57
@Dunqing Dunqing added the 0-merge Merge with Graphite Merge Queue label Sep 23, 2026

Dunqing commented Sep 23, 2026 •

Copy link
Copy Markdown
Member Author

Merge activity

…26953)

A module export name that is not well-formed Unicode is an [early error](https://tc39.es/ecma262/#sec-module-semantics-static-semantics-early-errors) (`ModuleExportName : StringLiteral` is a Syntax Error if `IsStringWellFormedUnicode` of its value is false), and the parser reported it, but it still built the node and returned the recovered AST. Every consumer of `ModuleExportName::name` therefore had to tolerate an export name that cannot exist in a valid module. Acorn rejects the input outright, and Babel does the same unless error recovery is enabled.

Make the error fatal, so no AST carries an ill-formed export name. Consumers can treat the name as well-formed by construction. This is preparation for the JSStr stack (#26242), where `ModuleExportName::name` keeps returning UTF-8 text and currently needs a fallback for exactly this case; with this change the fallback becomes dead and is removed there.

## Example

```js
export { x as "\uD800" };
```

Before, the error was reported and parsing continued with a recovered AST. After, the same diagnostic is reported and parsing stops:

```
x An export name cannot include a unicode lone surrogate
```

The test262 negative test `early-export-ill-formed-string.js` still fails to parse; it now reports only its first error instead of three, and a duplicate-export diagnostic that printed the surrogate as marker text disappears with it. Verified with four new misc fixtures covering the export, re-export, namespace re-export, and import forms, the parser, semantic, codegen, and lexer conformance runs, and the parser, semantic, and linter test suites.

Implemented with AI assistance.
@graphite-app
graphite-app Bot force-pushed the parser-fatal-export-name branch from e25a1d5 to 01ff33e Compare September 23, 2026 02:11
@graphite-app
graphite-app Bot merged commit 01ff33e into main Sep 23, 2026
33 checks passed
@graphite-app graphite-app Bot removed the 0-merge Merge with Graphite Merge Queue label Sep 23, 2026
@graphite-app
graphite-app Bot deleted the parser-fatal-export-name branch September 23, 2026 02:14
camc314 added a commit to camc314/rolldown that referenced this pull request Sep 23, 2026
oxc-project/oxc#26953

Oxc now treats module export names containing a Unicode lone surrogate as a fatal parse error. Parsing stops after the first diagnostic instead of returning a recovered AST that triggers additional semantic errors.

The test262 module-code snapshot removes two repeated lone-surrogate diagnostics and the downstream duplicate-export diagnostic for early-export-ill-formed-string.js. The remaining single parse error is the expected ECMAScript early error.

First-Bad-Oxc-Commit: 01ff33e9c834a04eda027a9f5716a3dbf0f389b9

Oxc-Revision: 01ff33e9c834a04eda027a9f5716a3dbf0f389b9
camc314 added a commit to camc314/rolldown that referenced this pull request Sep 24, 2026
oxc-project/oxc#26953

Oxc now treats module export names containing a Unicode lone surrogate as a fatal parse error. Parsing stops after the first diagnostic instead of returning a recovered AST that triggers additional semantic errors.

The test262 module-code snapshot removes two repeated lone-surrogate diagnostics and the downstream duplicate-export diagnostic for early-export-ill-formed-string.js. The remaining single parse error is the expected ECMAScript early error.

First-Bad-Oxc-Commit: 01ff33e9c834a04eda027a9f5716a3dbf0f389b9

Oxc-Revision: 01ff33e9c834a04eda027a9f5716a3dbf0f389b9
camc314 added a commit to camc314/rolldown that referenced this pull request Sep 24, 2026
oxc-project/oxc#26953

Oxc now treats module export names containing a Unicode lone surrogate as a fatal parse error. Parsing stops after the first diagnostic instead of returning a recovered AST that triggers additional semantic errors.

The test262 module-code snapshot removes two repeated lone-surrogate diagnostics and the downstream duplicate-export diagnostic for early-export-ill-formed-string.js. The remaining single parse error is the expected ECMAScript early error.

First-Bad-Oxc-Commit: 01ff33e9c834a04eda027a9f5716a3dbf0f389b9

Oxc-Revision: 01ff33e9c834a04eda027a9f5716a3dbf0f389b9
camc314 added a commit to camc314/rolldown that referenced this pull request Sep 25, 2026
oxc-project/oxc#26953

Oxc now treats module export names containing a Unicode lone surrogate as a fatal parse error. Parsing stops after the first diagnostic instead of returning a recovered AST that triggers additional semantic errors.

The test262 module-code snapshot removes two repeated lone-surrogate diagnostics and the downstream duplicate-export diagnostic for early-export-ill-formed-string.js. The remaining single parse error is the expected ECMAScript early error.

First-Bad-Oxc-Commit: 01ff33e9c834a04eda027a9f5716a3dbf0f389b9

Oxc-Revision: 01ff33e9c834a04eda027a9f5716a3dbf0f389b9
camc314 added a commit to camc314/rolldown that referenced this pull request Sep 27, 2026
oxc-project/oxc#26953

Oxc now treats module export names containing a Unicode lone surrogate as a fatal parse error. Parsing stops after the first diagnostic instead of returning a recovered AST that triggers additional semantic errors.

The test262 module-code snapshot removes two repeated lone-surrogate diagnostics and the downstream duplicate-export diagnostic for early-export-ill-formed-string.js. The remaining single parse error is the expected ECMAScript early error.

First-Bad-Oxc-Commit: 01ff33e9c834a04eda027a9f5716a3dbf0f389b9

Oxc-Revision: 01ff33e9c834a04eda027a9f5716a3dbf0f389b9
camc314 added a commit to camc314/rolldown that referenced this pull request Sep 28, 2026
oxc-project/oxc#26953

Oxc now treats module export names containing a Unicode lone surrogate as a fatal parse error. Parsing stops after the first diagnostic instead of returning a recovered AST that triggers additional semantic errors.

The test262 module-code snapshot removes two repeated lone-surrogate diagnostics and the downstream duplicate-export diagnostic for early-export-ill-formed-string.js. The remaining single parse error is the expected ECMAScript early error.

First-Bad-Oxc-Commit: 01ff33e9c834a04eda027a9f5716a3dbf0f389b9

Oxc-Revision: 01ff33e9c834a04eda027a9f5716a3dbf0f389b9
camc314 added a commit to camc314/rolldown that referenced this pull request Sep 28, 2026
oxc-project/oxc#26953

Oxc now treats module export names containing a Unicode lone surrogate as a fatal parse error. Parsing stops after the first diagnostic instead of returning a recovered AST that triggers additional semantic errors.

The test262 module-code snapshot removes two repeated lone-surrogate diagnostics and the downstream duplicate-export diagnostic for early-export-ill-formed-string.js. The remaining single parse error is the expected ECMAScript early error.

First-Bad-Oxc-Commit: 01ff33e9c834a04eda027a9f5716a3dbf0f389b9

Oxc-Revision: 01ff33e9c834a04eda027a9f5716a3dbf0f389b9
graphite-app Bot pushed a commit that referenced this pull request Sep 28, 2026
### 🚀 Features

- 02331c8 str: Add `JSStr`, `JSChar` and `JSStrBuilder` types (#26435) (Dunqing)
- 52ae63f regular_expression: Support buffer boundary assertions (#27048) (Boshen)
- 3255b89 transform-react: Add `reportDiagnostics` option to expose recoverable React Compiler diagnostics (#26624) (Jack)
- f585cb4 napi: Add threadless WASI builds (#26898) (Boshen)

### 🐛 Bug Fixes

- c380c85 minifier: Preserve iife with directives (#27060) (Armano)
- c55b35d str: Correct clippy reason (#27013) (overlookmotel)
- 8fbddb1 formatter/jsdoc: More alignment with original plugin (#27039) (leaysgur)
- 5186328 parser: Handle HTML comment values (#22933) (Boshen)
- 01ff33e parser: Reject module export names containing a lone surrogate (#26953) (Dunqing)
- d79ad19 codegen: Remove redundant dollar escapes in minified templates (#26924) (camc314)

### ⚡ Performance

- 0afbf85 minifier: Fold logical expressions in place (#26768) (Armano)
- 3471f29 minifier: Avoid creation of empty block when folding try finally (#26971) (Armano)
- 3893d64 minifier: Update boolean context expressions in place (#26823) (Armano)
- de8af47 minifier: Take return argument directly when converting arrow fn (#26830) (Armano)
- fc37ba0 minifier: Reduce allocations when minimizing assignments (#26609) (Armano)
- dce64f6 minifier: Use ident hashes for catch var and arguments (#26907) (Armano)
- 57610b3 minifier: Use ident hashes in label comparison (#26887) (Armano)

### 📚 Documentation

- dfa6cf9 str: Reformat and simplify comments (#27011) (overlookmotel)
- d775315 parser: Document AST property order (#27038) (Boshen)
- cd80e3f ast: Correct `JSXExpressionContainer` example (#26975) (camc314)
- 8cb05e3 ast: Simplify `JSXAttribute` value description (#26974) (camc314)
- fda7fbb ast: Correct `TSNumberKeyword` example (#26973) (camc314)
- e63c439 ast: Clarify `RegExpFlags::V` flag features (#26972) (camc314)
- 278288e ast: Correct `JSXText` example (#26970) (camc314)
- e9ff529 ast: Correct `TSIntrinsicKeyword` example (#26967) (camc314)
- c643ce4 ast: Fix `TSTupleType` example syntax (#26966) (camc314)
- 895b1a7 ast: Correct `TSPropertySignature` usage example (#26964) (camc314)
- 8d8cc7c ast: Correct `Class` abstract example values (#26963) (camc314)
- f7ef2e2 ast: Use valid variance example for `TSTypeParameter` (#26962) (camc314)
- 145fcdb ast: Attach `pure` comment to `NewExpression` field (#26961) (camc314)
- 06dfd9f ast: Clarify `TSNonNullExpression` docs (#26960) (camc314)
- d5f92b5 ast: Add docs for TSNonNullExpression (#26910) (camchenry)
- 4a76723 ast: Add docs for TSNamespaceExportDeclaration (#26909) (camchenry)
- de41927 ast: Add docs for `TSInstantiationExpression` (#26908) (camchenry)
camc314 added a commit to camc314/rolldown that referenced this pull request Sep 28, 2026
oxc-project/oxc#26953

Oxc now treats module export names containing a Unicode lone surrogate as a fatal parse error. Parsing stops after the first diagnostic instead of returning a recovered AST that triggers additional semantic errors.

The test262 module-code snapshot removes two repeated lone-surrogate diagnostics and the downstream duplicate-export diagnostic for early-export-ill-formed-string.js. The remaining single parse error is the expected ECMAScript early error.

First-Bad-Oxc-Commit: 01ff33e9c834a04eda027a9f5716a3dbf0f389b9

Oxc-Revision: 01ff33e9c834a04eda027a9f5716a3dbf0f389b9
camc314 added a commit to camc314/rolldown that referenced this pull request Sep 29, 2026
oxc-project/oxc#26953

Oxc now treats module export names containing a Unicode lone surrogate as a fatal parse error. Parsing stops after the first diagnostic instead of returning a recovered AST that triggers additional semantic errors.

The test262 module-code snapshot removes two repeated lone-surrogate diagnostics and the downstream duplicate-export diagnostic for early-export-ill-formed-string.js. The remaining single parse error is the expected ECMAScript early error.

First-Bad-Oxc-Commit: 01ff33e9c834a04eda027a9f5716a3dbf0f389b9

Oxc-Revision: 01ff33e9c834a04eda027a9f5716a3dbf0f389b9
shulaoda pushed a commit to rolldown/rolldown that referenced this pull request Sep 30, 2026
## Summary

- Upgrade Oxc Rust dependencies to the published 0.152.0 crates.
- Upgrade `@oxc-project/runtime`, `@oxc-project/types`, `oxc-parser`,
and `oxc-transform` JavaScript packages to 0.152.0.

## Root causes

### oxc-project/oxc#26953

oxc-project/oxc#26953

Oxc now treats a lone surrogate in a module export name as a fatal parse
error. Rolldown's test262 module-code snapshot accordingly retains the
one expected early error and removes two duplicate parse diagnostics
plus a downstream duplicate-export diagnostic that depended on recovery
after the fatal error.

Commit: 01ff33e9c834a04eda027a9f5716a3dbf0f389b9

### oxc-project/oxc#22933

oxc-project/oxc#22933

Oxc distinguishes HTML opening and closing comments in `CommentKind`.
Rolldown handles the new variants as line comments when generating
sourcemap references, preserving the existing `//` reference form. No
snapshot changes were needed.

Commit: 51863287632df2ab85cafc16c9d66015c5d5a754

### oxc-project/oxc#27078

oxc-project/oxc#27078

Oxc moved to `oxc_sourcemap` 9, so Rolldown must use the same version to
avoid incompatible `SourceMap` types. Source maps now serialize the
standard `ignoreList` field; Rolldown still accepts legacy
`x_google_ignoreList` input and preserves the plugin/MagicString
compatibility surface. The native and WASI binding declarations were
regenerated for v9's NAPI sourcemap type and field changes. The
allocation snapshot did not change.

Commit: efc646a59041b183bb8b13c728bc824f07f33b85

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

Labels

A-parser Area - JS/TS parsing and syntax errors, oxc_parser

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants