Skip to content

Support keyword arguments in Concurrent::Async delegators - #1128

Open
lyn1dev wants to merge 1 commit into
ruby-concurrency:masterfrom
lyn1dev:fix-async-keyword-arguments
Open

lyn1dev wants to merge 1 commit into
ruby-concurrency:masterfrom
lyn1dev:fix-async-keyword-arguments

Conversation

@lyn1dev

@lyn1dev lyn1dev commented Nov 25, 2026

Copy link
Copy Markdown

Fixes #1040

Summary

On Ruby 3+, calling a method with keyword arguments through Concurrent::Async#async or #await failed with ArgumentError (e.g. wrong number of arguments (given 1, expected 0; required keyword: msg)) because AsyncDelegator#method_missing and AwaitDelegator#method_missing captured *args without ruby2_keywords.

Changes

  • Mark Concurrent::Async::AsyncDelegator#method_missing and Concurrent::Async::AwaitDelegator#method_missing with ruby2_keywords :method_missing if respond_to?(:ruby2_keywords, true), matching the existing pattern on ClassMethods#new.
  • Add specs in spec/concurrent/async_spec.rb covering required keyword arguments, optional and splat keyword arguments, keyword arguments with blocks, and positional Hash arguments for both #async and #await.

Verification

  • Confirmed the new specs fail with ArgumentError before the change (38 examples, 2 failures, 1 pending on Windows where fork is unavailable).
  • Confirmed RUBYOPT="-w" bundle exec rspec spec/concurrent/async_spec.rb passes after the change (38 examples, 0 failures, 1 pending) in both normal and ISOLATED=true runs, and spec/concurrent/ivar_spec.rb passes alongside it (114 examples, 0 failures, 1 pending).

This branch has not been deployed

No deployments
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.

Add keyword arguments to async

1 participant