Debian Codegraph @

test/fixedbugs/bug159.go

raw
1 // 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 import "os"
10
11 func main() {
12 ok := true;
13 var a, b, c, x, y, z int;
14 f := func() int { b--; return -b };
15
16 // this fails on 6g: apparently it rewrites
17 // the list into
18 // z = f();
19 // y = f();
20 // x = f();
21 // so that the values come out backward.
22 x, y, z = f(), f(), f();
23 if x != 1 || y != 2 || z != 3 {
24 println("xyz: expected 1 2 3 got", x, y, z);
25 ok = false;
26 }
27
28 // this fails on 6g too. one of the function calls
29 // happens after assigning to b.
30 a, b, c = f(), f(), f();
31 if a != 4 || b != 5 || c != 6 {
32 println("abc: expected 4 5 6 got", a, b, c);
33 ok = false;
34 }
35
36 if !ok {
37 os.Exit(1);
38 }
39 }