ReviewOS

zig-utils/zig-js

NamedEvaluation: canonicalize computed property display names

#687
Closed chris opened this 9 days ago ·
9 days ago

Parent: #473

Problem

Computed object/class property names are correctly coerced once with ToPropertyKey and stored canonically. NamedEvaluation and SetFunctionName then derive a display name from that already-coerced primitive through keyDisplayName. For a string primitive, keyDisplayName currently returns raw physical asStr bytes, so inferred function/method/accessor/field names can depend on flat Latin-1 storage.

Scope

  • Read string display-name primitives through the representation-aware WTF-8 boundary.
  • Route non-string display-name ToString through the canonical boundary as well.
  • Preserve single ToPropertyKey coercion, Symbol description formatting, accessor prefixes, class element evaluation order, and storage-key identity.
  • Cover computed object data properties/accessors and computed class methods/fields with one exact-coercion witness under canonical and forced-flat storage.

This issue does not touch promises, jobs, queues, workers/threads, or Map/Set iterators.

Acceptance

  • Latin-1 computed names round-trip exactly in Function.name for object/class methods, accessors, and anonymous field/data-property initializers.
  • An object-valued computed key is coerced once per syntactic occurrence.
  • Focused Debug, ReleaseSafe, and TSan tests pass, including forced-flat storage.
  • Full sharded units report zero failures and zero leaks.
  • Test262 language/expressions/object (1170 files) and language/statements/class/elements (1534 files) are measured before and after with exact flips.
9 days ago

Implemented and pushed in https://github.com/zig-utils/zig-js/commit/d02a791ed2bde3fb38ded04d079574cd27e1e1ac.

Computed property display names now read an already-coerced string primitive through representation-aware WTF-8. Storage-key identity and single ToPropertyKey coercion are unchanged; inferred object/class method, accessor, and anonymous field/data-property names now survive flat Latin-1 storage exactly.

Validation: focused Debug, forced-flat storage, ReleaseSafe, and TSan 1/1 each; full units 1780 passed, 1 skipped, 0 failed, 0 leaked. Test262 stayed object expressions 1170/1170 and class elements 1534/1534; flips 0.

9 days ago

Follow-up #695 is complete in ef485bab: the remaining non-computed Function metadata consumers now canonicalize bound target names and native toString names. This complements computed SetFunctionName without changing its single-coercion behavior.

Sign in to comment on this issue.