aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_keyword.rb
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2019-12-22 03:31:27 +0900
committerYusuke Endoh <mame@ruby-lang.org>2019-12-22 03:35:29 +0900
commit75acbd5f0076970d48bc423c2b058adbdb5da9e8 (patch)
tree63fb15a22a27aa969916849dcdfc381cd13b52bb /test/ruby/test_keyword.rb
parent3a29f05ba5ba7ed4b821ba5f566eeb3ff3c5c3b1 (diff)
downloadruby-75acbd5f0076970d48bc423c2b058adbdb5da9e8.tar.gz
compile.c: avoid newarraykwsplat for argumentsv2_7_0_rc2
`foo(*rest, post, **empty_kw)` is compiled like `foo(*rest + [post, **empty_kw])`, and `**empty_kw` is removed by "newarraykwsplat" instruction. However, the method call still has a flag of KW_SPLAT, so "post" is considered as a keyword hash, which caused a segfault. Note that the flag cannot be removed if "empty_kw" is not always empty. This change fixes the issue by compiling arguments with "newarray" instead of "newarraykwsplat". [Bug #16442]
Diffstat (limited to 'test/ruby/test_keyword.rb')
-rw-r--r--test/ruby/test_keyword.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb
index 3d5cb2dd20..bfdec6fc74 100644
--- a/test/ruby/test_keyword.rb
+++ b/test/ruby/test_keyword.rb
@@ -4654,6 +4654,12 @@ class TestKeywordArguments < Test::Unit::TestCase
def test_splat_empty_hash_with_block_passing
assert_valid_syntax("bug15087(**{}, &nil)")
end
+
+ def test_do_not_use_newarraykwsplat
+ assert_equal([42, "foo", 424242], f2(*[], 42, **{}))
+ a = [1, 2, 3]
+ assert_equal([[1,2,3,4,5,6], "foo", 424242, {:k=>:k}], f7(*a, 4,5,6, k: :k))
+ end
end
class TestKeywordArgumentsSymProcRefinements < Test::Unit::TestCase