Commit ae57c944

ae57c944a913Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 3 files · +1 added · ~2 modified

Description

Specialize Array#flatten for str_array / float_array element arrays

flatten on a typed-array-of-typed-array was only wired for int elements (int_array_ptr_array -> int_array, #739). A nested array of strings (str_array_ptr_array, e.g. pr_geohash's cells.map{...}.flatten) or floats fell through to the unresolved-call stub and failed to compile.

Mirror the int specialization for str and float: the analyzer maps str_array_ptr_array -> str_array and float_array_ptr_array -> float_array, and codegen concatenates every inner array into one flat typed array via the matching push helper. sym_array-of-arrays stays unsupported — sp_SymArray has no new/push runtime helpers yet.

Closes #1078

Co-Authored-By: Claude Opus 4.8 [email protected]

Details

Commit
ae57c944a913
Parent
07c9db0750fb

spinel_analyze.rbmodifiedView file

@@ -5773,11 +5773,18 @@
57735773 if mname == "flatten"
57745774 if recv >= 0
57755775 rt_fl = infer_type(recv)
5776- # int_array_ptr_array (typed-array-of-int_array, common shape
5777- # from `[[1,2],[3,4]]`) flattens to int_array. Issue #739.
5776+ # A typed-array-of-<T>_array (e.g. `[[1,2],[3,4]]` ->
5777+ # int_array_ptr_array) flattens to a flat <T>_array. Issue #739
5778+ # added the int shape; str / float mirror it.
57785779 if rt_fl == "int_array_ptr_array"
57795780 return "int_array"
57805781 end
5782+ if rt_fl == "str_array_ptr_array"
5783+ return "str_array"
5784+ end
5785+ if rt_fl == "float_array_ptr_array"
5786+ return "float_array"
5787+ end
57815788 return rt_fl
57825789 end
57835790 return "int_array"