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

ruby-changes:32335

From: nobu <ko1@a...>
Date: Wed, 25 Dec 2013 20:30:21 +0900 (JST)
Subject: [ruby-changes:32335] nobu:r44414 (trunk): iseq.c: fix parameter of unnamed rest keywords argument

nobu	2013-12-25 20:30:15 +0900 (Wed, 25 Dec 2013)

  New Revision: 44414

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44414

  Log:
    iseq.c: fix parameter of unnamed rest keywords argument
    
    * iseq.c (rb_iseq_parameters): push argument type symbol only for
      unnamed rest keywords argument.

  Modified files:
    trunk/ChangeLog
    trunk/iseq.c
    trunk/test/ruby/test_method.rb
    trunk/test/ruby/test_proc.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 44413)
+++ ChangeLog	(revision 44414)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Dec 25 20:30:10 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* iseq.c (rb_iseq_parameters): push argument type symbol only for
+	  unnamed rest keywords argument.
+
 Wed Dec 25 20:28:48 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* proc.c (rb_iseq_min_max_arity): maximum argument is unlimited if
Index: iseq.c
===================================================================
--- iseq.c	(revision 44413)
+++ iseq.c	(revision 44414)
@@ -2015,10 +2015,8 @@ rb_iseq_parameters(const rb_iseq_t *iseq https://github.com/ruby/ruby/blob/trunk/iseq.c#L2015
 	    }
 	    rb_ary_push(args, a);
 	}
-	if (rb_id2str(iseq->local_table[iseq->arg_keyword])) {
-	    CONST_ID(keyrest, "keyrest");
-	    rb_ary_push(args, PARAM(iseq->arg_keyword, keyrest));
-	}
+	CONST_ID(keyrest, "keyrest");
+	rb_ary_push(args, PARAM(iseq->arg_keyword, keyrest));
     }
     if (iseq->arg_block != -1) {
 	CONST_ID(block, "block");
Index: test/ruby/test_proc.rb
===================================================================
--- test/ruby/test_proc.rb	(revision 44413)
+++ test/ruby/test_proc.rb	(revision 44414)
@@ -1104,6 +1104,13 @@ class TestProc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_proc.rb#L1104
   def pmo6(a, *b, c, &d) end
   def pmo7(a, b = :b, *c, d, &e) end
   def pma1((a), &b) a; end
+  def pmk1(**) end
+  def pmk2(**o) nil && o end
+  def pmk3(a, **o) nil && o end
+  def pmk4(a = nil, **o) nil && o end
+  def pmk5(a, b = nil, **o) nil && o end
+  def pmk6(a, b = nil, c, **o) nil && o end
+  def pmk7(a, b = nil, *c, d, **o) nil && o end
 
 
   def test_bound_parameters
@@ -1118,6 +1125,13 @@ class TestProc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_proc.rb#L1125
     assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], method(:pmo6).to_proc.parameters)
     assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], method(:pmo7).to_proc.parameters)
     assert_equal([[:req], [:block, :b]], method(:pma1).to_proc.parameters)
+    assert_equal([[:keyrest]], method(:pmk1).to_proc.parameters)
+    assert_equal([[:keyrest, :o]], method(:pmk2).to_proc.parameters)
+    assert_equal([[:req, :a], [:keyrest, :o]], method(:pmk3).to_proc.parameters)
+    assert_equal([[:opt, :a], [:keyrest, :o]], method(:pmk4).to_proc.parameters)
+    assert_equal([[:req, :a], [:opt, :b], [:keyrest, :o]], method(:pmk5).to_proc.parameters)
+    assert_equal([[:req, :a], [:opt, :b], [:req, :c], [:keyrest, :o]], method(:pmk6).to_proc.parameters)
+    assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], method(:pmk7).to_proc.parameters)
 
     assert_equal([], "".method(:upcase).to_proc.parameters)
     assert_equal([[:rest]], "".method(:gsub).to_proc.parameters)
Index: test/ruby/test_method.rb
===================================================================
--- test/ruby/test_method.rb	(revision 44413)
+++ test/ruby/test_method.rb	(revision 44414)
@@ -491,6 +491,13 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L491
     assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], method(:mo6).parameters)
     assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], method(:mo7).parameters)
     assert_equal([[:req], [:block, :b]], method(:ma1).parameters)
+    assert_equal([[:keyrest]], method(:mk1).parameters)
+    assert_equal([[:keyrest, :o]], method(:mk2).parameters)
+    assert_equal([[:req, :a], [:keyrest, :o]], method(:mk3).parameters)
+    assert_equal([[:opt, :a], [:keyrest, :o]], method(:mk4).parameters)
+    assert_equal([[:req, :a], [:opt, :b], [:keyrest, :o]], method(:mk5).parameters)
+    assert_equal([[:req, :a], [:opt, :b], [:req, :c], [:keyrest, :o]], method(:mk6).parameters)
+    assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], method(:mk7).parameters)
   end
 
   def test_unbound_parameters
@@ -505,6 +512,13 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L512
     assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], self.class.instance_method(:mo6).parameters)
     assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], self.class.instance_method(:mo7).parameters)
     assert_equal([[:req], [:block, :b]], self.class.instance_method(:ma1).parameters)
+    assert_equal([[:keyrest]], self.class.instance_method(:mk1).parameters)
+    assert_equal([[:keyrest, :o]], self.class.instance_method(:mk2).parameters)
+    assert_equal([[:req, :a], [:keyrest, :o]], self.class.instance_method(:mk3).parameters)
+    assert_equal([[:opt, :a], [:keyrest, :o]], self.class.instance_method(:mk4).parameters)
+    assert_equal([[:req, :a], [:opt, :b], [:keyrest, :o]], self.class.instance_method(:mk5).parameters)
+    assert_equal([[:req, :a], [:opt, :b], [:req, :c], [:keyrest, :o]], self.class.instance_method(:mk6).parameters)
+    assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], self.class.instance_method(:mk7).parameters)
   end
 
   def test_bmethod_bound_parameters
@@ -519,6 +533,13 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L533
     assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], method(:pmo6).parameters)
     assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], method(:pmo7).parameters)
     assert_equal([[:req], [:block, :b]], method(:pma1).parameters)
+    assert_equal([[:keyrest]], method(:pmk1).parameters)
+    assert_equal([[:keyrest, :o]], method(:pmk2).parameters)
+    assert_equal([[:req, :a], [:keyrest, :o]], method(:pmk3).parameters)
+    assert_equal([[:opt, :a], [:keyrest, :o]], method(:pmk4).parameters)
+    assert_equal([[:req, :a], [:opt, :b], [:keyrest, :o]], method(:pmk5).parameters)
+    assert_equal([[:req, :a], [:opt, :b], [:req, :c], [:keyrest, :o]], method(:pmk6).parameters)
+    assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], method(:pmk7).parameters)
   end
 
   def test_bmethod_unbound_parameters
@@ -533,6 +554,14 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L554
     assert_equal([[:req, :a], [:rest, :b], [:req, :c], [:block, :d]], self.class.instance_method(:pmo6).parameters)
     assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], self.class.instance_method(:pmo7).parameters)
     assert_equal([[:req], [:block, :b]], self.class.instance_method(:pma1).parameters)
+    assert_equal([[:req], [:block, :b]], self.class.instance_method(:pma1).parameters)
+    assert_equal([[:keyrest]], self.class.instance_method(:pmk1).parameters)
+    assert_equal([[:keyrest, :o]], self.class.instance_method(:pmk2).parameters)
+    assert_equal([[:req, :a], [:keyrest, :o]], self.class.instance_method(:pmk3).parameters)
+    assert_equal([[:opt, :a], [:keyrest, :o]], self.class.instance_method(:pmk4).parameters)
+    assert_equal([[:req, :a], [:opt, :b], [:keyrest, :o]], self.class.instance_method(:pmk5).parameters)
+    assert_equal([[:req, :a], [:opt, :b], [:req, :c], [:keyrest, :o]], self.class.instance_method(:pmk6).parameters)
+    assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:keyrest, :o]], self.class.instance_method(:pmk7).parameters)
   end
 
   def test_public_method_with_zsuper_method

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

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