[ruby-core:96518] [Ruby master Bug#16458] Ruby 2.7 warning firing in the wrong situations
From:
rafael@...
Date:
2019-12-27 17:55:57 UTC
List:
ruby-core #96518
Issue #16458 has been reported by rafaelfranca (Rafael Fran軋).
----------------------------------------
Bug #16458: Ruby 2.7 warning firing in the wrong situations
https://bugs.ruby-lang.org/issues/16458
* Author: rafaelfranca (Rafael Fran軋)
* Status: Open
* 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 related 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: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/Users/rafaelfranca/src/rails/rails/activesupport/lib/active_support/core_ext/object/try.rb:146: warning: The called method `try' is defined here
```
This is the method call:
https://github.com/rails/globalid/blob/bdcbc0300c29292709e4f16b7eb69f8cff9be993/lib/global_id/global_id.rb#L23
This is the method definition:
https://github.com/rails/rails/blob/fe097fa629f0975316736f08c3ae00600055ef06/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 = {})
A.public_send(:b, 1, options.merge(a: "a"))
end
class A
def self.b(number, options = {})
B.b(number, options)
end
end
class B
class << self
def b(number, options = {})
C.new.try(:c, options)
end
end
end
class C
def c(options = {})
puts(options)
end
end
a
a(b: "b")
```
--
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>