Skip to content

fix(ast): preserve lone surrogates in static property names - #26720

Merged
Dunqing merged 0 commit into
jsstr-linter-import-pathsfrom
jsstr-static-name
Sep 27, 2026
Merged

Dunqing merged 0 commit into
jsstr-linter-import-pathsfrom
jsstr-static-name

Conversation

@Dunqing

@Dunqing Dunqing commented Sep 16, 2026 •

Copy link
Copy Markdown
Member

Continued in #27095. GitHub marked this PR indirectly merged during stack reordering; the change has not landed in main.

A property key can be statically known without being valid Rust UTF-8, but PropertyKey::static_name(), PropertyKey::name(), and ClassElement::static_name() returned UTF-8 text and gave None for a key containing a lone surrogate. Consumers read that None as "dynamic key", so { "\uD800": 1, "\uD800": 2 } raised no duplicate-key diagnostic, duplicate class members and overload signatures went ungrouped, accessor pairs and sorted keys skipped them, the semantic class table lost entries, declaration emit stopped inferring accessor types, and an object-property React component got no display name. ESLint, which sees native JavaScript strings, reports all of these; the duplicate-key case is verified against eslint 9 directly.

The helpers now return StaticPropertyName, which borrows the JSStr of identifier, string, and template keys and owns the UTF-8 conversion of numeric and regular-expression keys. Numeric keys convert with ECMAScript Number::toString, so 1e21 gets the name "1e+21" like the runtime property key. Equal names compare and hash equally across both forms, so { 1: a, "1": b } stays a duplicate. Display is diagnostic-only, a surrogate name is escaped once and in one spelling — Display and Debug both print lowercase \udXXX escapes, matching printed output, and consumers that need a Rust string request the UTF-8 view explicitly, declining only optional fixes when there is none. This is the design from #26630, renamed to StaticPropertyName, re-cut on the migrated AST, so the earlier UTF-8 compatibility adapters are gone and identity consumers compare complete values.

One reviewer note: two existing lint snapshots reorder entries because those rules iterate a hash map whose key type changed; the diagnostics themselves are unchanged. The return type of the three helpers is a Rust API change for downstream callers.

Example

const o = { "\uD800": 1, "\uD800": 2 };

Before: no diagnostic. After:

x eslint(no-dupe-keys): Duplicate key '\ud800'

Verified with lead, trail, and pair cases across the touched rules, a differential test of the sort-keys comparator against the previous implementation on 8,100 UTF-8 pairs, unchanged allocation snapshots, the transform conformance suites, and the full linter suite; an adversarial review pass found no defects.

Seventh PR in the JSStr stack, based on #26717. Part of #26242.

Implemented with AI assistance.

Dunqing commented Sep 16, 2026 •

Copy link
Copy Markdown
Member Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


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 A-linter Area - Linter (oxlint): rules, config, diagnostics, fixes. Add L-* labels for details A-semantic Area - Scopes, symbols, references and semantic errors, oxc_semantic A-ast Area - AST definitions and visitors, oxc_ast / oxc_ast_visit A-transformer Area - JS/TS transforms and downleveling, oxc_transformer A-isolated-declarations Area - TypeScript declaration (.d.ts) generation, oxc_isolated_declarations labels Sep 16, 2026
@codspeed

codspeed Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 87 untouched benchmarks
⏩ 9 skipped benchmarks1


Comparing jsstr-static-name (3a44e86) with jsstr-linter-import-paths (a9039e6)

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. ↩

@Dunqing
Dunqing force-pushed the jsstr-linter-import-paths branch from 1f0f752 to f2e04cc Compare September 16, 2026 07:29
@Dunqing
Dunqing force-pushed the jsstr-static-name branch 2 times, most recently from 8990afd to 24e0693 Compare September 16, 2026 07:49
@Dunqing
Dunqing force-pushed the jsstr-linter-import-paths branch from f2e04cc to 83dd06d Compare September 17, 2026 00:23
@Dunqing
Dunqing changed the base branch from jsstr-linter-import-paths to graphite-base/26720 September 18, 2026 02:19
@Dunqing
Dunqing force-pushed the graphite-base/26720 branch from 83dd06d to d0c59fd Compare September 18, 2026 02:20
@Dunqing
Dunqing changed the base branch from graphite-base/26720 to jsstr-linter-import-paths September 18, 2026 02:20
@Dunqing Dunqing closed this Sep 18, 2026
@Dunqing Dunqing reopened this Sep 18, 2026
@Dunqing
Dunqing changed the base branch from jsstr-linter-import-paths to graphite-base/26720 September 18, 2026 15:14
@Dunqing
Dunqing force-pushed the graphite-base/26720 branch from d0c59fd to 897e1aa Compare September 18, 2026 15:15
@Dunqing
Dunqing changed the base branch from graphite-base/26720 to jsstr-linter-import-paths September 21, 2026 08:23
@Dunqing
Dunqing changed the base branch from jsstr-linter-import-paths to graphite-base/26720 September 22, 2026 02:40
@Dunqing
Dunqing force-pushed the graphite-base/26720 branch from e048e68 to b38ea25 Compare September 22, 2026 02:41
@Dunqing
Dunqing changed the base branch from graphite-base/26720 to jsstr-linter-import-paths September 22, 2026 02:41
@Dunqing
Dunqing changed the base branch from jsstr-linter-import-paths to graphite-base/26720 September 22, 2026 04:12
@Dunqing
Dunqing force-pushed the graphite-base/26720 branch from b38ea25 to 21f6f32 Compare September 22, 2026 04:12
@Dunqing
Dunqing changed the base branch from graphite-base/26720 to jsstr-linter-import-paths September 22, 2026 04:13
@Dunqing
Dunqing changed the base branch from jsstr-linter-import-paths to graphite-base/26720 September 22, 2026 08:19
@Dunqing
Dunqing force-pushed the graphite-base/26720 branch from 21f6f32 to 11c002b Compare September 22, 2026 08:20
@Dunqing
Dunqing changed the base branch from graphite-base/26720 to jsstr-linter-import-paths September 22, 2026 08:20
@Dunqing
Dunqing force-pushed the jsstr-linter-import-paths branch from 11c002b to 7018aa2 Compare September 23, 2026 01:55
@Dunqing
Dunqing changed the base branch from jsstr-linter-import-paths to graphite-base/26720 September 23, 2026 02:18
@Dunqing
Dunqing force-pushed the graphite-base/26720 branch from 7018aa2 to 16cff28 Compare September 23, 2026 02:19
@Dunqing
Dunqing changed the base branch from graphite-base/26720 to jsstr-linter-import-paths September 23, 2026 02:19
@Dunqing
Dunqing changed the base branch from jsstr-linter-import-paths to graphite-base/26720 September 23, 2026 02:23
@Dunqing
Dunqing force-pushed the graphite-base/26720 branch from 16cff28 to 0ead3d8 Compare September 23, 2026 02:24
@Dunqing
Dunqing changed the base branch from graphite-base/26720 to jsstr-linter-import-paths September 23, 2026 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast Area - AST definitions and visitors, oxc_ast / oxc_ast_visit A-isolated-declarations Area - TypeScript declaration (.d.ts) generation, oxc_isolated_declarations A-linter Area - Linter (oxlint): rules, config, diagnostics, fixes. Add L-* labels for details A-semantic Area - Scopes, symbols, references and semantic errors, oxc_semantic A-transformer Area - JS/TS transforms and downleveling, oxc_transformer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant