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
end55725572
return "str_int_hash"55735573
end5574+
if mname == "group_by"5575+
if recv >= 05576+
rt_gb = infer_type(recv)5577+
if is_array_type(rt_gb) == 15578+
@needs_rb_value = 15579+
@needs_gc = 15580+
return "poly_poly_hash"5581+
end5582+
end5583+
end55745584
if mname == "transform_keys"55755585
if recv >= 055765586
rt_tk = infer_type(recv)spinel_codegen.rbmodifiedView file
Loading diff…
test/array_group_by_standalone.rbaddedView file
Loading diff…
test/array_group_by_standalone.rb.expectedaddedView file
Loading diff…