Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 // $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: should run | |
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 List struct { | |
10 Item int | |
11 Next *List | |
12 } | |
13 | |
14 type Foo struct{ *Bar } | |
15 | |
16 type Bar struct{ *Foo } | |
17 | |
18 var x = Foo{&y} | |
19 var y = Bar{&x} | |
20 var l = List{0, &l} | |
21 | |
22 func main() { | |
23 if y.Foo != &x { | |
24 println("y was not initialized with &x!") | |
25 } | |
26 if x.Bar != &y { | |
27 println("x was not initialized with &y!") | |
28 } | |
29 | |
30 if l.Next != &l { | |
31 println("l should have been initialized with its own address") | |
32 } | |
33 } | |
OLD | NEW |