// Copyright 2012 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. // statements package stmt0 func assignments0() (int, int) { var a, b, c int var ch chan int f0 := func() {} f1 := func() int { return 1 } f2 := func() (int, int) { return 1, 2 } f3 := func() (int, int, int) { return 1, 2, 3 } a, b, c = 1, 2, 3 a, b, c = 1 /* ERROR "cannot assign [1-9]+ values to [1-9]+ variables" */ , 2 a, b, c = 1 /* ERROR "cannot assign [1-9]+ values to [1-9]+ variables" */ , 2, 3, 4 _, _, _ = a, b, c a = f0 /* ERROR "used as value" */ () a = f1() a = f2 /* ERROR "cannot assign [1-9]+ values to [1-9]+ variables" */ () a, b = f2() a, b, c = f2 /* ERROR "cannot assign [1-9]+ values to [1-9]+ variables" */ () a, b, c = f3() a, b = f3 /* ERROR "cannot assign [1-9]+ values to [1-9]+ variables" */ () a, b, c = <- /* ERROR "cannot assign [1-9]+ values to [1-9]+ variables" */ ch return /* ERROR "not enough return values\n\thave \(\)\n\twant \(int, int\)" */ return 1 /* ERROR "not enough return values\n\thave \(number\)\n\twant \(int, int\)" */ return 1, 2 return 1, 2, 3 /* ERROR "too many return values\n\thave \(number, number, number\)\n\twant \(int, int\)" */ } func assignments1() { b, i, f, c, s := false, 1, 1.0, 1i, "foo" b = i /* ERROR "cannot use .* in assignment" */ i = f /* ERROR "cannot use .* in assignment" */ f = c /* ERROR "cannot use .* in assignment" */ c = s /* ERROR "cannot use .* in assignment" */ s = b /* ERROR "cannot use .* in assignment" */ v0, v1, v2 := 1 /* ERROR "cannot initialize" */ , 2, 3, 4 _, _, _ = v0, v1, v2 b = true i += 1 i /* ERROR "mismatched types int and untyped string" */+= "foo" f -= 1 f /= 0 f = float32(0)/0 /* ERROR "division by zero" */ f /* ERROR "mismatched types float64 and untyped string" */-= "foo" c *= 1 c /= 0 s += "bar" s /* ERROR "mismatched types string and untyped int" */+= 1 var u64 uint64 u64 += 1<