Commit 74e638e9
74e638e9b9ddMerged
Yusuke Endoh <[email protected]> · 6 months ago · 2 files · +1 added · ~1 modified
Description
fix(codegen): attr-writer call returns rhs, not 0
obj.attr = v as an expression was emitting (rc->iv = v, 0):
the comma-with-zero forced the C value to 0 regardless of the
rhs. Chained writes like local = obj.attr = v and
b1.n = b2.n = 7 therefore landed 0 at the outer slot instead
of the rhs, contradicting Ruby semantics.
Drop the trailing , 0 so the assignment expression's value is
the rhs. C's auto-cast handles the slot-type-vs-rhs-type matchup
in either direction, same as for plain slot = expr.
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- 74e638e9b9dd
- Parent
- 15f7e5f356d7
spinel_codegen.rbmodifiedView file
@@ -21482,7 +21482,7 @@
2148221482
j = 02148321483
while j < writers.length2148421484
if writers[j] == bname21485-
return "(" + rc + arrow + sanitize_ivar(bname) + " = " + compile_arg0(nid) + ", 0)"21485+
return "(" + rc + arrow + sanitize_ivar(bname) + " = " + compile_arg0(nid) + ")"2148621486
end2148721487
j = j + 12148821488
endtest/attr_writer_returns_rhs.rbaddedView file
Loading diff…