Commit 9343b0be

9343b0be9d7eMerged

Yusuke Endoh <[email protected]> · 6 months ago · 2 files · +1 added · ~1 modified

Description

fix(codegen): support Array#+ on poly_array

a + b where both are heterogeneous arrays compiled to a + between two sp_PolyArray * pointers:

/tmp/_t.c:24:18: error: invalid operands to binary + (have 'sp_PolyArray *' and 'sp_PolyArray *')

Follow-up to the introduction of poly_array: Array#+ was missed in both infer_call_type (so the result type fell back to int) and compile_operator_call_expr (so the codegen emitted the C +). sp_PolyArray_dup is in place from the previous shuffle commit.

Adds test/array_plus_poly.rb.

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

Details

Commit
9343b0be9d7e
Parent
efb61dee8240

spinel_codegen.rbmodifiedView file

@@ -1676,7 +1676,7 @@
16761676 if lt == "poly"
16771677 return "poly"
16781678 end
1679- if lt == "int_array" || lt == "str_array" || lt == "float_array" || lt == "sym_array"
1679+ if lt == "int_array" || lt == "str_array" || lt == "float_array" || lt == "sym_array" || lt == "poly_array"
16801680 return lt
16811681 end
16821682 if lt == "float"
@@ -13811,7 +13811,7 @@
1381113811 @needs_string_helpers = 1
1381213812 return "sp_poly_add(" + compile_expr(recv) + ", " + box_expr_to_poly(@nd_arguments[nid] >= 0 ? get_args(@nd_arguments[nid])[0] : -1) + ")"
1381313813 end
13814- if lt == "int_array" || lt == "str_array" || lt == "float_array" || lt == "sym_array"
13814+ if lt == "int_array" || lt == "str_array" || lt == "float_array" || lt == "sym_array" || lt == "poly_array"
1381513815 rc = compile_expr_gc_rooted(recv)
1381613816 arg = compile_arg0(nid)
1381713817 pfx = array_c_prefix(lt)