From 299a13612e54accd9d3661bafde8f67142a78d54 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Wed, 27 Nov 2019 09:03:00 -0800 Subject: Don't modify rest array when using ruby2_keywords Previously, the rest array was modified, but it turns out that is not necessary. Not modifying the rest array fixes cases when the rest array is used more than once. --- test/ruby/test_keyword.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/ruby/test_keyword.rb') diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index bbb107dedd..29335a4963 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -2649,6 +2649,11 @@ class TestKeywordArguments < Test::Unit::TestCase baz(*args) end + ruby2_keywords def foo_baz2(*args) + baz(*args) + baz(*args) + end + ruby2_keywords def foo_foo_bar(meth, *args) foo_bar(meth, *args) end @@ -2761,6 +2766,10 @@ class TestKeywordArguments < Test::Unit::TestCase h1 = {a: 1} o = c.new + assert_equal([1, h1], o.foo_baz2(1, :a=>1)) + assert_equal([1], o.foo_baz2(1, **{})) + assert_equal([h1], o.foo_baz2(h1, **{})) + assert_equal([[1], h1], o.foo(:bar, 1, :a=>1)) assert_equal([1, h1], o.foo(:baz, 1, :a=>1)) assert_equal([[1], h1], o.bfoo(:bar, 1, :a=>1)) -- cgit v1.2.3