Skip to content

fix(runtime): honor defineProperty prototype index setters (from #9339) - #9392

Merged
proggeramlug merged 2 commits into
mainfrom
fix/9339-defineproperty-index-setters
Sep 1, 2026
Merged

fix(runtime): honor defineProperty prototype index setters (from #9339)#9392
proggeramlug merged 2 commits into
mainfrom
fix/9339-defineproperty-index-setters

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Lands #9339, whose branch conflicts against current main on GitHub's three-way merge (it cherry-picks cleanly). Author's commits preserved.

It was blocked until now for a real reason: it depends on the array_spec_set call-site wiring and prototype_already_checked that the #9326 revert removed. #9370 reapplied that, so this applies cleanly again.

Validation. All lint gates pass. perry-runtime 8 suites green under RUST_TEST_THREADS=1. Both relevant gap fixtures match the pinned Node 26.5.1 oracle byte-for-byte: test_gap_9220_9221_array_proto_paths and test_gap_typedarray_buffer_aliasing_7219 (the latter matters because #9360 regresses it, and this confirms #9339 does not).

I also wrote an independent probe for the behaviour it claims: an index setter installed on a prototype via defineProperty now runs on a[3] = …, the read returns the getter's value, and no own property is created — setter saw: written | read: G | own: false, matching node exactly.

One observation, not a blocker. In that probe I hit a module-goal difference rather than a defect in this PR. A .ts file with no import/export is CommonJS to node --experimental-strip-types (sloppy mode), so a store blocked by a non-writable inherited index fails silently; Perry compiles it as a module, so strict mode throws. Add export {} and both throw, agreeing on semantics and differing only in how node formats the error. Worth a separate look at whether Perry should follow node's module-goal inference for extensionless-import-free files, but it is independent of this change and this PR is what makes the strict-mode throw reachable at all.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed array indexed assignments to honor accessors and non-writable properties defined on Array.prototype or Object.prototype.
    • Corrected behavior for inherited setters, getters, and non-writable properties, including proper TypeError handling.
    • Aligned runtime behavior with standard JavaScript and Node.js results.
  • Tests

    • Added regression coverage for property definitions using defineProperty, defineProperties, and Reflect.defineProperty.

@proggeramlug
proggeramlug merged commit 0e9ba1d into main Sep 1, 2026
15 of 16 checks passed
@proggeramlug
proggeramlug deleted the fix/9339-defineproperty-index-setters branch September 1, 2026 13:07
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 294d99a6-37d3-4645-a82c-ce0fc6da4454

📥 Commits

Reviewing files that changed from the base of the PR and between 757beac and 8c11066.

📒 Files selected for processing (5)
  • changelog.d/9339-array-prototype-define-property-index.md
  • crates/perry-runtime/src/array/indexing.rs
  • crates/perry-runtime/src/array/mod.rs
  • crates/perry-runtime/src/object/array_object_ops.rs
  • crates/perry/tests/issue_9249_array_prototype_define_property.rs

📝 Walkthrough

Walkthrough

The runtime now observes indexed descriptors defined on Array.prototype or Object.prototype during array stores. It records prototype index definitions, enables the inherited [[Set]] walk, and adds regression tests for setters, getters, and non-writable properties.

Changes

Array index descriptor fix

Layer / File(s) Summary
Runtime latch and inherited descriptor walk
crates/perry-runtime/src/array/indexing.rs, crates/perry-runtime/src/array/mod.rs, crates/perry-runtime/src/object/array_object_ops.rs, changelog.d/9339-array-prototype-define-property-index.md
Canonical index definitions raise the array index-write latch. Strict indexed stores use the inherited descriptor walk when Array.prototype or Object.prototype contains indexed properties.
Prototype descriptor regression coverage
crates/perry/tests/issue_9249_array_prototype_define_property.rs
Tests cover indexed setters, inherited getters, and non-writable properties defined through defineProperty, defineProperties, and Reflect.defineProperty.

Estimated code review effort: 3 (Moderate) | ~20 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/9339-defineproperty-index-setters

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant