ruby-changes:57579
From: Jeremy <ko1@a...>
Date: Fri, 6 Sep 2019 10:00:08 +0900 (JST)
Subject: [ruby-changes:57579] 729de9ee68 (master): Convert empty keyword hash to required positional argument and warn for method_missing
https://git.ruby-lang.org/ruby.git/commit/?id=729de9ee68 From 729de9ee68b868b43375eb4339b2d59f0bb8e7e8 Mon Sep 17 00:00:00 2001 From: Jeremy Evans <code@j...> Date: Thu, 5 Sep 2019 13:07:28 -0700 Subject: Convert empty keyword hash to required positional argument and warn for method_missing This is the same as the bmethod, sym proc, and send cases, where we don't remove the keyword splat, so later code can move it to a required positional parameter and warn. diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index 2a99feb..7624e6d 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -728,8 +728,12 @@ class TestKeywordArguments < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L728 def c.method_missing(_, args) args end - assert_raise(ArgumentError) { c.m(**{}) } - assert_raise(ArgumentError) { c.m(**kw) } + assert_warn(/The keyword argument is passed as the last hash parameter.* for `method_missing'/m) do + assert_equal(kw, c.m(**{})) + end + assert_warn(/The keyword argument is passed as the last hash parameter.* for `method_missing'/m) do + assert_equal(kw, c.m(**kw)) + end assert_equal(h, c.m(**h)) assert_equal(h, c.m(a: 1)) assert_equal(h2, c.m(**h2)) @@ -751,8 +755,12 @@ class TestKeywordArguments < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L755 def c.method_missing(_, arg, **args) [arg, args] end - assert_raise(ArgumentError) { c.m(**{}) } - assert_raise(ArgumentError) { c.m(**kw) } + assert_warn(/The keyword argument is passed as the last hash parameter.* for `method_missing'/m) do + assert_equal([kw, kw], c.m(**{})) + end + assert_warn(/The keyword argument is passed as the last hash parameter.* for `method_missing'/m) do + assert_equal([kw, kw], c.m(**kw)) + end assert_warn(/The keyword argument is passed as the last hash parameter.* for `method_missing'/m) do assert_equal([h, kw], c.m(**h)) end diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 1bbe397..3c85d2f 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -2429,7 +2429,7 @@ vm_call_method_missing(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2429 struct rb_call_cache cc_entry, *cc; unsigned int argc; - CALLER_SETUP_ARG(reg_cfp, calling, orig_ci); + CALLER_SETUP_ARG_WITHOUT_KW_SPLAT(reg_cfp, calling, orig_ci); argc = calling->argc+1; ci_entry.flag = VM_CALL_FCALL | VM_CALL_OPT_SEND | (calling->kw_splat ? VM_CALL_KW_SPLAT : 0); -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/