Skip to content

Add specs for Enumerable value packing rule (0->nil, 1->value, N->Array)#1363

Merged
eregon merged 2 commits into
ruby:masterfrom
sampokuokkanen:enumerable-value-packing
May 27, 2026
Merged

Add specs for Enumerable value packing rule (0->nil, 1->value, N->Array)#1363
eregon merged 2 commits into
ruby:masterfrom
sampokuokkanen:enumerable-value-packing

Conversation

@sampokuokkanen

Copy link
Copy Markdown
Contributor

The rb_enum_values_pack rule in enum.c packs yielded source values when they flow through any Enumerable collection method or Lazy stage: 0 args -> nil, 1 arg -> the value, N args -> Array.

Pin this explicitly via a shared describe used by both Enumerable#take and Enumerator::Lazy#take.

The rb_enum_values_pack rule in enum.c packs yielded source values when they flow through any Enumerable collection method or Lazy stage: 0 args -> nil, 1 arg -> the value, N args -> Array.

Pin this explicitly via a shared describe used by both Enumerable#take and Enumerator::Lazy#take.
@sampokuokkanen sampokuokkanen force-pushed the enumerable-value-packing branch from 1e86572 to 5c4352c Compare May 27, 2026 13:45
Comment thread core/enumerable/shared/value_packing.rb
@eregon eregon merged commit 99d40d4 into ruby:master May 27, 2026
14 checks passed
sampokuokkanen added a commit to sampokuokkanen/truffleruby that referenced this pull request May 28, 2026
Apply CRuby's rb_enum_values_pack rule at the Lazy#each consumer boundary
(0 args -> nil, 1 arg -> value, N args -> Array) via Primitive.single_block_arg.
Chained stages bypass via a private iterate_chain helper that routes through
a pre-override _enumerable_each alias so user blocks still see raw args,
matching CRuby's LAZY_MEMO_PACKED unpacking in enumerator.c.

Specced via ruby/spec#1363.
sampokuokkanen added a commit to sampokuokkanen/truffleruby that referenced this pull request May 28, 2026
Apply CRuby's rb_enum_values_pack rule at the consumer boundary (0 args -> nil,
1 arg -> value, N args -> Array) via Primitive.single_block_arg. The override lives on a prepended ConsumerPacking module so Lazy.public_instance_methods(false) still matches MRI, which defines no Lazy#each.

Chained stages bypass via a private iterate_chain helper that routes through a
pre-override _enumerable_each alias, so stage user blocks still see raw args, matching CRuby's LAZY_MEMO_PACKED unpacking in enumerator.c.

Specced via ruby/spec#1363.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants