blob: 218b4cad6abe6b4fdf6eb57d3f9c07f8274d078d [file] [log] [blame]
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package cycles
import "unsafe"
type (
T0 int
T1 /* ERROR cycle */ T1
T2 *T2
T3 /* ERROR cycle */ T4
T4 T5
T5 T3
T6 T7
T7 *T8
T8 T6
// arrays
A0 /* ERROR cycle */ [10]A0
A1 [10]*A1
A2 /* ERROR cycle */ [10]A3
A3 [10]A4
A4 A2
A5 [10]A6
A6 *A5
// slices
L0 []L0
// structs
S0 /* ERROR cycle */ struct{ _ S0 }
S1 /* ERROR cycle */ struct{ S1 }
S2 struct{ _ *S2 }
S3 struct{ *S3 }
S4 /* ERROR cycle */ struct{ S5 }
S5 struct{ S6 }
S6 S4
// pointers
P0 *P0
// functions
F0 func(F0)
F1 func() F1
F2 func(F2) F2
// interfaces
I0 /* ERROR cycle */ interface{ I0 }
I1 /* ERROR cycle */ interface{ I2 }
I2 interface{ I3 }
I3 interface{ I1 }
I4 interface{ f(I4) }
// testcase for issue 5090
I5 interface{ f(I6) }
I6 interface{ I5 }
// maps
M0 map[M0 /* ERROR incomparable map key */ ]M0
// channels
C0 chan C0
)
// test case for issue #34771
type (
AA /* ERROR cycle */ B
B C
C [10]D
D E
E AA
)
func _() {
type (
t1 /* ERROR cycle */ t1
t2 *t2
t3 t4 /* ERROR undeclared */
t4 t5 /* ERROR undeclared */
t5 t3
// arrays
a0 /* ERROR cycle */ [10]a0
a1 [10]*a1
// slices
l0 []l0
// structs
s0 /* ERROR cycle */ struct{ _ s0 }
s1 /* ERROR cycle */ struct{ s1 }
s2 struct{ _ *s2 }
s3 struct{ *s3 }
// pointers
p0 *p0
// functions
f0 func(f0)
f1 func() f1
f2 func(f2) f2
// interfaces
i0 /* ERROR cycle */ interface{ i0 }
// maps
m0 map[m0 /* ERROR incomparable map key */ ]m0
// channels
c0 chan c0
)
}
// test cases for issue 6667
type A [10]map[A /* ERROR incomparable map key */ ]bool
type S struct {
m map[S /* ERROR incomparable map key */ ]bool
}
// test cases for issue 7236
// (cycle detection must not be dependent on starting point of resolution)
type (
P1 *T9
T9 /* ERROR cycle */ T9
T10 /* ERROR cycle */ T10
P2 *T10
)
func (T11) m() {}
type T11 /* ERROR cycle */ struct{ T11 }
type T12 /* ERROR cycle */ struct{ T12 }
func (*T12) m() {}
type (
P3 *T13
T13 /* ERROR cycle */ T13
)
// test cases for issue 18643
// (type cycle detection when non-type expressions are involved)
type (
T14 [len(T14 /* ERROR cycle */ {})]int
T15 [][len(T15 /* ERROR cycle */ {})]int
T16 map[[len(T16 /* ERROR cycle */ {1:2})]int]int
T17 map[int][len(T17 /* ERROR cycle */ {1:2})]int
)
// Test case for types depending on function literals (see also #22992).
type T20 chan [unsafe.Sizeof(func(ch T20){ _ = <-ch })]byte
type T22 = chan [unsafe.Sizeof(func(ch T20){ _ = <-ch })]byte
func _() {
type T0 func(T0)
type T1 /* ERROR cycle */ = func(T1)
type T2 chan [unsafe.Sizeof(func(ch T2){ _ = <-ch })]byte
type T3 /* ERROR cycle */ = chan [unsafe.Sizeof(func(ch T3){ _ = <-ch })]byte
}