Issue #16458 has been updated by marcandre (Marc-Andre Lafortune).

Status changed from Open to Rejected

The method is defined in line *146*, i.e. it is `nil`'s `#try` method:

```
def try(_method_name =3D nil, *, **)
  nil
end
```

https://github.com/rails/rails/blob/fe097fa629f0975316736f08c3ae00600055ef0=
6/activesupport/lib/active_support/core_ext/object/try.rb#L146-L148

So the warning isn't actually wrong.

----------------------------------------
Bug #16458: Ruby 2.7 warning firing in the wrong situations
https://bugs.ruby-lang.org/issues/16458#change-83451

* Author: rafaelfranca (Rafael Fran=E7a)
* Status: Rejected
* Priority: Normal
* Assignee: =

* Target version: =

* ruby -v: 2.7.0p0
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
I'm trying to remove all warnings from my library and there is a warning re=
lated to keyword arguments that is firing when I believe it should not.

The warning is:

```
/Users/rafaelfranca/src/rails/globalid/lib/global_id/global_id.rb:23: warni=
ng: Using the last argument as keyword parameters is deprecated; maybe ** s=
hould be added to the call
/Users/rafaelfranca/src/rails/rails/activesupport/lib/active_support/core_e=
xt/object/try.rb:146: warning: The called method `try' is defined here
```

This is the method call:
https://github.com/rails/globalid/blob/bdcbc0300c29292709e4f16b7eb69f8cff9b=
e993/lib/global_id/global_id.rb#L23

This is the method definition:
https://github.com/rails/rails/blob/fe097fa629f0975316736f08c3ae00600055ef0=
6/activesupport/lib/active_support/core_ext/object/try.rb#L7-L17

As you can see. The argument that Ruby believes is a keyword argument is a =
regular hash. I tried to simplify the case writing the following script but=
 I could run that script without warning.

```
require 'active_support'
require 'active_support/core_ext/object/try'

def a(options =3D {})
  A.public_send(:b, 1, options.merge(a: "a"))
end

class A
  def self.b(number, options =3D {})
    B.b(number, options)
  end
end

class B
  class << self
    def b(number, options =3D {})
      C.new.try(:c, options)
    end
  end
end

class C
  def c(options =3D {})
    puts(options)
  end
end

a
a(b: "b")
```



-- =

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

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