fix(console): preserve native callable arity - #6817
Conversation
📝 WalkthroughWalkthroughRuntime closure ChangesNative callable length parity
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
crates/perry-runtime/src/value/dynamic_object.rs (1)
142-160: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy liftKeep optimized
.lengthlookup aligned with own-property overrides.
closure_get_dynamic_propchecks the closure property table and deleted keys before applying metadata, butjs_value_length_f64applies native/builtin arity unconditionally. Iflengthis redefined or deleted, generic and optimized reads can disagree. Apply the same override/deletion contract here, and add regression coverage for both cases.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/perry-runtime/src/value/dynamic_object.rs` around lines 142 - 160, Update js_value_length_f64 to consult the closure property table and deleted-key state for “length” before applying native or builtin metadata, matching closure_get_dynamic_prop; honor redefined values and deleted properties so optimized reads match generic reads. Add regression coverage for both an own length override and a deleted length property.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@crates/perry-runtime/src/value/dynamic_object.rs`:
- Around line 142-160: Update js_value_length_f64 to consult the closure
property table and deleted-key state for “length” before applying native or
builtin metadata, matching closure_get_dynamic_prop; honor redefined values and
deleted properties so optimized reads match generic reads. Add regression
coverage for both an own length override and a deleted length property.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: c3554517-be60-46fa-8793-c934de461d66
📒 Files selected for processing (3)
changelog.d/6788-named-callable-length.mdcrates/perry-runtime/src/closure/dynamic_props.rscrates/perry-runtime/src/value/dynamic_object.rs
Summary
.lengthreflectionConsole.lengththrough the native-module lookup and IC miss pathsValidation
cargo test -p perry-runtime named_native_callable_length_paths_use_declared_arity./run_parity_tests.sh --suite node-suite --module console --filter without-new(1/1 passed)./run_parity_tests.sh --suite node-suite --module console(119/119 passed)cargo fmt --all -- --checkgit diff --checkCloses #6788
Summary by CodeRabbit
.lengthreflection for native and optimized callable functions.Console.lengthto return1, matching its declared arity.