Repository navigation
Enumerator + Lazy + Yielder: advance MRI 4.0.6 conformance - #550
Merged
Merged
Conversation
Enumerator::Lazy now answers #size by threading the source's size through
the op chain (map/with_index/zip keep it, take/drop bound it, filtering ops
make it unknown). Adds Enumerator::Lazy.new(obj, size) { |y, *vals| … },
Lazy#next/#peek/#next_values/#peek_values/#rewind driven one element at a
time through a fiber (no over-evaluation), and shares Method objects so
collect/filter/find_all/collect_concat/enum_for match their MRI aliases and
the Lazy method whitelist is complete. Adds Lazy#to_enum/#enum_for.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…index Enumerator#feed queues a value the source's next yield returns during external iteration (TypeError on double-feed, cleared by #rewind); Yielder#yield now returns that value, Yielder#<< enforces arity 1, and Yielder#to_proc lets a yielder be passed as &block. Enumerator#each_with_index rejects extra args; uninitialized (allocate) enumerators inspect as "#<Class: uninitialized>". Lazy#take stops driving the source once its quota is met (never running a source that raises on its n+1-th step, and take(0) drives it zero times); Lazy#zip validates list-like arguments (TypeError) and Lazy#with_index treats a nil offset as 0; Lazy#flat_map flattens an Array or a forceable Lazy. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…tests The lazy pipeline now threads a source's raw yield arguments alongside the gathered value, so a multi-value yield reaches each op the way MRI does (rb_yield_values2): map/flat_map/filter_map/take_while/drop_while pass the arguments by block arity (a single-parameter block sees only the first), while select/reject/uniq and the grouping ops operate on the gathered value; the arguments survive a filter into a later mapping op. Enumerator#each(*args) appends its arguments to the receiver's #each. Adds enumerator_residuals_test.go covering feed, Yielder, aliases, lazy size/next/peek, to_enum, flat_map flattening, zip validation, with_index offset and take quota behaviour. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ches lazySize now only propagates an Integer or +Infinity size (any other base is reported unknown), so lazyOpSize's take/drop arithmetic has no dead non-numeric fallbacks. Removes the take op's now-redundant rem<=0 guard (the pre-loop takeSaturated check plus stopping the pull the moment the quota is met already keep take(0) from driving the source). Extends the residual tests to cover the live-Lazy #inspect path, to_enum(meth) forcing, take followed by an early-stopping terminal, and a lazy over a Chain source. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Advances
core/enumeratorandcore/enumerator/lazyresiduals toward MRI Ruby 4.0.6, entirely withininternal/vm/enumerator.goandinternal/vm/lazy.goplus a newenumerator_residuals_test.go. Suite total for those specs: pass 233 → 298 (fail 45 → 20, error 34 → 25); no regressions.Highlights:
yield; TypeError on double-feed; cleared by#rewind); Yielder#yield returns that value, Yielder#<< enforces arity 1, Yielder#to_proc lets&yielderbe a block.#each; #each_with_index rejects extra args; uninitialized (allocate) enumerators inspect as#<Class: uninitialized>.instance_methods(false)whitelist.take(0)drives it zero times).Builds,
go test ./internal/vm/andgo test ./...green,GOOS=wasip1 GOARCH=wasm go build ./...OK,gofmt -lclean; every changed function is 100% in the merged-coverpkgprofile. FLOOR untouched.🤖 Generated with Claude Code