[bugfix] local variables should be initialized before copied to env object
This commit is contained in:
parent
737f916a8c
commit
5668ae1b29
19
src/vm.c
19
src/vm.c
|
@ -525,6 +525,16 @@ pic_apply(pic_state *pic, struct pic_proc *proc, pic_value argv)
|
||||||
}
|
}
|
||||||
PUSH(rest);
|
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 */
|
/* prepare env */
|
||||||
if (proc->u.irep->cv_num == 0) {
|
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;
|
pc = proc->u.irep->code;
|
||||||
pic_gc_arena_restore(pic, ai);
|
pic_gc_arena_restore(pic, ai);
|
||||||
JUMP;
|
JUMP;
|
||||||
|
|
Loading…
Reference in New Issue