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

@@ -4338,7 +4338,14 @@
43384338 @needs_rb_value = 1
43394339 return "poly"
43404340 end
4341- 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
4341+ # Limited to int_array / str_array for now -- codegen has
4342+ # `_poly` wrappers only for these two array kinds.
4343+ # float_array / sym_array / poly_array / ptr_array fall
4344+ # through to the existing unresolved-call path (warn + emit 0)
4345+ # until their `_poly` wrappers land. Issue raised during the
4346+ # #585 follow-up; the subset-correctness fix here only covers
4347+ # the array kinds with existing emit routes.
4348+ if rt_idx == "int_array" || rt_idx == "str_array"
43424349 @needs_rb_value = 1
43434350 return "poly"
43444351 end