1
// Copyright 2013 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.
9
func g() (x, y int) { return }
12
// Var decls must have a type or an initializer.
16
var _ /* ERROR "missing type or init expr" */
17
var _ /* ERROR "missing type or init expr" */, _
18
var _ /* ERROR "missing type or init expr" */, _, _
20
// The initializer must be an expression.
21
var _ = int /* ERROR "not an expression" */
22
var _ = f /* ERROR "used as value" */ ()
24
// Identifier and expression arity must match.
26
var _ = 1, 2 /* ERROR "extra init expr 2" */
27
var _, _ = 1 /* ERROR "assignment count mismatch" */
28
var _, _, _ /* ERROR "missing init expr for _" */ = 1, 2
30
var _ = g /* ERROR "2-valued expr" */ ()
32
var _, _, _ = g /* ERROR "assignment count mismatch" */ ()
36
var _, _, _ = m /* ERROR "assignment count mismatch" */ ["foo"]
39
var _ int = 1, 2 /* ERROR "extra init expr 2" */
40
var _, _ int = 1 /* ERROR "assignment count mismatch" */
41
var _, _, _ /* ERROR "missing init expr for _" */ int = 1, 2
45
_ = 1, 2 /* ERROR "extra init expr 2" */
46
_, _ = 1 /* ERROR "assignment count mismatch" */
47
_, _, _ /* ERROR "missing init expr for _" */ = 1, 2
49
_ = g /* ERROR "2-valued expr" */ ()
51
_, _, _ = g /* ERROR "assignment count mismatch" */ ()
55
_, _, _ = m /* ERROR "assignment count mismatch" */ ["foo"]
58
_ int = 1, 2 /* ERROR "extra init expr 2" */
59
_, _ int = 1 /* ERROR "assignment count mismatch" */
60
_, _, _ /* ERROR "missing init expr for _" */ int = 1, 2
63
// Variables declared in function bodies must be 'used'.
65
func (r T) _(a, b, c int) (u, v, w int) {
66
var x1 /* ERROR "declared but not used" */ int
67
var x2 /* ERROR "declared but not used" */ int
71
y1 /* ERROR "declared but not used" */ := 1
72
y2 /* ERROR "declared but not used" */ := 2
77
var x1 /* ERROR "declared but not used" */ int
78
var x2 /* ERROR "declared but not used" */ int
82
y1 /* ERROR "declared but not used" */ := 1
83
y2 /* ERROR "declared but not used" */ := 2
88
if x /* ERROR "declared but not used" */ := 0; a < b {}
90
switch x /* ERROR "declared but not used" */, y := 0, 1; a {
94
x /* ERROR "declared but not used" */ := 0
98
switch t /* ERROR "declared but not used" */ := t.(type) {}
100
switch t /* ERROR "declared but not used" */ := t.(type) {
104
switch t /* ERROR "declared but not used" */ := t.(type) {
106
case float32, complex64:
110
switch t := t.(type) {
112
case float32, complex64:
116
switch t := t.(type) {
125
switch t := t; t /* ERROR "declared but not used" */ := t.(type) {}
127
var z1 /* ERROR "declared but not used" */ int
129
_ = func(a, b, c int) (u, v, w int) {
137
var i /* ERROR "declared but not used" */ , j int
142
for i, j /* ERROR "declared but not used" */ := range s {
150
// Short variable declarations must declare at least one new non-blank variable.
152
_ := /* ERROR no new variables */ 0
154
_, a := /* ERROR no new variables */ 0, 1
156
_, _, _ := /* ERROR no new variables */ 0, 1, 2
162
// TODO(gri) consolidate other var decl checks in this file
b'\\ No newline at end of file'