Project

General

Profile

Actions

Bug #16458

closed

Ruby 2.7 warning firing in the wrong situations

Added by rafaelfranca (Rafael França) over 4 years ago. Updated over 4 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
2.7.0p0
[ruby-core:96518]

Description

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")
Actions

Also available in: Atom PDF

Like0
Like0