3 // Copyright 2016 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.
7 // Test various valid and invalid struct assignments and conversions.
16 // conversions between structs
25 s = t // ERROR "cannot use .* in assignment|incompatible type"
35 type S struct{ x int }
45 s = t // ERROR "cannot use .* in assignment|incompatible type"
46 s = u // ERROR "cannot use .* in assignment|incompatible type"
50 t = u // ERROR "cannot use .* in assignment|incompatible type"
55 type E struct{ x int }
66 s = t // ERROR "cannot use .* in assignment|incompatible type"
67 s = u // ERROR "cannot use .* in assignment|incompatible type"
71 t = u // ERROR "cannot use .* in assignment|incompatible type"
94 s = t // ERROR "cannot use .* in assignment|incompatible type"
95 s = u // ERROR "cannot use .* in assignment|incompatible type"
99 t = u // ERROR "cannot use .* in assignment|incompatible type"
110 type S struct{ x E1 }
120 s = t // ERROR "cannot use .* in assignment|incompatible type"
121 s = u // ERROR "cannot use .* in assignment|incompatible type"
123 s = S(t) // ERROR "cannot convert"
124 s = S(u) // ERROR "cannot convert"
125 t = u // ERROR "cannot use .* in assignment|incompatible type"
130 type E struct{ x int }
143 var u struct{ f func(E) }
145 s = t // ERROR "cannot use .* in assignment|incompatible type"
146 s = u // ERROR "cannot use .* in assignment|incompatible type"
149 s = S(u) // ERROR "cannot convert"
150 t = u // ERROR "cannot use .* in assignment|incompatible type"
151 t = T(u) // ERROR "cannot convert"
154 // conversions between pointers to structs
163 s = t // ERROR "cannot use .* in assignment|incompatible type"
164 s = u // ERROR "cannot use .* in assignment|incompatible type"
168 t = u // ERROR "cannot use .* in assignment|incompatible type"
173 type S struct{ x int }
183 s = t // ERROR "cannot use .* in assignment|incompatible type"
184 s = u // ERROR "cannot use .* in assignment|incompatible type"
188 t = u // ERROR "cannot use .* in assignment|incompatible type"
193 type E struct{ x int }
204 s = t // ERROR "cannot use .* in assignment|incompatible type"
205 s = u // ERROR "cannot use .* in assignment|incompatible type"
209 t = u // ERROR "cannot use .* in assignment|incompatible type"
232 s = t // ERROR "cannot use .* in assignment|incompatible type"
233 s = u // ERROR "cannot use .* in assignment|incompatible type"
237 t = u // ERROR "cannot use .* in assignment|incompatible type"
248 type S struct{ x E1 }
258 s = t // ERROR "cannot use .* in assignment|incompatible type"
259 s = u // ERROR "cannot use .* in assignment|incompatible type"
261 s = (*S)(t) // ERROR "cannot convert"
262 s = (*S)(u) // ERROR "cannot convert"
263 t = u // ERROR "cannot use .* in assignment|incompatible type"
268 type E struct{ x int }
281 var u *struct{ f func(E) }
283 s = t // ERROR "cannot use .* in assignment|incompatible type"
284 s = u // ERROR "cannot use .* in assignment|incompatible type"
287 s = (*S)(u) // ERROR "cannot convert"
288 t = u // ERROR "cannot use .* in assignment|incompatible type"
289 t = (*T)(u) // ERROR "cannot convert"
293 type E struct{ x int }
306 var u *struct{ f func(E) }
308 s = t // ERROR "cannot use .* in assignment|incompatible type"
309 s = u // ERROR "cannot use .* in assignment|incompatible type"
312 s = (*S)(u) // ERROR "cannot convert"
313 t = u // ERROR "cannot use .* in assignment|incompatible type"
314 t = (*T)(u) // ERROR "cannot convert"
328 _ = (*P)(s) // ERROR "cannot convert"