Issue #16339 has been updated by jeremyevans0 (Jeremy Evans).

Status changed from Open to Closed

Fixed by commit:9fa0166a580e72adf02562b7d60672c6c362d4b7.

----------------------------------------
Bug #16339: Forwardable#def_delegator warns and is incorrect on trunk when passed keyword arguments
https://bugs.ruby-lang.org/issues/16339#change-82955

* Author: Eregon (Benoit Daloze)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.7.0dev (2019-11-10T05:56:38Z master 4570284ce1) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Because it uses `*args, &block`-style delegation.
```ruby
require 'forwardable'

class C
  extend Forwardable
  def_delegator :self, :target, :delegate
  def target(*args, **kwargs)
    [args, kwargs]
  end
end

p C.new.target(1, b: 2)   # => [[1], {:b=>2}]
p C.new.delegate(1, b: 2)
# ruby-trunk/lib/ruby/2.7.0/forwardable.rb:231: warning: The last argument is used as the keyword parameter
# del.rb:6: warning: for `target' defined here
# => [[1], {:b=>2}]

p C.new.target({}, **{}) # => [[{}], {}]
p C.new.delegate({}, **{})
# ruby-trunk/lib/ruby/2.7.0/forwardable.rb:231: warning: The last argument is used as the keyword parameter
# del.rb:6: warning: for `target' defined here
# => [[], {}]
```

Which also illustrates we're missing important tests/specs for Forwardable.



-- 
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>