Commit c655d53d
c655d53dbc21Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified
Description
fix(analyze): empty array widens to poly_array on Hash/Array push (#440)
#412 added the int_array → _array upgrade in scan_locals's push observation for primitive element types (str_array, float_array, sym_array, obj_X_ptr_array, poly_array). Container element types — Hash literals and nested Arrays — fell through to the bottom of the if/elsif chain and stayed at int_array, then sp_IntArray_push errored with int-from-pointer conversion.
Extend the push observation: when the pushed arg's type is a hash variant (is_hash_type) or an array variant (is_array_type, which covers both flat typed arrays and *_ptr_array nested arrays), promote the local to poly_array. Spinel has no _ptr_array or _ptr_array_ptr_array slot — poly_array is the canonical container-of-containers shape, matching the literal-array inference at infer_array_elem_type_from_ids (the typed-array and hash arms at line 2400 / 2414).
Closes #440
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- c655d53dbc21
- Parent
- c915ee1ac501
spinel_analyze.rbmodifiedView file
end ki = ki + 1 end elsif is_hash_type(arg_type) == 1 || is_array_type(arg_type) == 1 || is_ptr_array_type(arg_type) == 1 # Hash or typed-array element: spinel has no # <hash>_ptr_array / <array>_ptr_array_ptr_array slot, # so box each push via poly_array. Mirrors the literal- # array inference shape at infer_array_elem_type_from_ids # (line 2400+ / 2414+). @needs_rb_value = 1 @needs_gc = 1 ki = 0 while ki < names.length if names[ki] == arr_name if types[ki] == "int_array" types[ki] = "poly_array" end end ki = ki + 1 end end end endtest/empty_array_push_container_elem.rbaddedView file
Loading diff…
test/empty_array_push_container_elem.rb.expectedaddedView file
Loading diff…