aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/go/types/testdata/cycles.src
blob: 621d83c9450a03f7823a657e0b01a96a0dc098b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// 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

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 interface{ I2 }
	I2 interface{ I3 }
	I3 /* ERROR cycle */ interface{ I1 }

	I4 interface{ f(I4) }

	// testcase for issue 5090
	I5 interface{ f(I6) }
	I6 interface{ I5 }

	// maps
	M0 map[M0 /* ERROR invalid map key */ ]M0

	// channels
	C0 chan C0
)

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 invalid map key */ ]m0

		// channels
		c0 chan c0
	)
}

// test cases for issue 6667

type A [10]map[A /* ERROR invalid map key */ ]bool

type S struct {
	m map[S /* ERROR invalid 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
)