Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async::Notification has trouble when signalling with a plain hash object #67

Closed
tadman opened this issue Apr 29, 2020 · 2 comments
Closed

Comments

@tadman
Copy link

tadman commented Apr 29, 2020

The keyword argument causes the hash to be interpreted incorrectly by Ruby:

require 'async'
require 'async/notification'

Async do
  notification = Async::Notification.new

  hash = {
    async: true
  }

  notification.signal(hash)
  # => ArgumentError: unknown keyword: :async
end

It may be better to go all keyword args, like signal(value:, task:) to avoid ambiguity here, though that would be a breaking change.

@ioquatix
Copy link
Member

This will be fixed in Ruby 3 and is just an unfortunate issue of Ruby 2.x - I'll see if there is anything we can do to fix this, but I've run into this issue before with other libraries. It's one of the motivating factors to remove the implicit conversion of a hash to options.

@ioquatix
Copy link
Member

ioquatix commented Jul 4, 2020

Matz has confirmed the decision for Ruby 3.0 however it might be possible to work on 2.x by using empty options, **{}.

notification.signal(hash, **{})

This should be backwards and forwards compatible.

@ioquatix ioquatix closed this as completed Jul 4, 2020
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

No branches or pull requests

2 participants