1 // errchk $G -e $D/$F.go
3 // Copyright 2010 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 cases for revised conversion rules.
33 a0 = [3]int(a2) // ERROR "cannot|invalid"
36 a1 = A1(a2) // ERROR "cannot|invalid"
37 a2 = A2(a0) // ERROR "cannot|invalid"
38 a2 = A2(a1) // ERROR "cannot|invalid"
56 }(s2) // ERROR "cannot|invalid"
59 s1 = S1(s2) // ERROR "cannot|invalid"
60 s2 = S2(s0) // ERROR "cannot|invalid"
61 s2 = S2(s1) // ERROR "cannot|invalid"
71 p0 = (*int)(p2) // ERROR "cannot|invalid"
74 p1 = P1(p2) // ERROR "cannot|invalid"
75 p2 = P2(p0) // ERROR "cannot|invalid"
76 p2 = P2(p1) // ERROR "cannot|invalid"
93 })(ps1) // legal because of special conversion exception for pointers
96 })(q2) // ERROR "cannot|invalid"
99 q1 = Q1(q2) // ERROR "cannot|invalid"
100 q2 = (*S1)(q0) // legal because of special conversion exception for pointers
101 q2 = Q2(q1) // ERROR "cannot|invalid"
104 type F1 func(x NewInt) int
105 type F2 func(x int) NewInt
106 var f0 func(x NewInt) int
111 f0 = func(x NewInt) int(f2) // ERROR "cannot|invalid"
114 f1 = F1(f2) // ERROR "cannot|invalid"
115 f2 = F2(f0) // ERROR "cannot|invalid"
116 f2 = F2(f1) // ERROR "cannot|invalid"
134 }(x2) // ERROR "cannot|need type assertion|incompatible"
137 x1 = X1(x2) // ERROR "cannot|need type assertion|incompatible"
138 x2 = X2(x0) // ERROR "cannot|need type assertion|incompatible"
139 x2 = X2(x1) // ERROR "cannot|need type assertion|incompatible"
149 l0 = []int(l2) // ERROR "cannot|invalid"
152 l1 = L1(l2) // ERROR "cannot|invalid"
153 l2 = L2(l0) // ERROR "cannot|invalid"
154 l2 = L2(l1) // ERROR "cannot|invalid"
157 type M1 map[string]int
158 type M2 map[string]NewInt
164 m0 = []int(m2) // ERROR "cannot|invalid"
167 m1 = L1(m2) // ERROR "cannot|invalid"
168 m2 = L2(m0) // ERROR "cannot|invalid"
169 m2 = L2(m1) // ERROR "cannot|invalid"
179 c0 = chan int(c2) // ERROR "cannot|invalid"
182 c1 = C1(c2) // ERROR "cannot|invalid"
183 c2 = C2(c0) // ERROR "cannot|invalid"
184 c2 = C2(c1) // ERROR "cannot|invalid"
187 // internal compiler error (6g and gccgo)
189 var _ T = 17 // assignment compatible
190 _ = T(17) // internal compiler error even though assignment compatible