3 // Copyright 2021 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.
11 _ = a, b // ERROR "assignment mismatch: 1 variable but 2 values"
12 _ = a, b, c // ERROR "assignment mismatch: 1 variable but 3 values"
14 _, _ = a // ERROR "assignment mismatch: 2 variables but 1 value"
16 _, _ = a, b, c // ERROR "assignment mismatch: 2 variables but 3 values"
18 _, _, _ = a // ERROR "assignment mismatch: 3 variables but 1 value"
19 _, _, _ = a, b // ERROR "assignment mismatch: 3 variables but 2 values"
25 func f3() (int, int, int)
29 _ = f2() // ERROR "assignment mismatch: 1 variable but f2 returns 2 values"
30 _ = f3() // ERROR "assignment mismatch: 1 variable but f3 returns 3 values"
32 _, _ = f1() // ERROR "assignment mismatch: 2 variables but f1 returns 1 value"
34 _, _ = f3() // ERROR "assignment mismatch: 2 variables but f3 returns 3 values"
36 _, _, _ = f1() // ERROR "assignment mismatch: 3 variables but f1 returns 1 value"
37 _, _, _ = f2() // ERROR "assignment mismatch: 3 variables but f2 returns 2 values"
40 // test just a few := cases as they use the same code as the = case
41 a1 := f3() // ERROR "assignment mismatch: 1 variable but f3 returns 3 values"
42 a2, b2 := f1() // ERROR "assignment mismatch: 2 variables but f1 returns 1 value"
43 a3, b3, c3 := f2() // ERROR "assignment mismatch: 3 variables but f2 returns 2 values"
53 func (T) f2() (int, int)
54 func (T) f3() (int, int, int)
58 _ = x.f2() // ERROR "assignment mismatch: 1 variable but .\.f2 returns 2 values"
59 _ = x.f3() // ERROR "assignment mismatch: 1 variable but .\.f3 returns 3 values"
61 _, _ = x.f1() // ERROR "assignment mismatch: 2 variables but .\.f1 returns 1 value"
63 _, _ = x.f3() // ERROR "assignment mismatch: 2 variables but .\.f3 returns 3 values"
65 _, _, _ = x.f1() // ERROR "assignment mismatch: 3 variables but .\.f1 returns 1 value"
66 _, _, _ = x.f2() // ERROR "assignment mismatch: 3 variables but .\.f2 returns 2 values"
69 // test just a few := cases as they use the same code as the = case
70 a1 := x.f3() // ERROR "assignment mismatch: 1 variable but .\.f3 returns 3 values"
71 a2, b2 := x.f1() // ERROR "assignment mismatch: 2 variables but .\.f1 returns 1 value"
72 a3, b3, c3 := x.f2() // ERROR "assignment mismatch: 3 variables but .\.f2 returns 2 values"
82 _ = f1(), 2 // ERROR "assignment mismatch: 1 variable but 2 values"
83 _, _ = (f1()), f2() // ERROR "multiple-value f2\(\) .*in single-value context"
84 _, _, _ = f3(), 3 // ERROR "assignment mismatch: 3 variables but 2 values|multiple-value f3\(\) .*in single-value context"