fix(runtime): coerce class refs before dynamic addition - #9097
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 8 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughRegistered class-reference INT32 values now use Function-object ToPrimitive handling during dynamic addition. New integration coverage checks string concatenation, repeated ChangesClass Reference Coercion
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: 🔵 Low · up to Dynamic addition now treats registered class references like functions, but an ordinary integer with the same runtime identifier may also be routed through class valueOf or toString behavior, producing unexpected results or method execution within a compiled program. The PR is mergeable with explicit owner awareness and follow-up to make class-reference identification unambiguous. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description provides a clear summary, identifies issue Full details: Linked Issues checkExplanation The implementation addresses issue
✨ 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 |
|
Merged. Closes #9087. Running the ordinary
Rows correct: main 5/27 → this PR 14/27, and nothing regressed — every row the PR touches moves toward node, and the rows still wrong are byte-identical on both arms. Case 10/11 is the one I'd highlight: main answered Four residuals, filed as #9101, none introduced here. The one worth your attention is that the looped class WithToString { static toString() { return "CUSTOM"; } }
let s = ""; for (let i = 0; i < 3; i++) s += WithToString;
// node: "CUSTOMCUSTOMCUSTOM" here: "function WithToString() { [native code] }…"— which is notable because the PR description names the looped Validation: runtime 2819 passed ( |
Summary
+coercionvalueOf/toStringsequence so default classes concatenate their function source while static overrides remain observable+=reproducerNo version bump.
Tests
Run on
root@perrymaster.skelpo.net:cargo fmt --all -- --checkcargo check -p perry-runtimecargo test -p perry-runtime dynamic_arith --libcargo build --release -p perry-runtime-staticcargo test -p perry --test issue_9087_class_ref_add -- --nocaptureCloses #9087
Summary by CodeRabbit
Bug Fixes
+operations instead of being treated as numeric identifiers.valueOfbehavior and correct results for both operand orders and repeated additions.Tests
valueOfresults.