blob: 71e5b406439f02539b51d61f5ca59020d8ab3949 [file] [log] [blame]
Russ Cox565b5dc2010-06-08 18:50:02 -07001// errchk $G -e $D/$F.go
2
3// Copyright 2009 The Go Authors. All rights reserved.
4// Use of this source code is governed by a BSD-style
5// license that can be found in the LICENSE file.
6
7package main
8
9type (
10 A [10]int
11 B []int
12 C chan int
13 F func() int
14 I interface {
15 m() int
16 }
17 M map[int]int
18 P *int
19 S struct {
20 X int
21 }
22
23 A1 [10]int
24 B1 []int
25 C1 chan int
26 F1 func() int
27 I1 interface {
28 m() int
29 }
30 M1 map[int]int
31 P1 *int
32 S1 struct {
33 X int
34 }
35)
36
37var (
38 a0 [10]int
39 b0 []int
40 c0 chan int
41 f0 func() int
42 i0 interface {
43 m() int
44 }
45 m0 map[int]int
46 p0 *int
47 s0 struct {
48 X int
49 }
50
51 a A
52 b B
53 c C
54 f F
55 i I
56 m M
57 p P
58 s S
59
60 a1 A1
61 b1 B1
62 c1 C1
63 f1 F1
64 i1 I1
65 m1 M1
66 p1 P1
67 s1 S1
68
69 pa0 *[10]int
70 pb0 *[]int
71 pc0 *chan int
72 pf0 *func() int
73 pi0 *interface {
74 m() int
75 }
76 pm0 *map[int]int
77 pp0 **int
78 ps0 *struct {
79 X int
80 }
81
82 pa *A
83 pb *B
84 pc *C
85 pf *F
86 pi *I
87 pm *M
88 pp *P
89 ps *S
90
91 pa1 *A1
92 pb1 *B1
93 pc1 *C1
94 pf1 *F1
95 pi1 *I1
96 pm1 *M1
97 pp1 *P1
98 ps1 *S1
99)
100
101func main() {
102 a0 = a
103 a0 = a1
104 a = a0
105 a = a1 // ERROR "cannot use"
106 a1 = a0
107 a1 = a // ERROR "cannot use"
108
109 b0 = b
110 b0 = b1
111 b = b0
112 b = b1 // ERROR "cannot use"
113 b1 = b0
114 b1 = b // ERROR "cannot use"
115
116 c0 = c
117 c0 = c1
118 c = c0
119 c = c1 // ERROR "cannot use"
120 c1 = c0
121 c1 = c // ERROR "cannot use"
122
123 f0 = f
124 f0 = f1
125 f = f0
126 f = f1 // ERROR "cannot use"
127 f1 = f0
128 f1 = f // ERROR "cannot use"
129
130 i0 = i
131 i0 = i1
132 i = i0
133 i = i1
134 i1 = i0
135 i1 = i
136
137 m0 = m
138 m0 = m1
139 m = m0
140 m = m1 // ERROR "cannot use"
141 m1 = m0
142 m1 = m // ERROR "cannot use"
143
144 p0 = p
145 p0 = p1
146 p = p0
147 p = p1 // ERROR "cannot use"
148 p1 = p0
149 p1 = p // ERROR "cannot use"
150
151 s0 = s
152 s0 = s1
153 s = s0
154 s = s1 // ERROR "cannot use"
155 s1 = s0
156 s1 = s // ERROR "cannot use"
157
Ian Lance Taylor8d0265d2010-09-10 19:12:10 -0700158 pa0 = pa // ERROR "cannot use|incompatible"
159 pa0 = pa1 // ERROR "cannot use|incompatible"
160 pa = pa0 // ERROR "cannot use|incompatible"
161 pa = pa1 // ERROR "cannot use|incompatible"
162 pa1 = pa0 // ERROR "cannot use|incompatible"
163 pa1 = pa // ERROR "cannot use|incompatible"
Russ Cox565b5dc2010-06-08 18:50:02 -0700164
Ian Lance Taylor8d0265d2010-09-10 19:12:10 -0700165 pb0 = pb // ERROR "cannot use|incompatible"
166 pb0 = pb1 // ERROR "cannot use|incompatible"
167 pb = pb0 // ERROR "cannot use|incompatible"
168 pb = pb1 // ERROR "cannot use|incompatible"
169 pb1 = pb0 // ERROR "cannot use|incompatible"
170 pb1 = pb // ERROR "cannot use|incompatible"
Russ Cox565b5dc2010-06-08 18:50:02 -0700171
Ian Lance Taylor8d0265d2010-09-10 19:12:10 -0700172 pc0 = pc // ERROR "cannot use|incompatible"
173 pc0 = pc1 // ERROR "cannot use|incompatible"
174 pc = pc0 // ERROR "cannot use|incompatible"
175 pc = pc1 // ERROR "cannot use|incompatible"
176 pc1 = pc0 // ERROR "cannot use|incompatible"
177 pc1 = pc // ERROR "cannot use|incompatible"
Russ Cox565b5dc2010-06-08 18:50:02 -0700178
Ian Lance Taylor8d0265d2010-09-10 19:12:10 -0700179 pf0 = pf // ERROR "cannot use|incompatible"
180 pf0 = pf1 // ERROR "cannot use|incompatible"
181 pf = pf0 // ERROR "cannot use|incompatible"
182 pf = pf1 // ERROR "cannot use|incompatible"
183 pf1 = pf0 // ERROR "cannot use|incompatible"
184 pf1 = pf // ERROR "cannot use|incompatible"
Russ Cox565b5dc2010-06-08 18:50:02 -0700185
Ian Lance Taylor8d0265d2010-09-10 19:12:10 -0700186 pi0 = pi // ERROR "cannot use|incompatible"
187 pi0 = pi1 // ERROR "cannot use|incompatible"
188 pi = pi0 // ERROR "cannot use|incompatible"
189 pi = pi1 // ERROR "cannot use|incompatible"
190 pi1 = pi0 // ERROR "cannot use|incompatible"
191 pi1 = pi // ERROR "cannot use|incompatible"
Russ Cox565b5dc2010-06-08 18:50:02 -0700192
Ian Lance Taylor8d0265d2010-09-10 19:12:10 -0700193 pm0 = pm // ERROR "cannot use|incompatible"
194 pm0 = pm1 // ERROR "cannot use|incompatible"
195 pm = pm0 // ERROR "cannot use|incompatible"
196 pm = pm1 // ERROR "cannot use|incompatible"
197 pm1 = pm0 // ERROR "cannot use|incompatible"
198 pm1 = pm // ERROR "cannot use|incompatible"
Russ Cox565b5dc2010-06-08 18:50:02 -0700199
Ian Lance Taylor8d0265d2010-09-10 19:12:10 -0700200 pp0 = pp // ERROR "cannot use|incompatible"
201 pp0 = pp1 // ERROR "cannot use|incompatible"
202 pp = pp0 // ERROR "cannot use|incompatible"
203 pp = pp1 // ERROR "cannot use|incompatible"
204 pp1 = pp0 // ERROR "cannot use|incompatible"
205 pp1 = pp // ERROR "cannot use|incompatible"
Russ Cox565b5dc2010-06-08 18:50:02 -0700206
Ian Lance Taylor8d0265d2010-09-10 19:12:10 -0700207 ps0 = ps // ERROR "cannot use|incompatible"
208 ps0 = ps1 // ERROR "cannot use|incompatible"
209 ps = ps0 // ERROR "cannot use|incompatible"
210 ps = ps1 // ERROR "cannot use|incompatible"
211 ps1 = ps0 // ERROR "cannot use|incompatible"
212 ps1 = ps // ERROR "cannot use|incompatible"
Russ Cox565b5dc2010-06-08 18:50:02 -0700213
214
215 a0 = [10]int(a)
216 a0 = [10]int(a1)
217 a = A(a0)
218 a = A(a1)
219 a1 = A1(a0)
220 a1 = A1(a)
221
222 b0 = []int(b)
223 b0 = []int(b1)
224 b = B(b0)
225 b = B(b1)
226 b1 = B1(b0)
227 b1 = B1(b)
228
229 c0 = chan int(c)
230 c0 = chan int(c1)
231 c = C(c0)
232 c = C(c1)
233 c1 = C1(c0)
234 c1 = C1(c)
235
236 f0 = func() int(f)
237 f0 = func() int(f1)
238 f = F(f0)
239 f = F(f1)
240 f1 = F1(f0)
241 f1 = F1(f)
242
243 i0 = interface {
244 m() int
245 }(i)
246 i0 = interface {
247 m() int
248 }(i1)
249 i = I(i0)
250 i = I(i1)
251 i1 = I1(i0)
252 i1 = I1(i)
253
254 m0 = map[int]int(m)
255 m0 = map[int]int(m1)
256 m = M(m0)
257 m = M(m1)
258 m1 = M1(m0)
259 m1 = M1(m)
260
261 p0 = (*int)(p)
262 p0 = (*int)(p1)
263 p = P(p0)
264 p = P(p1)
265 p1 = P1(p0)
266 p1 = P1(p)
267
268 s0 = struct {
269 X int
270 }(s)
271 s0 = struct {
272 X int
273 }(s1)
274 s = S(s0)
275 s = S(s1)
276 s1 = S1(s0)
277 s1 = S1(s)
278
279 pa0 = (*[10]int)(pa)
280 pa0 = (*[10]int)(pa1)
281 pa = (*A)(pa0)
282 pa = (*A)(pa1)
283 pa1 = (*A1)(pa0)
284 pa1 = (*A1)(pa)
285
286 pb0 = (*[]int)(pb)
287 pb0 = (*[]int)(pb1)
288 pb = (*B)(pb0)
289 pb = (*B)(pb1)
290 pb1 = (*B1)(pb0)
291 pb1 = (*B1)(pb)
292
293 pc0 = (*chan int)(pc)
294 pc0 = (*chan int)(pc1)
295 pc = (*C)(pc0)
296 pc = (*C)(pc1)
297 pc1 = (*C1)(pc0)
298 pc1 = (*C1)(pc)
299
300 pf0 = (*func() int)(pf)
301 pf0 = (*func() int)(pf1)
302 pf = (*F)(pf0)
303 pf = (*F)(pf1)
304 pf1 = (*F1)(pf0)
305 pf1 = (*F1)(pf)
306
307 pi0 = (*interface {
308 m() int
309 })(pi)
310 pi0 = (*interface {
311 m() int
312 })(pi1)
313 pi = (*I)(pi0)
314 pi = (*I)(pi1)
315 pi1 = (*I1)(pi0)
316 pi1 = (*I1)(pi)
317
318 pm0 = (*map[int]int)(pm)
319 pm0 = (*map[int]int)(pm1)
320 pm = (*M)(pm0)
321 pm = (*M)(pm1)
322 pm1 = (*M1)(pm0)
323 pm1 = (*M1)(pm)
324
325 pp0 = (**int)(pp)
326 pp0 = (**int)(pp1)
327 pp = (*P)(pp0)
328 pp = (*P)(pp1)
329 pp1 = (*P1)(pp0)
330 pp1 = (*P1)(pp)
331
332 ps0 = (*struct {
333 X int
334 })(ps)
335 ps0 = (*struct {
336 X int
337 })(ps1)
338 ps = (*S)(ps0)
339 ps = (*S)(ps1)
340 ps1 = (*S1)(ps0)
341 ps1 = (*S1)(ps)
342
343}