Project

General

Profile

Actions

Bug #16632

closed

Remove verbose warning on treating keyword splat as positional argument in Ruby 2.6

Added by jeremyevans0 (Jeremy Evans) almost 5 years ago. Updated over 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-openbsd]
[ruby-core:<unknown>]

Description

Ruby 2.6 will issue a verbose mode warning if treating a keyword splat as a positional argument if the method does not accept rest arguments or keyword arguments. This is different from Ruby 2.5, 2.7, and the master branch.

$ ruby25 -ve 'def a(b); b end; hash = {bar: 1}; p a(**hash)'
ruby 2.5.7p206 (2019-10-01 revision 67816) [x86_64-openbsd]
{:bar=>1}

$ ruby26 -ve 'def a(b); b end; hash = {bar: 1}; p a(**hash)'
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-openbsd]
-e:1: warning: in `a': the last argument was passed as a single Hash
-e:1: warning: although a splat keyword arguments here
{:bar=>1}

$ ruby27 -ve 'def a(b); b end; hash = {bar: 1}; p a(**hash)'
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-openbsd]
{:bar=>1}

My guess for the reason for the Ruby 2.6 behavior is it was done before we agreed on the semantics of keyword argument separation. If we were going to drop keyword argument to positional argument conversion for methods that did not accept keyword arguments, it is a reasonable warning. However, since we convert keyword arguments to positional arguments for methods that do not accept keywords, the 2.6 verbose mode warning doesn't make sense and I think should be removed. See attached diff for the removal of the warning and updating of related test.


Files


Related issues 1 (0 open1 closed)

Has duplicate Ruby master - Bug #16950: Stop nonsense keyword argument warnings in 2.6Closedusa (Usaku NAKAMURA)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0