]> Cypherpunks.ru repositories - gostls13.git/blob - test/decl.go
fix "declared and not used" in tests;
[gostls13.git] / test / decl.go
1 // $G $F.go && $L $F.$A && ./$A.out
2
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.
6
7 // Correct short declarations and redeclarations.
8
9 package main
10
11 func f1() int { return 1 }
12 func f2() (float, int) { return 1, 2 }
13 func f3() (float, int, string) { return 1, 2, "3" }
14
15 func x() (s string) {
16         a, b, s := f3();
17         return  // tests that result var is in scope for redeclaration
18 }
19
20 func main() {
21         i, f, s := f3();
22         j, f := f2();   // redeclare f
23         k := f1();
24         m, g, s := f3();
25         m, h, s := f3();
26         {
27                 // new block should be ok.
28                 i, f, s := f3();
29                 j, f := f2();   // redeclare f
30                 k := f1();
31                 m, g, s := f3();
32                 m, h, s := f3();
33                 _, _, _, _, _, _, _, _, _ = i, f, s, j, k, m, g, s, h;
34         }
35         if x() != "3" {
36                 println("x() failed");
37         }
38         _, _, _, _, _, _, _, _, _ = i, f, s, j, k, m, g, s, h;
39 }