Push instance to the VM in case of a GC
@@ -118,10 +118,12 @@ ObjInstance *newInstance(DictuVM *vm, ObjClass *klass) {
initTable(&instance->publicFields);
initTable(&instance->privateFields);
+ push(vm, OBJ_VAL(instance));
ObjString *classString = copyString(vm, "_class", 6);
push(vm, OBJ_VAL(classString));
tableSet(vm, &instance->publicFields, classString, OBJ_VAL(klass));
pop(vm);
+ pop(vm);
return instance;
}
