[前][次][番号順一覧][スレッド一覧]

ruby-changes:57600

From: Jeremy <ko1@a...>
Date: Fri, 6 Sep 2019 15:15:11 +0900 (JST)
Subject: [ruby-changes:57600] e220b467ef (master): Convert empty keyword hash to required positional argument and warn for sym procs

https://git.ruby-lang.org/ruby.git/commit/?id=e220b467ef

From e220b467ef3faf24140cba572b2d67973391aaa5 Mon Sep 17 00:00:00 2001
From: Jeremy Evans <code@j...>
Date: Thu, 5 Sep 2019 13:03:09 -0700
Subject: Convert empty keyword hash to required positional argument and warn
 for sym procs

This is the same as the bmethod and send cases, where we don't
remove the keyword splat, so later code can move it to to a
a required positional parameter and warn.

diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb
index c5b9c15..2a99feb 100644
--- a/test/ruby/test_keyword.rb
+++ b/test/ruby/test_keyword.rb
@@ -633,8 +633,12 @@ class TestKeywordArguments < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L633
     def c.m(args)
       args
     end
-    assert_raise(ArgumentError) { :m.to_proc.call(c, **{}) }
-    assert_raise(ArgumentError) { :m.to_proc.call(c, **kw) }
+    assert_warn(/The keyword argument is passed as the last hash parameter.* for `m'/m) do
+      assert_equal(kw, :m.to_proc.call(c, **{}))
+    end
+    assert_warn(/The keyword argument is passed as the last hash parameter.* for `m'/m) do
+      assert_equal(kw, :m.to_proc.call(c, **kw))
+    end
     assert_equal(h, :m.to_proc.call(c, **h))
     assert_equal(h, :m.to_proc.call(c, a: 1))
     assert_equal(h2, :m.to_proc.call(c, **h2))
@@ -657,8 +661,12 @@ class TestKeywordArguments < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L661
     def c.m(arg, **args)
       [arg, args]
     end
-    assert_raise(ArgumentError) { :m.to_proc.call(c, **{}) }
-    assert_raise(ArgumentError) { :m.to_proc.call(c, **kw) }
+    assert_warn(/The keyword argument is passed as the last hash parameter.* for `m'/m) do
+      assert_equal([kw, kw], :m.to_proc.call(c, **{}))
+    end
+    assert_warn(/The keyword argument is passed as the last hash parameter.* for `m'/m) do
+      assert_equal([kw, kw], :m.to_proc.call(c, **kw))
+    end
     assert_warn(/The keyword argument is passed as the last hash parameter.* for `m'/m) do
       assert_equal([h, kw], :m.to_proc.call(c, **h))
     end
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index b1ea71a..1bbe397 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -3039,7 +3039,7 @@ vm_invoke_symbol_block(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L3039
 {
     VALUE val;
     int argc;
-    CALLER_SETUP_ARG(ec->cfp, calling, ci);
+    CALLER_SETUP_ARG_WITHOUT_KW_SPLAT(ec->cfp, calling, ci);
     argc = calling->argc;
     val = vm_yield_with_symbol(ec, symbol, argc, STACK_ADDR_FROM_TOP(argc), calling->kw_splat, calling->block_handler);
     POPN(argc);
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]