spew fails to detect cycles in []interface{} values
kortschak opened this issue · 6 comments
kortschak commented
Reproducer:
package main
import "github.com/davecgh/go-spew/spew"
func main() {
r := make([]interface{}, 1)
r[0] = r
spew.Dump(r)
}
See kortschak#5
kortschak commented
Fix for the slice case at kortschak#7.
davecgh commented
Nice find! I'll take at a look at the proposed fix and get this updated accordingly.
Fixing this should also fix #44.
kortschak commented
Note that it doesn't fix the `type t map[T]t` case. I need to spend some more time thinking on that one.
davecgh commented
I suspect that interface pointers in general will need to be saved since it could really happen with any compound data structure that contains an interface due to them really just being a reference.
kortschak commented
It can only happen with pointer or pointer-like types. So for example, you do not get the effect with type T struct { F interface{} }; v := T{}; v.F = v
. So this means it's just limited to maps, slices and pointers. I have a partial fix for maps, but it need mores work.
kortschak commented
Here is a fix for maps kortschak#8.