Skip to content

fix(runtime): #5893 — class setter .length ignores default params - #5939

Merged
proggeramlug merged 1 commit into
mainfrom
fix/t262-5893-setter-length-dflt
Jul 4, 2026
Merged

proggeramlug merged 1 commit into
mainfrom
fix/t262-5893-setter-length-dflt

Conversation

@proggeramlug

Copy link
Copy Markdown
Contributor

Part of #5893 (test262 language/class tail).

Root cause

A class setter with a defaulted formal param (set m(x = 42)) must report .length === 0 — default parameters do not count toward a function's length. But class_accessor_function_value (the helper that mints the callable value returned by Object.getOwnPropertyDescriptor(C.prototype, 'm').set) hardcoded the setter length to 1, ignoring defaults. So descriptor.set.length came back 1 instead of 0.

Fix

  • Codegen (string_pool.rs): register each setter's default-aware spec length (spec_function_length — leading formal params before the first default/rest) against its accessor func_ptr via the existing js_register_closure_length.
  • Runtime (registration.rs): class_accessor_function_value now consults lookup_closure_length(raw_setter_ptr) and uses it for the reflected value's .length, falling back to the fixed 1/0 when no registration exists (native / cross-module accessors whose length wasn't emitted).

A plain set m(x) still reports 1; getters keep 0.

Before / after (slice language/statements/class language/expressions/class, jobs=6)

  • Fixes: language/expressions/class/setter-length-dflt.js, language/statements/class/setter-length-dflt.js.
  • Slice failures 175 → 173 (−2), zero regressions (the other 173 failures are the same pre-existing set from the issue baseline; the only accessor-length-reading tests in the slice are the 2 fixed cases plus fn-length-static-precedence*, which read C.length/property names, not the accessor value's length — both still pass).

A setter with a defaulted formal param (`set m(x = 42)`) must report
`.length === 0` (defaults do not count toward a function's length), but
`class_accessor_function_value` hardcoded the reflected setter value's
length to 1, ignoring defaults. Reading
`Object.getOwnPropertyDescriptor(C.prototype, 'm').set.length` therefore
returned 1 instead of 0.

Fix: codegen now registers each setter's default-aware spec length
(`spec_function_length`) against its accessor func_ptr via
`js_register_closure_length`, and `class_accessor_function_value`
consults `lookup_closure_length` for the raw setter pointer, falling back
to the fixed 1/0 when no registration exists (native / cross-module
accessors). A plain `set m(x)` still reports 1; getters stay at 0.

Fixes test262 language/{statements,expressions}/class/setter-length-dflt.
@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@proggeramlug, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 7 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1de56f35-4c5c-40d6-9da4-b4bcdc2771c7

📥 Commits

Reviewing files that changed from the base of the PR and between a5d705b and 3a1df72.

📒 Files selected for processing (2)
  • crates/perry-codegen/src/codegen/string_pool.rs
  • crates/perry-runtime/src/object/class_registry/registration.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/t262-5893-setter-length-dflt

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.

@proggeramlug
proggeramlug merged commit 3d4815c into main Jul 4, 2026
16 of 17 checks passed
@proggeramlug
proggeramlug deleted the fix/t262-5893-setter-length-dflt branch July 4, 2026 08:18
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