Commit 33db7a5a
33db7a5aa8d7Merged
Yusuke Endoh <[email protected]> · 6 months ago · 2 files · +1 added · ~1 modified
Description
fix(codegen): support Array#each_with_object on poly_array
each_with_object only matched int_array | str_array | float_array | sym_array. On a poly_array the dispatcher fell through and the loop
body was never emitted:
n = 0 [1, "a", :sym].each_with_object("") {|_e, _a| n += 1 } puts n # ruby: 3, spinel: 0
Follow-up to the introduction of poly_array: each_with_object was
missed when the new type was added. Extend the receiver-type check
and let elem_type_of_array map poly_array → "poly" so the block
param is typed sp_RbVal.
Adds test/array_each_with_object_poly.rb.
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- 33db7a5aa8d7
- Parent
- 78a133bd5d33
spinel_codegen.rbmodifiedView file
@@ -3031,6 +3031,9 @@
30313031
if t == "sym_array"30323032
return "symbol"30333033
end3034+
if t == "poly_array"3035+
return "poly"3036+
end30343037
if is_ptr_array_type(t) == 130353038
return ptr_array_elem_type(t)30363039
end@@ -20962,7 +20965,7 @@
2096220965
result = new_temp2096320966
emit(" " + obj_ct + " " + result + " = " + obj_arg + ";")2096420967
tmp_i = new_temp20965-
if rt == "int_array" || rt == "str_array" || rt == "float_array" || rt == "sym_array"20968+
if rt == "int_array" || rt == "str_array" || rt == "float_array" || rt == "sym_array" || rt == "poly_array"2096620969
pfx = array_c_prefix(rt)2096720970
emit(" {")2096820971
@indent = @indent + 1test/array_each_with_object_poly.rbaddedView file
Loading diff…