summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-01 22:46:32 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-01 22:46:32 +0000
commitf810d1804a7e1c2dbdb2d4d6c0406674a1912ea3 (patch)
tree42fa784f7c89431e8e563cf48495d06c52f40e26 /proc.c
parent83610815d4ec34b3d5528aa8dbc6c4a475c7ed92 (diff)
* proc.c (proc_curry): Fix arity check [Bug #5747]
* test/ruby/test_proc.rb: Test for above git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/proc.c b/proc.c
index b2c2b70b0e..07c43dfe00 100644
--- a/proc.c
+++ b/proc.c
@@ -2163,22 +2163,17 @@ curry(VALUE dummy, VALUE args, int argc, VALUE *argv, VALUE passed_proc)
static VALUE
proc_curry(int argc, VALUE *argv, VALUE self)
{
- int sarity, marity = rb_proc_arity(self);
- VALUE arity, opt = Qfalse;
-
- if (marity < 0) {
- marity = -marity - 1;
- opt = Qtrue;
- }
+ int sarity, max_arity, min_arity = rb_proc_min_max_arity(self, &max_arity);
+ VALUE arity;
rb_scan_args(argc, argv, "01", &arity);
if (NIL_P(arity)) {
- arity = INT2FIX(marity);
+ arity = INT2FIX(min_arity);
}
else {
sarity = FIX2INT(arity);
- if (rb_proc_lambda_p(self) && (sarity < marity || (sarity > marity && !opt))) {
- rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)", sarity, marity);
+ if (rb_proc_lambda_p(self)) {
+ rb_check_arity(sarity, min_arity, max_arity);
}
}