Repository navigation
fix(runtime): #5893 — class setter .length ignores default params - #5939
Conversation
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.
|
Warning Review limit reached
Next review available in: 7 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
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'slength. Butclass_accessor_function_value(the helper that mints the callable value returned byObject.getOwnPropertyDescriptor(C.prototype, 'm').set) hardcoded the setter length to1, ignoring defaults. Sodescriptor.set.lengthcame back1instead of0.Fix
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 existingjs_register_closure_length.registration.rs):class_accessor_function_valuenow consultslookup_closure_length(raw_setter_ptr)and uses it for the reflected value's.length, falling back to the fixed1/0when no registration exists (native / cross-module accessors whose length wasn't emitted).A plain
set m(x)still reports1; getters keep0.Before / after (slice
language/statements/class language/expressions/class, jobs=6)language/expressions/class/setter-length-dflt.js,language/statements/class/setter-length-dflt.js.fn-length-static-precedence*, which readC.length/property names, not the accessor value's length — both still pass).