diff options
author | Ayke van Laethem <[email protected]> | 2019-08-10 21:52:14 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2019-08-11 15:00:43 +0200 |
commit | ea8e4079bcade515fe8ca4f44326ee7f9bd4da39 (patch) | |
tree | faea284a22708d97cc30615705d270a0371304bc /testdata | |
parent | 0818a125c0d8493b325f36f3d2824d2fba8ce802 (diff) | |
download | tinygo-ea8e4079bcade515fe8ca4f44326ee7f9bd4da39.tar.gz tinygo-ea8e4079bcade515fe8ca4f44326ee7f9bd4da39.zip |
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.
Diffstat (limited to 'testdata')
-rw-r--r-- | testdata/reflect.go | 7 | ||||
-rw-r--r-- | testdata/reflect.txt | 16 |
2 files changed, 23 insertions, 0 deletions
diff --git a/testdata/reflect.go b/testdata/reflect.go index fc28b1893..314f112c3 100644 --- a/testdata/reflect.go +++ b/testdata/reflect.go @@ -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), "") } diff --git a/testdata/reflect.txt b/testdata/reflect.txt index 9a3e39777..4b17a90fc 100644 --- a/testdata/reflect.txt +++ b/testdata/reflect.txt @@ -293,6 +293,22 @@ reflect type: struct indexing: 0 reflect type: uint8 settable=true uint: 88 +reflect type: ptr + pointer: true struct + nil: false + reflect type: struct settable=true + struct: 2 + field: 0 next + tag: description:"chain" + embedded: false + reflect type: ptr + pointer: false struct + nil: true + field: 1 foo + tag: + embedded: false + reflect type: int + int: 42 sizes: int8 1 8 |