1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
10 b, i, f, c, s := false, 1, 1.0, 1i, "foo"
11 b = i /* ERROR "cannot assign" */
12 i = f /* ERROR "cannot assign" */
13 f = c /* ERROR "cannot assign" */
14 c = s /* ERROR "cannot assign" */
15 s = b /* ERROR "cannot assign" */
17 v0 /* ERROR "mismatch" */, v1, v2 := 1, 2, 3, 4
22 i += "foo" /* ERROR "cannot convert.*int" */
25 f -= "foo" /* ERROR "cannot convert.*float64" */
28 c /= 0 /* ERROR "division by zero" */
31 s += 1 /* ERROR "cannot convert.*string" */
36 c /* ERROR "cannot assign" */ ++
38 s /* ERROR "cannot convert" */ --
39 3.14 /* ERROR "cannot assign" */ ++
54 x /* ERROR "cannot send" */ <- x
55 rch /* ERROR "cannot send" */ <- x
56 ch /* ERROR "cannot send" */ <- "foo"
72 case <-sc /* ERROR "cannot receive from send-only channel" */ :
76 default /* ERROR "multiple defaults" */ :
81 go 1 /* ERROR "expected function/method call" */
85 go len(c) // TODO(gri) this should not be legal
89 defer 1 /* ERROR "expected function/method call" */
93 defer len(c) // TODO(gri) this should not be legal
101 default /* ERROR "multiple defaults" */ :
105 case 1 /* ERROR "cannot convert" */ :
110 case x /* ERROR "cannot compare" */ :
114 case 1 /* ERROR "overflows int" */ << 100:
119 case 1 /* ERROR "duplicate case" */ :
121 case 1 /* ERROR "duplicate case" */ :
124 // TODO(gri) duplicate 64bit values that don't fit into an int64 are not yet detected
146 func _typeswitches() {
151 switch (x /* ERROR "outside type switch" */ .(type)) {}
155 default /* ERROR "multiple defaults" */ :
158 switch x := x.(type) {}
160 switch x := x.(type) {
165 switch x := i /* ERROR "not an interface" */ .(type) {}
167 switch t := x.(type) {
169 var v bool = t /* ERROR "cannot assign" */
172 case float32, complex64:
173 var v float32 = t /* ERROR "cannot assign" */
175 var v float32 = t /* ERROR "cannot assign" */
181 case T1 /* ERROR "missing method m" */ :
182 case T2 /* ERROR "wrong type for method m" */ :
183 case I2 /* ERROR "wrong type for method m" */ :
201 for _ = range x /* ERROR "cannot range over" */ {}
202 for i := range x /* ERROR "cannot range over" */ {}
208 for i, x := range a {
212 xx = x /* ERROR "cannot assign" */
216 for ii, xx := range a {}
222 for i, x := range b {
233 for i, x := range s {
240 for _, x := range p {
245 for _, x := range pp /* ERROR "cannot range over" */ {}
249 kk = k /* ERROR "cannot assign" */
251 for k, v := range m {
257 for _, _ /* ERROR "only one iteration variable" */ = range c {}
262 for _ = range sc /* ERROR "cannot range over send-only channel" */ {}
267 for i, x := range cs {}
268 for i, x := range "" {