summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-05-01 05:01:15 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-05-01 05:01:15 +0000
commitf80841275d23122872e528f75f975270cb7b1624 (patch)
tree3cfc99b0ad4f7df4443fcbab54ae4dbcfbf5f275 /proc.c
parent75d28f887089c8582b63a64cf5df1d0270f15cc1 (diff)
* proc.c (proc_arity): fix an arity bug ([ruby-core:11060]).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/proc.c b/proc.c
index 66eebec8ab..d11f486e38 100644
--- a/proc.c
+++ b/proc.c
@@ -443,17 +443,24 @@ proc_arity(VALUE self)
rb_iseq_t *iseq;
GetProcPtr(self, proc);
iseq = proc->block.iseq;
- if (iseq && BUILTIN_TYPE(iseq) != T_NODE) {
- if (iseq->arg_rest < 0) {
- return INT2FIX(iseq->argc);
+ if (iseq) {
+ if (BUILTIN_TYPE(iseq) != T_NODE) {
+ if (iseq->arg_rest < 0) {
+ return INT2FIX(iseq->argc);
+ }
+ else {
+ return INT2FIX(-(iseq->argc + 1 + iseq->arg_post_len));
+ }
}
else {
- return INT2FIX(-(iseq->argc + 1 + iseq->arg_post_len));
+ NODE *node = (NODE *)iseq;
+ if (nd_type(node) == NODE_IFUNC && node->nd_cfnc == bmcall) {
+ /* method(:foo).to_proc.arity */
+ return INT2FIX(method_arity(node->nd_tval));
+ }
}
}
- else {
- return INT2FIX(-1);
- }
+ return INT2FIX(-1);
}
int