summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorsdottaka <[email protected]>2014-11-19 13:29:22 +0900
committersdottaka <[email protected]>2014-11-19 13:29:22 +0900
commit820f6d147fb13ade3b69eb87cfee39f85ee4a6ce (patch)
tree7527d9bb7e77b5cf96bd1800455569669ffc7b76 /src
parent4e4bfb08cbbc0198d1489004f807ba6a75469f16 (diff)
downloadmruby-820f6d147fb13ade3b69eb87cfee39f85ee4a6ce.tar.gz
mruby-820f6d147fb13ade3b69eb87cfee39f85ee4a6ce.zip
Fix an error when calling a method implemented in C by super() with arguments. This fix makes the following code workable:
Expected: class MRBTime < Time; def self.new; super(2012, 4, 21); end; end MRBTime.new # => Sat Apr 21 00:00:00 2012 Actual: class MRBTime < Time; def self.new; super(2012, 4, 21); end; end MRBTime.new # => can't convert nil into Integer (TypeError)
Diffstat (limited to 'src')
-rw-r--r--src/vm.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/vm.c b/src/vm.c
index 118efb64b..88c0f2e49 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -1250,7 +1250,12 @@ RETRY_TRY_BLOCK:
mrb->c->stack[0] = recv;
if (MRB_PROC_CFUNC_P(m)) {
- ci->nregs = 0;
+ if (n == CALL_MAXARGS) {
+ ci->nregs = 3;
+ }
+ else {
+ ci->nregs = n + 2;
+ }
mrb->c->stack[0] = m->body.func(mrb, recv);
mrb_gc_arena_restore(mrb, ai);
if (mrb->exc) goto L_RAISE;