Commit 39547bb5

39547bb511c8Merged

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

Description

analyze,codegen: Array#group_by standalone returns poly_poly_hash

Build a poly_poly_hash keyed by the block result with boxed-poly_array values (per-key buckets). Reuses the fused-each emit shape (same poly_poly_hash + insertion-order poly_array), just without the trailing each loop so the result is observable directly.

analyze claims poly_poly_hash for any-typed array receiver; `{1=>[1,4], 2=>[2,5], 0=>[3,6]}` inspect format comes from the existing sp_PolyPolyHash_inspect (`int_key => array_value` shape).

Fixes #983

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

Details

Commit
39547bb511c8
Parent
7780fff2c6e8

spinel_analyze.rbmodifiedView file

@@ -5571,6 +5571,16 @@
55715571 end
55725572 return "str_int_hash"
55735573 end
5574+ if mname == "group_by"
5575+ if recv >= 0
5576+ rt_gb = infer_type(recv)
5577+ if is_array_type(rt_gb) == 1
5578+ @needs_rb_value = 1
5579+ @needs_gc = 1
5580+ return "poly_poly_hash"
5581+ end
5582+ end
5583+ end
55745584 if mname == "transform_keys"
55755585 if recv >= 0
55765586 rt_tk = infer_type(recv)