Commit ce48af2b
ce48af2b667eMerged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified
Description
fix(analyze): narrow Array#index poly-return to kinds with codegen
The earlier change in e46ec54 declared arr.index(x) as returning
poly for all array kinds, but codegen only routes int_array and
str_array through sp_*Array_index_poly runtime wrappers. For
float_array / sym_array / poly_array / ptr_array, the analyzer
expected poly while codegen emitted the int-returning fallback,
producing a type mismatch at the call site (e.g. [1,"two",:three] .index("two") failed C compile passing int into sp_poly_inspect).
Narrow the poly-return arm to the kinds with existing emit routes. The other array kinds fall through to the unresolved-call path (warn-emit-0) which is the same behavior as before this series. Issue raised during the cataloging-remaining-gaps review.
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- ce48af2b667e
- Parent
- cd9733e51230
spinel_analyze.rbmodifiedView file
@needs_rb_value = 1 return "poly" end if rt_idx == "int_array" || rt_idx == "str_array" || rt_idx == "float_array" || rt_idx == "sym_array" || rt_idx == "poly_array" || is_ptr_array_type(rt_idx) == 1 # Limited to int_array / str_array for now -- codegen has # `_poly` wrappers only for these two array kinds. # float_array / sym_array / poly_array / ptr_array fall # through to the existing unresolved-call path (warn + emit 0) # until their `_poly` wrappers land. Issue raised during the # #585 follow-up; the subset-correctness fix here only covers # the array kinds with existing emit routes. if rt_idx == "int_array" || rt_idx == "str_array" @needs_rb_value = 1 return "poly" end