Skip to content

Commit f55746a

Browse files
fix bug with refs at end of list
1 parent 96d0f11 commit f55746a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

pickle.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,15 @@ static void print_with_refs(pickle* vm, object* obj, object* alist, int64_t* cou
241241
for (;;) {
242242
print_with_refs(vm, car(obj), alist, counter);
243243
obj = cdr(obj);
244-
if (reffed(vm, obj, alist, counter)) break;
244+
int64_t ref = reffed(vm, obj, alist, counter);
245+
if (ref) {
246+
if (ref > 0) {
247+
// reset the ref so it will print properly
248+
cdr(assoc(alist, obj)) = vm->integer(ref);
249+
(*counter)--;
250+
}
251+
break;
252+
}
245253
if (obj && obj->type == &cons_type) putchar(' ');
246254
else break;
247255
}

0 commit comments

Comments
 (0)