tinygo/testdata/slice.txt
Ayke van Laethem 5b42871baa compiler: support all kinds of recursive types
Previously we only supported recursive types in structs. But there can
be other kinds of recursive types, like slices:

    type RecursiveSlice []RecursiveSlice

This doesn't involve structs, so it led to infinite recursion in the
compiler. This fix avoids recursion at the proper level: at the place
where the named type is defined.
2023-03-18 17:53:47 +01:00

19 строки
565 Б
Text

foo is nil? false false
foo: len=4 cap=4 data: 1 2 4 5
bar: len=3 cap=5 data: 0 0 0
foo[1:2]: len=1 cap=3 data: 2
sum foo: 12
copy foo -> bar: 3
bar: len=3 cap=5 data: 1 2 4
slice is nil? true true
grow: len=0 cap=0 data:
grow: len=1 cap=1 data: 42
grow: len=3 cap=4 data: 42 -1 -2
grow: len=7 cap=8 data: 42 -1 -2 1 2 4 5
grow: len=7 cap=8 data: 42 -1 -2 1 2 4 5
grow: len=14 cap=16 data: 42 -1 -2 1 2 4 5 42 -1 -2 1 2 4 5
bytes: len=6 cap=6 data: 1 2 3 102 111 111
slice to array pointer: 1 -2 20 4
unsafe.Add array: 1 5 8 4
unsafe.Slice array: 3 3 9 15 4
len: 0