ruby-changes:21872
From: marcandre <ko1@a...>
Date: Thu, 1 Dec 2011 20:46:41 +0900 (JST)
Subject: [ruby-changes:21872] marcandRe: r33921 (trunk): * proc.c (rb_proc_arity): Fix Proc#arity in case of optional arguments
marcandre 2011-12-01 20:46:31 +0900 (Thu, 01 Dec 2011) New Revision: 33921 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33921 Log: * proc.c (rb_proc_arity): Fix Proc#arity in case of optional arguments [bug #5694] [rubyspec:b8b259] Modified files: trunk/ChangeLog trunk/proc.c Index: ChangeLog =================================================================== --- ChangeLog (revision 33920) +++ ChangeLog (revision 33921) @@ -1,3 +1,8 @@ +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 33920) +++ proc.c (revision 33921) @@ -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|}.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 @@ -641,7 +641,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 { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/