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
if mname == "flatten" if recv >= 0 rt_fl = infer_type(recv) # int_array_ptr_array (typed-array-of-int_array, common shape # from `[[1,2],[3,4]]`) flattens to int_array. Issue #739. # A typed-array-of-<T>_array (e.g. `[[1,2],[3,4]]` -> # int_array_ptr_array) flattens to a flat <T>_array. Issue #739 # added the int shape; str / float mirror it. if rt_fl == "int_array_ptr_array" return "int_array" end if rt_fl == "str_array_ptr_array" return "str_array" end if rt_fl == "float_array_ptr_array" return "float_array" end return rt_fl end return "int_array"spinel_codegen.rbmodifiedView file
Loading diff…
test/array_flatten_typed_elements.rbaddedView file
Loading diff…