Commit b75070d3
b75070d3abf9Merged
Yusuke Endoh <[email protected]> · 6 months ago · 2 files · +1 added · ~1 modified
Description
fix(codegen): support Array#each_with_object on ptr_array
each_with_object only matched the typed-array list. On a ptr_array
the dispatcher fell through and the loop body was never emitted:
n = 0 [Bar.new(1), Bar.new(2)].each_with_object("") {|_e, _a| n += 1 } puts n # ruby: 2, spinel: 0
Follow-up to the introduction of ptr_array (mirrors the earlier
poly_array fix): each_with_object was missed when the new type was
added. elem_type_of_array already maps *_ptr_array to its obj
element type via ptr_array_elem_type, so the block param is typed
correctly once the receiver-type check accepts ptr_array.
Adds test/array_each_with_object_ptr.rb.
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- b75070d3abf9
- Parent
- b6d93414ef23
spinel_codegen.rbmodifiedView file
result = new_temp emit(" " + obj_ct + " " + result + " = " + obj_arg + ";") tmp_i = new_temp if is_array_type(rt) == 1 if is_array_type(rt) == 1 || is_ptr_array_type(rt) == 1 pfx = array_c_prefix(rt) emit(" {") @indent = @indent + 1test/array_each_with_object_ptr.rbaddedView file
Loading diff…