We want to update our codebase to Ruby 3 and one of the biggest breaking change is the mix of keyword arguments with arguments in methods. This warning should show up
warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
But I've noticed when running a simple script, it just doesn't appear
# script.rb
def my_method(argument, other:)
puts "hello"
end
options = { other: "medium" }
argument = true
my_method(argument, options)
$ rvm use 2.7.5
$ ruby script.rb
hello
$ rvm use 3.0.1
$ ruby script.rb
script.rb:1:in `my_method': wrong number of arguments (given 2, expected 1; required keyword: other) (ArgumentError)
from script.rb:8:in `<main>'
It breaks as planned in Ruby 3, but doesn't show anything in the previous versions.
This behavior is the same in production for us, I couldn't spot one occurrence anywhere. I've used RUBYOPT='-W:deprecated'
or even $VERBOSE = true
that successfully list several other deprecation warnings except this one.
After looking around, it doesn't seem other people have this problem. Is there something I am missing here? Is there an option in Ruby? Using other versions of Ruby like 2.7.2 renders the same.
Another detail, we use Ruby on Rails ton run everything, but I believe the problem is within Ruby itself.