ruby-changes:24362
From: marcandre <ko1@a...>
Date: Tue, 17 Jul 2012 00:28:47 +0900 (JST)
Subject: [ruby-changes:24362] marcandRe: r36413 (trunk): Revert of r36411, as does not distinguish proc from lambda
marcandre 2012-07-17 00:28:34 +0900 (Tue, 17 Jul 2012) New Revision: 36413 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36413 Log: Revert of r36411, as does not distinguish proc from lambda * proc.c (rb_proc_arity): Fix Proc#arity in case of optional arguments [bug #5694] [rubyspec:b8b259] [rubyspec:184c8100f] Modified files: trunk/ChangeLog trunk/proc.c trunk/test/ruby/test_proc.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 36412) +++ ChangeLog (revision 36413) @@ -1,11 +1,3 @@ -Tue Jul 17 00:18:41 2012 Marc-Andre Lafortune <ruby-core@m...> - - Revert r33924. - - * proc.c (rb_proc_arity): Fix Proc#arity in case of optional - arguments - [bug #5694] [rubyspec:b8b259] [rubyspec:184c8100f] - Mon Jul 16 23:20:24 2012 Tanaka Akira <akr@f...> * bignum.c (rb_integer_float_cmp): use FIXNUM_MIN and FIXNUM_MAX, Index: proc.c =================================================================== --- proc.c (revision 36412) +++ proc.c (revision 36413) @@ -622,14 +622,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 @@ -648,7 +648,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 { Index: test/ruby/test_proc.rb =================================================================== --- test/ruby/test_proc.rb (revision 36412) +++ test/ruby/test_proc.rb (revision 36413) @@ -68,7 +68,6 @@ assert_equal(-1, proc{|*|}.arity) assert_equal(-3, proc{|x, *y, z|}.arity) assert_equal(-4, proc{|x, *y, z, a|}.arity) - assert_equal(-1, ->(a=42){}.arity) assert_arity(0) {} assert_arity(0) {||} -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/