Commit c6b96233

c6b962331cb9Merged

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

Description

codegen: int_array#slice_when / #chunk materialise directly

Both used to fall through to the unresolved-call emit-0 path, which then crashed when the user chained `.to_a`. Inline the materialisation: slice_when walks the array and starts a new chunk whenever the block predicate returns true; chunk groups consecutive elements sharing the same block-returned key and emits [key, sub_array] pairs.

`.to_a` on the resulting (int_array_ptr_array / poly_array) is now a no-op identity — the result IS the array.

Fixes #935 Fixes #936 (slice_when portion)

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

Details

Commit
c6b962331cb9
Parent
7db7727cd10e

spinel_analyze.rbmodifiedView file

@@ -4477,6 +4477,12 @@
44774477 if mname == "product"
44784478 return "int_array_ptr_array"
44794479 end
4480+ if mname == "slice_when" || mname == "chunk_while"
4481+ return "int_array_ptr_array"
4482+ end
4483+ if mname == "chunk"
4484+ return "poly_array"
4485+ end
44804486 # Issue #889: String#unpack returns Array of mixed-type elements;
44814487 # spinel boxes through poly_array.
44824488 if mname == "unpack"