From: eregontp@... Date: 2020-02-21T09:39:45+00:00 Subject: [ruby-core:97228] [Ruby master Bug#16632] Remove verbose warning on treating keyword splat as positional argument in Ruby 2.6 Issue #16632 has been updated by Eregon (Benoit Daloze). As mentioned in https://bugs.ruby-lang.org/issues/16511#note-17 it seems very unlikely this triggers in practice, because indeed who would bother with an extra `**` when the method doesn't take keyword arguments? Maybe for the case the user thinks the method takes keyword arguments but it doesn't (yet, maybe the next gem version does)? Anyway, agreed with Jeremy, no point to warn about something which no longer warns in more recent versions. Warning `**` but not `foo: 1` as a special case seems to just make things more complicated. ---------------------------------------- Bug #16632: Remove verbose warning on treating keyword splat as positional argument in Ruby 2.6 https://bugs.ruby-lang.org/issues/16632#change-84338 * Author: jeremyevans0 (Jeremy Evans) * Status: Closed * Priority: Normal * ruby -v: ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-openbsd] * Backport: 2.5: DONTNEED, 2.6: REQUIRED, 2.7: DONTNEED ---------------------------------------- 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-------------------------------- remove-verbose-warning-keyword-splat-to-positional.patch (2.1 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: