1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Warn for keyword to last hash parameter when method has no optional/rest parameters

Previously, there was no warning in this case, even though we will
be changing the behavior in Ruby 3.

Fixes [Bug #14130]
This commit is contained in:
Jeremy Evans 2019-08-30 19:23:10 -07:00
parent 6424d316b9
commit 3463e83192
3 changed files with 68 additions and 35 deletions

View file

@ -717,7 +717,9 @@ describe "A method" do
ruby
m(1, b: 2).should == [1, 2]
-> { m("a" => 1, b: 2) }.should raise_error(ArgumentError)
suppress_keyword_warning.call do
-> { m("a" => 1, b: 2) }.should raise_error(ArgumentError)
end
end
evaluate <<-ruby do
@ -726,7 +728,9 @@ describe "A method" do
m(2).should == [2, 1]
m(1, b: 2).should == [1, 2]
m("a" => 1, b: 2).should == [{"a" => 1, b: 2}, 1]
suppress_keyword_warning.call do
m("a" => 1, b: 2).should == [{"a" => 1, b: 2}, 1]
end
end
evaluate <<-ruby do
@ -735,7 +739,9 @@ describe "A method" do
m(1).should == 1
m(1, a: 2, b: 3).should == 1
m("a" => 1, b: 2).should == {"a" => 1, b: 2}
suppress_keyword_warning.call do
m("a" => 1, b: 2).should == {"a" => 1, b: 2}
end
end
evaluate <<-ruby do
@ -744,7 +750,9 @@ describe "A method" do
m(1).should == [1, {}]
m(1, a: 2, b: 3).should == [1, {a: 2, b: 3}]
m("a" => 1, b: 2).should == [{"a" => 1, b: 2}, {}]
suppress_keyword_warning.call do
m("a" => 1, b: 2).should == [{"a" => 1, b: 2}, {}]
end
end
evaluate <<-ruby do