stackitem: properly detect recursive references during serialization

If we're done with element it no longer can lead to recursion error, so fix
cases like `[arr, arr]` where we have two copies of `arr` trigger this error
for no good reason (there is no recursion there).
This commit is contained in:
Roman Khimov 2021-07-06 17:10:31 +03:00
parent ae8f4ebd5e
commit 6879cbcdcc
2 changed files with 4 additions and 0 deletions

View file

@ -241,6 +241,7 @@ func toJSONWithTypes(item Item, seen map[Item]bool) (interface{}, error) {
arr = append(arr, s)
}
value = arr
delete(seen, item)
case *Bool:
value = it.value
case *Buffer, *ByteArray:
@ -266,6 +267,7 @@ func toJSONWithTypes(item Item, seen map[Item]bool) (interface{}, error) {
})
}
value = arr
delete(seen, item)
case *Pointer:
value = it.pos
}