[ruby-core:114340] [Ruby master Bug#19829] Enumerator.product called with keyword arguments raises exception with not precise message

Issue #19829 has been reported by andrykonchin (Andrew Konchin). ---------------------------------------- Bug #19829: Enumerator.product called with keyword arguments raises exception with not precise message https://bugs.ruby-lang.org/issues/19829 * Author: andrykonchin (Andrew Konchin) * Status: Open * Priority: Normal * ruby -v: 3.2.1 * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- 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: ```ruby 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. -- https://bugs.ruby-lang.org/

Issue #19829 has been updated by jeremyevans0 (Jeremy Evans). 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 ---------------------------------------- Bug #19829: Enumerator.product called with keyword arguments raises exception with not precise message https://bugs.ruby-lang.org/issues/19829#change-104152 * Author: andrykonchin (Andrew Konchin) * Status: Open * Priority: Normal * ruby -v: 3.2.1 * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- 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: ```ruby 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. -- https://bugs.ruby-lang.org/

Issue #19829 has been updated by matz (Yukihiro Matsumoto). 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. ---------------------------------------- Bug #19829: Enumerator.product called with keyword arguments raises exception with not precise message https://bugs.ruby-lang.org/issues/19829#change-104267 * Author: andrykonchin (Andrew Konchin) * Status: Closed * Priority: Normal * ruby -v: 3.2.1 * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- 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: ```ruby 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. -- https://bugs.ruby-lang.org/
participants (3)
-
andrykonchin (Andrew Konchin)
-
jeremyevans0 (Jeremy Evans)
-
matz (Yukihiro Matsumoto)