summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-17 07:47:52 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-17 07:47:52 +0000
commitc2bcae864e3d8ee4265d9b125f34af9236f5cea7 (patch)
tree9ee3464f991653e6a007714c939eef29a059aae9 /proc.c
parent7d1f53e782b5340591c3788d369a2951e9707f9b (diff)
* proc.c (rb_proc_arity): return normal value (not -n-1) if it is not
a labmda, or it is a labmda and no arg_opts. [Bug #5694] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36415 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/proc.c b/proc.c
index bb7f4a1a25..9502f98772 100644
--- a/proc.c
+++ b/proc.c
@@ -630,6 +630,10 @@ rb_proc_call_with_block(VALUE self, int argc, VALUE *argv, VALUE pass_procval)
* Proc.new {|*a|}.arity #=> -1
* Proc.new {|a,*b|}.arity #=> -2
* Proc.new {|a,*b, c|}.arity #=> -3
+ * lambda { |a = 0| }.arity #=> -1
+ * lambda { |a, b = 0| }.arity #=> -2
+ * lambda { |a, b = 0, c = 0| }.arity #=> -2
+ * lambda { |(a, b), c = 0| }.arity #=> -2
*/
static VALUE
@@ -648,7 +652,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 && (!proc->is_lambda || iseq->arg_opts == 0)) {
return iseq->argc;
}
else {