Skip to content

Commit

Permalink
define_method should not drop the empty keyword hash
Browse files Browse the repository at this point in the history
Similar to 38e9c1bc35d5549575fbb263afff560e97db068e
  • Loading branch information
mame authored and jeremyevans committed Sep 6, 2019
1 parent 70f2780 commit dd83f7b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions test/ruby/test_keyword.rb
Expand Up @@ -185,15 +185,15 @@ def test_lambda_kwsplat_call

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] }
assert_raise(ArgumentError) { f[**h3] }

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])
Expand Down Expand Up @@ -685,7 +685,7 @@ class << c
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) }
Expand All @@ -697,7 +697,7 @@ class << c
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))
Expand Down
2 changes: 1 addition & 1 deletion vm_insnhelper.c
Expand Up @@ -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 &&
Expand Down

0 comments on commit dd83f7b

Please sign in to comment.