ruby-changes:24360
From: marcandre <ko1@a...>
Date: Tue, 17 Jul 2012 00:19:15 +0900 (JST)
Subject: [ruby-changes:24360] marcandRe: r36411 (trunk): Revert r33924.
marcandre 2012-07-17 00:19:03 +0900 (Tue, 17 Jul 2012) New Revision: 36411 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36411 Log: Revert r33924. * 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 36410) +++ ChangeLog (revision 36411) @@ -1,3 +1,11 @@ +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 36410) +++ proc.c (revision 36411) @@ -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|}.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=42|}.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) { + if (iseq->arg_rest < 0 && iseq->arg_opts == 0) { return iseq->argc; } else { Index: test/ruby/test_proc.rb =================================================================== --- test/ruby/test_proc.rb (revision 36410) +++ test/ruby/test_proc.rb (revision 36411) @@ -68,6 +68,7 @@ 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/