Repository navigation
Bind a proc's &b block parameter to the block passed to Proc#call - #519
Merged
Merged
Conversation
A proc/lambda with its own `&b` block parameter did not capture the block
handed to Proc#call / #[] / #() — procCall discarded it — so `&b` was
always nil and any `->(&b){ … b.call }` or block-forwarding lambda
(`->(r,*a,&b){ r.step(*a,&b) }`) failed with a NoMethodError. exec now
takes a separate blockArg for the `&b` slot: for a method it equals the
block (a method's block backs both `&b` and a bare `yield`), but for
Proc#call the block passed to `.call` binds `&b` while `yield` inside the
proc still reaches the block captured where the proc was defined — the two
diverge, matching MRI.
Exposing the working block-form of Numeric#step surfaced a pre-existing
non-termination: a non-finite start (Float::INFINITY.step(Float::INFINITY,
1)) made every term the same Infinity, looping forever. MRI's step count
(stop-start)/step is NaN/negative there, so it yields nothing; guard it.
core/numeric/step_spec 184 -> 208 (fail 24 -> 0); core/proc/call_spec
13 -> 15. ruby/spec ratchet FLOOR 17270 -> 17300 (measured total 17342).
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.
A proc/lambda with its own
&bblock parameter did not capture the block handed toProc#call/#[]/#()—procCalldiscarded it — so&bwas alwaysniland any->(&b){ … b.call }or block-forwarding lambda (->(r,*a,&b){ r.step(*a,&b) }) failed with aNoMethodError.execnow takes a separateblockArgfor the&bslot: for a method it equals the block (a method's block backs both&band a bareyield), but forProc#callthe block passed to.callbinds&bwhileyieldinside the proc still reaches the block captured where the proc was defined — the two diverge, matching MRI (proc { yield }called with a different block still yields to the captured one).Exposing the working block-form of
Numeric#stepsurfaced a pre-existing non-termination: a non-finite start (Float::INFINITY.step(Float::INFINITY, 1)) made every term the same Infinity, looping forever. MRI's step count(stop-start)/stepis NaN/negative there, so it yields nothing — guarded.Conformance:
core/numeric/step_spec184 → 208 (fail 24 → 0);core/proc/call_spec13 → 15; no regressions across a block-heavy sweep. FLOOR 17270 → 17300 (measured total 17342).go test ./...green, native +wasip1/wasmbuild, gofmt clean, 100% merged coverage of the new code.🤖 Generated with Claude Code