Commit 8ad869e5
8ad869e58a58Merged
Yusuke Endoh <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified
Description
fix(codegen): poly_array << / push handlers in both expr and stmt context
compile_call_expr and compile_mutating_call_stmt had << /
push branches for int_array, float_array, str_array, sym_array,
ptr_array, but not poly_array — so arr << val on a poly_array
recv fell through to:
- (expr context, line 20744) raw C
<<operator:(arr << val)wherearrissp_PolyArray *andvalissp_Method *. gcc rejects with "invalid operands to binary <<". - (stmt context, no fall-through) silently dropped — the push vanished from the generated C entirely.
Add poly_array branches in both:
- expr context:
(sp_PolyArray_push(rc, box(val)), rc) - stmt context:
sp_PolyArray_push(rc, box(val));
The argument is boxed via box_value_to_poly when its static
type is non-poly so the PolyArray's elements stay typed as
sp_RbVal (PolyArray's element representation).
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- 8ad869e58a58
- Parent
- ef05cb1aa590
spinel_codegen.rbmodifiedView file
@@ -21595,6 +21595,12 @@
2159521595
rc = compile_expr_gc_rooted(recv)2159621596
return "(sp_PtrArray_push(" + rc + ", " + compile_arg0(nid) + "), " + rc + ")"2159721597
end21598+
if lt == "poly_array"21599+
@needs_rb_value = 121600+
@needs_gc = 121601+
rc = compile_expr_gc_rooted(recv)21602+
return "(sp_PolyArray_push(" + rc + ", " + box_expr_to_poly(get_args(@nd_arguments[nid])[0]) + "), " + rc + ")"21603+
end2159821604
if lt == "poly"2159921605
@needs_rb_value = 12160021606
return "sp_poly_shl(" + compile_expr(recv) + ", " + box_expr_to_poly(get_args(@nd_arguments[nid])[0]) + ")"@@ -28683,6 +28689,22 @@
2868328689
emit(" sp_PtrArray_push(" + rc + ", " + compile_arg0(nid) + ");")2868428690
return 12868528691
end28692+
if rt == "poly_array"28693+
rc = compile_expr_gc_rooted(recv)28694+
args_id3 = @nd_arguments[nid]28695+
if args_id3 >= 028696+
aa = get_args(args_id3)28697+
if aa.length > 028698+
vt = infer_type(aa[0])28699+
vexpr = compile_expr(aa[0])28700+
if vt != "poly"28701+
vexpr = box_value_to_poly(vt, vexpr)28702+
end28703+
emit(" sp_PolyArray_push(" + rc + ", " + vexpr + ");")28704+
return 128705+
end28706+
end28707+
end2868628708
end2868728709
end2868828710
test/poly_array_push_handlers.rbaddedView file
Loading diff…
test/poly_array_push_handlers.rb.expectedaddedView file
Loading diff…