Skip to content

Commit

Permalink
* proc.c (rb_proc_arity): Fix Proc#arity in case of optional arguments
Browse files Browse the repository at this point in the history
  [bug ruby#5694] [rubyspec:b8b259]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
marcandre committed Dec 1, 2011
1 parent b0f588f commit c6dec37
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Thu Dec 1 20:33:22 2011 Marc-Andre Lafortune <[email protected]>

* 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 <[email protected]>

* ext/socket/extconf.rb: add arguments for macro calls.
Expand Down
18 changes: 9 additions & 9 deletions proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,14 +615,14 @@ rb_proc_call_with_block(VALUE self, int argc, VALUE *argv, VALUE pass_procval)
* 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
Expand All @@ -641,7 +641,7 @@ rb_proc_arity(VALUE self)
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 {
Expand Down

0 comments on commit c6dec37

Please sign in to comment.