Repository navigation
fix(ast): preserve lone surrogates in static property names - #26720
Conversation
|
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.
How to use the Graphite Merge QueueAdd either label to this PR to merge it via 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. |
Merging this PR will not alter performance
Comparing Footnotes
|
1f0f752 to
f2e04cc
Compare
8990afd to
24e0693
Compare
f2e04cc to
83dd06d
Compare
24e0693 to
ddb6e5d
Compare
83dd06d to
d0c59fd
Compare
ddb6e5d to
477a2fe
Compare
d0c59fd to
897e1aa
Compare
8ee9397 to
ad22109
Compare
ad22109 to
bb9dba1
Compare
e048e68 to
b38ea25
Compare
b38ea25 to
21f6f32
Compare
bb9dba1 to
d3d0fc1
Compare
d3d0fc1 to
7bfa79b
Compare
21f6f32 to
11c002b
Compare
7bfa79b to
aca9177
Compare
11c002b to
7018aa2
Compare
aca9177 to
a04e297
Compare
7018aa2 to
16cff28
Compare
16cff28 to
0ead3d8
Compare
a04e297 to
16f50d0
Compare

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(), andClassElement::static_name()returned UTF-8 text and gaveNonefor a key containing a lone surrogate. Consumers read thatNoneas "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 theJSStrof identifier, string, and template keys and owns the UTF-8 conversion of numeric and regular-expression keys. Numeric keys convert with ECMAScriptNumber::toString, so1e21gets 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\udXXXescapes, 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 toStaticPropertyName, 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
Before: no diagnostic. After:
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.