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

ruby-changes:33152

From: naruse <ko1@a...>
Date: Sat, 1 Mar 2014 21:01:41 +0900 (JST)
Subject: [ruby-changes:33152] naruse:r45231 (ruby_2_1): merge revision(s) 44432: [Backport #9299]

naruse	2014-03-01 21:01:29 +0900 (Sat, 01 Mar 2014)

  New Revision: 45231

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

  Log:
    merge revision(s) 44432: [Backport #9299]
    
    * proc.c: Having optional keyword arguments makes maximum arity +1,
      not unlimited [#8072]

  Modified directories:
    branches/ruby_2_1/
  Modified files:
    branches/ruby_2_1/ChangeLog
    branches/ruby_2_1/proc.c
    branches/ruby_2_1/test/ruby/test_proc.rb
    branches/ruby_2_1/version.h
Index: ruby_2_1/ChangeLog
===================================================================
--- ruby_2_1/ChangeLog	(revision 45230)
+++ ruby_2_1/ChangeLog	(revision 45231)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/ChangeLog#L1
+Sat Mar  1 21:00:27 2014  Marc-Andre Lafortune  <ruby-core@m...>
+
+	* proc.c: Having optional keyword arguments makes maximum arity +1,
+	  not unlimited [#8072]
+
 Sat Mar  1 17:25:12 2014  Marc-Andre Lafortune  <ruby-core@m...>
 
 	* proc.c: Having any mandatory keyword argument increases min arity
Index: ruby_2_1/proc.c
===================================================================
--- ruby_2_1/proc.c	(revision 45230)
+++ ruby_2_1/proc.c	(revision 45231)
@@ -825,8 +825,9 @@ proc_arity(VALUE self) https://github.com/ruby/ruby/blob/trunk/ruby_2_1/proc.c#L825
 static inline int
 rb_iseq_min_max_arity(const rb_iseq_t *iseq, int *max)
 {
-    *max = (iseq->arg_rest == -1 && iseq->arg_keyword == -1) ?
-        iseq->argc + iseq->arg_post_len + iseq->arg_opts - (iseq->arg_opts > 0)
+    *max = iseq->arg_rest == -1 ?
+	iseq->argc + iseq->arg_post_len + iseq->arg_opts -
+	(iseq->arg_opts > 0) + (iseq->arg_keyword != -1)
       : UNLIMITED_ARGUMENTS;
     return iseq->argc + iseq->arg_post_len + (iseq->arg_keyword_required > 0);
 }
Index: ruby_2_1/version.h
===================================================================
--- ruby_2_1/version.h	(revision 45230)
+++ ruby_2_1/version.h	(revision 45231)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_1/version.h#L1
 #define RUBY_VERSION "2.1.2"
 #define RUBY_RELEASE_DATE "2014-03-01"
-#define RUBY_PATCHLEVEL 79
+#define RUBY_PATCHLEVEL 80
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_1/test/ruby/test_proc.rb
===================================================================
--- ruby_2_1/test/ruby/test_proc.rb	(revision 45230)
+++ ruby_2_1/test/ruby/test_proc.rb	(revision 45231)
@@ -77,12 +77,12 @@ class TestProc < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_1/test/ruby/test_proc.rb#L77
     assert_equal(2, proc{|(x, y), z|[x,y]}.arity)
     assert_equal(1, proc{|(x, y), z=0|[x,y]}.arity)
     assert_equal(-4, proc{|x, *y, z, a|}.arity)
-    assert_equal(-1, proc{|**|}.arity)
-    assert_equal(-1, proc{|**o|}.arity)
-    assert_equal(-2, proc{|x, **o|}.arity)
-    assert_equal(-1, proc{|x=0, **o|}.arity)
-    assert_equal(-2, proc{|x, y=0, **o|}.arity)
-    assert_equal(-3, proc{|x, y=0, z, **o|}.arity)
+    assert_equal(0, proc{|**|}.arity)
+    assert_equal(0, proc{|**o|}.arity)
+    assert_equal(1, proc{|x, **o|}.arity)
+    assert_equal(0, proc{|x=0, **o|}.arity)
+    assert_equal(1, proc{|x, y=0, **o|}.arity)
+    assert_equal(2, proc{|x, y=0, z, **o|}.arity)
     assert_equal(-3, proc{|x, y=0, *z, w, **o|}.arity)
 
     assert_equal(2, proc{|x, y=0, z, a:1|}.arity)

Property changes on: ruby_2_1
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r44432


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

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