Issue #16473 has been updated by puchuu (Andrew Aladjev).


@jeremyevans0, what will be the right way to bypass keyword arguments?

```ruby
def non_kw(a = {}, **keyword_args)
  puts "non kw #{a}"
  kw **keyword_args
end
```

This variant is wrong with ruby 2, because it provides:

```
non kw {:a=>2}
kw 2
warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
warning: The called method `non_kw' is defined here
non kw {}
kw 3
non kw {}
kw 1
```

Will it work with ruby 3? Thank you.

----------------------------------------
Bug #16473: New deprecated warning disallows keyword arguments bypassing
https://bugs.ruby-lang.org/issues/16473#change-83602

* Author: puchuu (Andrew Aladjev)
* Status: Rejected
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.7.0
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Hello. I see that ruby 2.7.0 prints unnecessary deprecated warning during arguments bypassing.

```ruby
def kw(a: 1)
  puts "kw #{a}"
end

def non_kw(a = {}, *args)
  puts "non kw #{a}"
  kw *args
end

non_kw({ :a => 2 }, :a => 2)
non_kw({ :a => 3 })
non_kw
```

The right output is:

```
non kw {:a=>2}
kw 2
non kw {:a=>3}
kw 1
non kw {}
kw 1
```

Ruby 2.7.0 provides deprecated warning:
```ruby
warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
```

`*args` is bypassing arguments without any conversion. It looks like ruby converts last hash to keywords and than converts it back to hash. I think it is a bug.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>