Skip to content

Add specs for Enumerator::Lazy passing multiple values on through the chain - #1389

Closed
sampokuokkanen wants to merge 1 commit into
ruby:masterfrom
sampokuokkanen:lazy-packed-propagation-specs
Closed

sampokuokkanen wants to merge 1 commit into
ruby:masterfrom
sampokuokkanen:lazy-packed-propagation-specs

Conversation

@sampokuokkanen

@sampokuokkanen sampokuokkanen commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

A lazy method which passes an element through unchanged (#select, #take, #compact, …) passes the values the source yielded at once on to the next method, so a splat block later in the chain sees them separately:

Enumerator.new { |y| y.yield 1, 2 }.lazy.select { true }.map { |*values| values }.force
# => [[1, 2]]

A method which produces a new value (#map, #filter_map, #grep with a block, …) passes that single value on. An element yielded with no value at all is nil for a lazy method.

The shared examples are in shared/value_propagation.rb. The specs pass on CRuby 3.3, 3.4 and 4.0, and are the ones from truffleruby/truffleruby#4420 after eregon's cleanup.

… chain

A lazy method which passes an element through unchanged (#select, #take,
#compact, ...) passes the values the source yielded at once on to the next
method, so a splat block later in the chain sees them separately. A method
which produces a new value (#map, #filter_map, #grep with a block, ...)
passes that single value on. An element yielded with no value at all is nil
for a lazy method.
@sampokuokkanen
sampokuokkanen force-pushed the lazy-packed-propagation-specs branch from ae72473 to 3da1ed2 Compare November 24, 2026 12:47
@sampokuokkanen sampokuokkanen changed the title Specs for Enumerator::Lazy propagating source yield arity through stages Add specs for Enumerator::Lazy passing multiple values on through the chain Nov 24, 2026
@sampokuokkanen

Copy link
Copy Markdown
Contributor Author

@eregon
This should now match what is merged on truffleruby master.

@eregon

eregon commented Nov 24, 2026

Copy link
Copy Markdown
Member

Are these the exact same specs from truffleruby/truffleruby#4420? It looks like it.
If so, they'll be sync'd back here around the end of the month so there is no need to merge them here earlier.

@sampokuokkanen

Copy link
Copy Markdown
Contributor Author

Ah sorry, if so then I'll close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants