// 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 "assignment mismatch: 3 variables but 2 values" */ , 2 a, b, c = 1 /* ERROR "assignment mismatch: 3 variables but 4 values" */ , 2, 3, 4 _, _, _ = a, b, c a = f0 /* ERROR "used as value" */ () a = f1() a = f2 /* ERROR "assignment mismatch: 1 variable but f2 returns 2 values" */ () a, b = f2() a, b, c = f2 /* ERROR "assignment mismatch: 3 variables but f2 returns 2 values" */ () a, b, c = f3() a, b = f3 /* ERROR "assignment mismatch: 2 variables but f3 returns 3 values" */ () a, b, c = <- /* ERROR "assignment mismatch: 3 variables but 1 value" */ 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 /* ERRORx `cannot use .* in assignment` */ i = f /* ERRORx `cannot use .* in assignment` */ f = c /* ERRORx `cannot use .* in assignment` */ c = s /* ERRORx `cannot use .* in assignment` */ s = b /* ERRORx `cannot use .* in assignment` */ v0, v1, v2 := 1 /* ERROR "assignment mismatch" */ , 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<