OSDN Git Service

Merge branch 'trunk' of git://gcc.gnu.org/git/gcc into rework
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / go.test / test / fixedbugs / bug148.go
1 // $G $D/$F.go && $L $F.$A && ! ./$A.out || echo BUG: should crash
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 package main
8
9 type T struct {a, b int};
10
11 func f(x interface{}) interface{} {
12         type T struct {a, b int};
13
14         if x == nil {
15                 return T{2, 3};
16         }
17
18         t := x.(T);
19         println(t.a, t.b);
20         return x;
21 }
22
23 func main() {
24         inner_T := f(nil);
25         f(inner_T);
26
27         outer_T := T{5, 7};
28         f(outer_T);
29 }
30
31 /*
32 This prints:
33
34 2 3
35 5 7
36
37 but it should crash: The type assertion on line 14 should fail
38 for the 2nd call to f with outer_T.
39 */