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

ruby-changes:21875

From: naruse <ko1@a...>
Date: Fri, 2 Dec 2011 07:15:11 +0900 (JST)
Subject: [ruby-changes:21875] naruse:r33924 (trunk): Revert r33921.

naruse	2011-12-02 07:14:45 +0900 (Fri, 02 Dec 2011)

  New Revision: 33924

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

  Log:
    Revert r33921.
    
    Revert "* proc.c (rb_proc_arity): Fix Proc#arity in case of optional arguments"
    Because following two reason:
    * Proc#arity's return value with optional arguments is not clear.
      The optional argument for proc/lambda is Ruby 1.9 feature.
      In 1.9, proc(a, b=1){} can receive 1 or more arguments.
      But lambda(a, b=1){} can receive only 1 or two arguments.
      r33921 breaks lambda's arity.
      The spec arround optional arguments of proc/lambda needs more
      discussion.
    
    * No tests.
      Add tests to test-all.

  Modified files:
    trunk/ChangeLog
    trunk/proc.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 33923)
+++ ChangeLog	(revision 33924)
@@ -7,11 +7,6 @@
 
 	* io.c (linux_get_maxfd): change local variable name.
 
-Thu Dec  1 20:33:22 2011  Marc-Andre Lafortune  <ruby-core@m...>
-
-	* proc.c (rb_proc_arity): Fix Proc#arity in case of optional
-	  arguments. [bug #5694] [rubyspec:b8b259]
-
 Thu Dec  1 16:59:24 2011  Nobuyoshi Nakada  <nobu@r...>
 
 	* ext/socket/extconf.rb: add arguments for macro calls.
Index: proc.c
===================================================================
--- proc.c	(revision 33923)
+++ proc.c	(revision 33924)
@@ -615,14 +615,14 @@
  *  arguments. A <code>proc</code> with no argument declarations
  *  is the same a block declaring <code>||</code> as its arguments.
  *
- *     Proc.new {}.arity             #=>  0
- *     Proc.new {||}.arity           #=>  0
- *     Proc.new {|a|}.arity          #=>  1
- *     Proc.new {|a, b|}.arity       #=>  2
- *     Proc.new {|a, b, c|}.arity    #=>  3
- *     Proc.new {|*a|}.arity         #=> -1
- *     Proc.new {|a, b=42|}.arity    #=> -2
- *     Proc.new {|a, *b, c|}.arity   #=> -3
+ *     Proc.new {}.arity          #=>  0
+ *     Proc.new {||}.arity        #=>  0
+ *     Proc.new {|a|}.arity       #=>  1
+ *     Proc.new {|a,b|}.arity     #=>  2
+ *     Proc.new {|a,b,c|}.arity   #=>  3
+ *     Proc.new {|*a|}.arity      #=> -1
+ *     Proc.new {|a,*b|}.arity    #=> -2
+ *     Proc.new {|a,*b, c|}.arity    #=> -3
  */
 
 static VALUE
@@ -641,7 +641,7 @@
     iseq = proc->block.iseq;
     if (iseq) {
 	if (BUILTIN_TYPE(iseq) != T_NODE) {
-	    if (iseq->arg_rest < 0 && iseq->arg_opts == 0) {
+	    if (iseq->arg_rest < 0) {
 		return iseq->argc;
 	    }
 	    else {

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

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