diff --git a/src/vm.c b/src/vm.c index ce5fbcde..720cf119 100644 --- a/src/vm.c +++ b/src/vm.c @@ -525,6 +525,16 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv) } PUSH(rest); } + /* prepare local variable area */ + if (proc->u.irep->localc > 0) { + int l = proc->u.irep->localc; + if (proc->u.irep->varg) { + --l; + } + for (i = 0; i < l; ++i) { + PUSH(pic_undef_value()); + } + } /* prepare env */ if (proc->u.irep->cv_num == 0) { @@ -540,15 +550,6 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv) } } - /* prepare local variable area */ - if (proc->u.irep->localc > 0) { - int l = proc->u.irep->localc; - if (proc->u.irep->varg) { - --l; - } - pic->sp += l; - } - pc = proc->u.irep->code; pic_gc_arena_restore(pic, ai); JUMP;