Skip to content

[codex] Implement computed property names#3694

Draft
andrewtdiz wants to merge 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/computed-property-names
Draft

[codex] Implement computed property names#3694
andrewtdiz wants to merge 1 commit into
PerryTS:mainfrom
andrewtdiz:codex/computed-property-names

Conversation

@andrewtdiz
Copy link
Copy Markdown
Contributor

Summary

Closes #3581.
Closes #3557.
Closes #3558.
Closes #3559.
Closes #3560.
Closes #3561.

Implements computed property names end to end across object literals, class methods/accessors, and object-literal super dispatch.

Root Cause

Computed keys were lowered through several special-case paths that did not consistently perform ECMAScript ToPropertyKey conversion. That lost symbols, stringified numeric/object keys inconsistently, and evaluated class/object members outside source order. Computed class methods were also sometimes treated like per-instance fields, so duplicate overwrite semantics and static/class symbol dispatch diverged from JavaScript.

What Changed

  • Added runtime/codegen property-key helpers so computed keys preserve symbols and stringify non-symbol values through one ToPropertyKey path.
  • Reworked complex object literal lowering into a source-ordered sequence that handles computed keys, spreads, accessors, methods, this, and object-literal super.
  • Added HIR and runtime registration for computed class methods/accessors, including static members, generators, accessors, string/numeric keys, and symbol side tables.
  • Preserved duplicate member overwrite order by routing later non-computed members through the same runtime registration path when needed.
  • Added object-literal super helpers that resolve through the current home-object prototype, including after Object.setPrototypeOf.
  • Exposed native Error subclass .constructor values so Test262 assert.throws(TypeError, ...) can verify the new static computed "prototype" TypeError cases.

Validation

  • cargo test -p perry-runtime property_key
  • cargo test -p perry-hir -p perry-codegen -p perry-runtime -- --test-threads=1
  • cargo build --release -p perry -p perry-runtime -p perry-stdlib
  • Compiled and ran:
    • test-files/test_issue_3557_computed_class_methods.ts
    • test-files/test_issue_3558_computed_accessors.ts
    • test-files/test_issue_3559_computed_key_side_effect_order.ts
    • test-files/test_issue_3560_object_super_computed_members.ts
    • test-files/test_issue_3561_object_literal_computed_keys.ts
  • Test262 pinned checkout 4249661388e5d3f92a85186213da140a6481490f:
    • scripts/test262_subset.py --root vendor/test262 --dir language/computed-property-names --sample-cap 99999 --report /tmp/perry-test262-computed-final2.json
    • Result: pass=48 diff=0 runtime-fail=0 compile-fail=0 skip=0 parity=100%

Notes

The existing untracked DeepWiki reference at reference/ was left unstaged.

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