Project

General

Profile

Actions

Bug #19829

closed

Enumerator.product called with keyword arguments raises exception with not precise message

Added by andrykonchin (Andrew Konchin) over 1 year ago. Updated about 1 year ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:114340]

Description

The Enumerator.product method, added in Ruby 3.2, when it's called with keyword arguments (but it expects only a list of enums) raises unknown keyword: ... (ArgumentError) exception:

Enumerator.product([], a: 1)
# (irb):1:in `product': unknown keyword: :a (ArgumentError)

But AFAIK unknown keyword is used when a method expects keyword arguments and some not supported keyword arguments were passed. So I would expect raising exception with no keywords accepted (ArgumentError) message instead that states clearly that no keywords should be passed.

Updated by jeremyevans0 (Jeremy Evans) over 1 year ago

I submitted a pull request to fix this, by adding an rb_no_keywords_accepted C-API function and using that for both C methods and Ruby methods that do not accept keywords: https://github.com/ruby/ruby/pull/8243

Updated by matz (Yukihiro Matsumoto) about 1 year ago

  • Status changed from Open to Closed

I see no benefit from the proposed change, other than you cannot tell the method takes any keyword argument or not at all from the error message.
In that case, I advise reading the document.

Matz.

Actions

Also available in: Atom PDF

Like0
Like1Like0