Skip to content

Pass an Array given to the first Fiber#resume as one argument - #10216

Open
evaniainbrooks wants to merge 1 commit into
jruby:masterfrom
evaniainbrooks:10129-fiber-resume-spread-array
Open

evaniainbrooks wants to merge 1 commit into
jruby:masterfrom
evaniainbrooks:10129-fiber-resume-spread-array

Conversation

@evaniainbrooks

@evaniainbrooks evaniainbrooks commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #10129.

The first Fiber#resume or Fiber#transfer packed its arguments into one value, then started the block with yield semantics. So resume([a, b]) spread the Array over the block parameters. CRuby keeps the argument count and calls the block like Proc#call (cont.c, rb_fiber_start).

Now a fiber that has not started gets the raw arguments, and the block is called with Block#call. Values passed to later resumes (returned by Fiber.yield) are unchanged.

Testing: added two examples to spec/ruby/core/fiber/shared/resume.rb (runs for #resume and #transfer). spec/ruby/core/fiber passes on JRuby in interpreter and JIT mode. The new examples pass on CRuby 4.0.1 and 3.4.8.

The first resume or transfer packed its arguments into one value and
started the block with yield semantics, so a single Array was spread
over the block parameters. CRuby keeps the argument count and calls the
block like Proc#call (rb_fiber_start in cont.c). Pass the raw arguments
to a fiber that has not started and call the block with them.

Fixes jruby#10129
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.

Fiber#resume spreads an Array passed to the first resume over the block's parameters

1 participant