reflect: add support for linked lists

Linked lists are usually implemented as follows:

    type linkedList struct {
        next *linkedList
        data int // whatever
    }

This caused a stack overflow while writing out the reflect run-time type
information. This has now been fixed by splitting the allocation of a
named type number from setting the underlying type in the sidetable.
This commit is contained in:
Ayke van Laethem
2019-08-10 21:52:14 +02:00
committed by Ron Evans
parent 0818a125c0
commit ea8e4079bc
7 changed files with 128 additions and 84 deletions
+7
View File
@@ -22,6 +22,10 @@ type (
buf []byte
Buf []byte
}
linkedList struct {
next *linkedList `description:"chain"`
foo int
}
)
func main() {
@@ -103,6 +107,9 @@ func main() {
c int8
}{42, 321, 123},
mystruct{5, point{-5, 3}, struct{}{}, []byte{'G', 'o'}, []byte{'X'}},
&linkedList{
foo: 42,
},
} {
showValue(reflect.ValueOf(v), "")
}