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|cannot use"
27 _, _, _, _, _ = i, f, s, g, t
30 // change of type for i
32 j, i, t := f3() // ERROR "redeclared|cannot assign|incompatible|cannot use"
33 _, _, _, _, _ = i, f, s, j, t
38 i, f := f2() // ERROR "redeclared|no new"
42 // multiline no new variables
44 i := func() int { // ERROR "redeclared|no new|incompatible"
50 // single redeclaration
52 i := 1 // ERROR "redeclared|no new|incompatible"
55 // double redeclaration
58 i, f := f2() // ERROR "redeclared|no new"
62 // triple redeclaration
64 i, f, s := f3() // ERROR "redeclared|no new"