mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
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.
This commit is contained in:
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user