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

ruby-changes:59599

From: Nobuyoshi <ko1@a...>
Date: Thu, 2 Jan 2020 10:55:56 +0900 (JST)
Subject: [ruby-changes:59599] 34bc15c86b (master): Check Module#ruby2_keywords arity

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

From 34bc15c86b764e8fdd11d9af8ad3dc401f24b5c4 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Thu, 2 Jan 2020 10:06:16 +0900
Subject: Check Module#ruby2_keywords arity

It is considered a mistake, because calling this method with no
arguments has no effect.

diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb
index bbf3953..c3a3a45 100644
--- a/test/ruby/test_keyword.rb
+++ b/test/ruby/test_keyword.rb
@@ -2724,6 +2724,12 @@ class TestKeywordArguments < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L2724
   end
 
   def test_ruby2_keywords
+    assert_raise(ArgumentError) do
+      Class.new do
+        ruby2_keywords
+      end
+    end
+
     c = Class.new do
       ruby2_keywords def foo(meth, *args)
         send(meth, *args)
diff --git a/vm_method.c b/vm_method.c
index 4504468..877198c 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -1811,6 +1811,7 @@ rb_mod_ruby2_keywords(int argc, VALUE *argv, VALUE module) https://github.com/ruby/ruby/blob/trunk/vm_method.c#L1811
     int i;
     VALUE origin_class = RCLASS_ORIGIN(module);
 
+    rb_check_arity(argc, 1, UNLIMITED_ARGUMENTS);
     rb_check_frozen(module);
 
     for (i = 0; i < argc; i++) {
-- 
cgit v0.10.2


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

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