From f0eaf9eaf53ce659c44ce6beeedbeb8bfc5b4efa Mon Sep 17 00:00:00 2001 From: cremno Date: Mon, 22 Jun 2015 13:34:24 +0200 Subject: fix arity of lambdas with optional arguments From the CRuby 2.2.2 Proc#arity documentation: If the block has optional arguments, returns -n-1, where n is the number of mandatory arguments, with the exception for blocks that are not lambdas and have only a finite number of optional arguments; in this latter case, returns n. --- src/proc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/proc.c b/src/proc.c index 4cb9ffe18..61524f00c 100644 --- a/src/proc.c +++ b/src/proc.c @@ -216,7 +216,7 @@ mrb_proc_arity(mrb_state *mrb, mrb_value self) ma = MRB_ASPEC_REQ(aspec); ra = MRB_ASPEC_REST(aspec); pa = MRB_ASPEC_POST(aspec); - arity = ra ? -(ma + pa + 1) : ma + pa; + arity = ra || MRB_PROC_STRICT_P(p) ? -(ma + pa + 1) : ma + pa; return mrb_fixnum_value(arity); } -- cgit v1.2.3