summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2019-09-05 10:07:05 (GMT)
committerJeremy Evans <code@jeremyevans.net>2019-09-06 00:47:12 (GMT)
commitdd83f7bf98764b27385735f6f39dd090dc4854f9 (patch)
treec4b02be62307904bc39dd51e5aad8da3f9f1f6d4
parent70f2780892330f8d1b612002c437fc2ca739fc7f (diff)
define_method should not drop the empty keyword hash
Similar to 38e9c1bc35d5549575fbb263afff560e97db068e
-rw-r--r--test/ruby/test_keyword.rb8
-rw-r--r--vm_insnhelper.c2
2 files changed, 5 insertions, 5 deletions
diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb
index dc450c0..229f0b3 100644
--- a/test/ruby/test_keyword.rb
+++ b/test/ruby/test_keyword.rb
@@ -185,7 +185,7 @@ class TestKeywordArguments < Test::Unit::TestCase
f = -> { true }
assert_equal(true, f[**{}])
- assert_equal(true, f[**kw])
+ assert_raise(ArgumentError) { f[**kw] }
assert_raise(ArgumentError) { f[**h] }
assert_raise(ArgumentError) { f[a: 1] }
assert_raise(ArgumentError) { f[**h2] }
@@ -193,7 +193,7 @@ class TestKeywordArguments < Test::Unit::TestCase
f = ->(a) { a }
assert_raise(ArgumentError) { f[**{}] }
- assert_raise(ArgumentError) { f[**kw] }
+ assert_equal(kw, f[**kw])
assert_equal(h, f[**h])
assert_equal(h, f[a: 1])
assert_equal(h2, f[**h2])
@@ -685,7 +685,7 @@ class TestKeywordArguments < Test::Unit::TestCase
define_method(:m) { }
end
assert_nil(c.m(**{}))
- assert_nil(c.m(**kw))
+ assert_raise(ArgumentError) { c.m(**kw) }
assert_raise(ArgumentError) { c.m(**h) }
assert_raise(ArgumentError) { c.m(a: 1) }
assert_raise(ArgumentError) { c.m(**h2) }
@@ -697,7 +697,7 @@ class TestKeywordArguments < Test::Unit::TestCase
define_method(:m) {|arg| arg }
end
assert_raise(ArgumentError) { c.m(**{}) }
- assert_raise(ArgumentError) { c.m(**kw) }
+ assert_equal(kw, c.m(**kw))
assert_equal(h, c.m(**h))
assert_equal(h, c.m(a: 1))
assert_equal(h2, c.m(**h2))
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 227ec2e..92a9bc6 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -2927,7 +2927,7 @@ vm_callee_setup_block_arg(rb_execution_context_t *ec, struct rb_calling_info *ca
rb_control_frame_t *cfp = ec->cfp;
VALUE arg0;
- CALLER_SETUP_ARG(cfp, calling, ci, 1); /* splat arg */
+ CALLER_SETUP_ARG(cfp, calling, ci, 0); /* splat arg */
if (arg_setup_type == arg_setup_block &&
calling->argc == 1 &&