From 70f2780892330f8d1b612002c437fc2ca739fc7f Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Thu, 5 Sep 2019 18:57:19 +0900 Subject: [PATCH] vm_call_bmethod should not drop the empty keyword hash Similar to 38e9c1bc35d5549575fbb263afff560e97db068e --- test/ruby/test_keyword.rb | 4 +++- vm_insnhelper.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index 3c486a4e15..dc450c08c2 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -733,7 +733,9 @@ class TestKeywordArguments < Test::Unit::TestCase define_method(:m) {|arg, **opt| [arg, opt] } end assert_raise(ArgumentError) { c.m(**{}) } - assert_raise(ArgumentError) { c.m(**kw) } + assert_warn(/The keyword argument is passed as the last hash parameter/m) do + assert_equal([kw, kw], c.m(**kw)) + end assert_warn(/The keyword argument is passed as the last hash parameter/m) do assert_equal([h, kw], c.m(**h)) end diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 70fbb491e6..227ec2e08f 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -2279,7 +2279,7 @@ vm_call_bmethod(rb_execution_context_t *ec, rb_control_frame_t *cfp, struct rb_c VALUE *argv; int argc; - CALLER_SETUP_ARG(cfp, calling, ci, 1); + CALLER_SETUP_ARG(cfp, calling, ci, 0); argc = calling->argc; argv = ALLOCA_N(VALUE, argc); MEMCPY(argv, cfp->sp - argc, VALUE, argc);