3 // Copyright 2009 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.
7 // Test that incorrect short declarations and redeclarations are detected.
12 func f1() int { return 1 }
13 func f2() (float32, int) { return 1, 2 }
14 func f3() (float32, int, string) { return 1, 2, "3" }
18 // simple redeclaration
20 i := f1() // ERROR "redeclared|no new"
24 // change of type for f
26 f, g, t := f3() // ERROR "redeclared|cannot assign|incompatible"
27 _, _, _, _, _ = i, f, s, g, t
30 // change of type for i
32 j, i, t := f3() // ERROR "redeclared|cannot assign|incompatible"
33 _, _, _, _, _ = i, f, s, j, t
38 i, f := f2() // ERROR "redeclared|no new"
42 // multiline no new variables
44 i := func() { // ERROR "redeclared|no new|incompatible"
49 // single redeclaration
51 i := 1 // ERROR "redeclared|no new|incompatible"
54 // double redeclaration
57 i, f := f2() // ERROR "redeclared|no new"
61 // triple redeclaration
63 i, f, s := f3() // ERROR "redeclared|no new"