blob: bc5a1fa6a0f0920c52e90c3d459b7c28de5423f8 [file] [log] [blame]
Russ Cox2b1c9b42012-02-16 23:49:30 -05001// run
Russ Cox272d1562009-12-02 23:54:51 -08002
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// function call arg reordering was picking out 1 call that
8// didn't need to be in a temporary, but it was picking
9// out the first call instead of the last call.
Péter Surányi9b6ccb12015-02-06 21:44:39 +090010// http://golang.org/issue/370
Russ Cox272d1562009-12-02 23:54:51 -080011
12package main
13
14var gen = 'a'
Russ Cox00f9f0c2010-03-30 10:34:57 -070015
Russ Cox272d1562009-12-02 23:54:51 -080016func f(n int) string {
Russ Cox00f9f0c2010-03-30 10:34:57 -070017 s := string(gen) + string(n+'A'-1)
18 gen++
19 return s
Russ Cox272d1562009-12-02 23:54:51 -080020}
21
22func g(x, y string) string {
23 return x + y
24}
25
26func main() {
Russ Cox00f9f0c2010-03-30 10:34:57 -070027 s := f(1) + f(2)
Russ Cox272d1562009-12-02 23:54:51 -080028 if s != "aAbB" {
Russ Cox00f9f0c2010-03-30 10:34:57 -070029 println("BUG: bug221a: ", s)
30 panic("fail")
Russ Cox272d1562009-12-02 23:54:51 -080031 }
Russ Cox00f9f0c2010-03-30 10:34:57 -070032 s = g(f(3), f(4))
Russ Cox272d1562009-12-02 23:54:51 -080033 if s != "cCdD" {
Russ Cox00f9f0c2010-03-30 10:34:57 -070034 println("BUG: bug221b: ", s)
35 panic("fail")
Russ Cox272d1562009-12-02 23:54:51 -080036 }
Russ Cox00f9f0c2010-03-30 10:34:57 -070037 s = f(5) + f(6) + f(7) + f(8) + f(9)
Russ Cox272d1562009-12-02 23:54:51 -080038 if s != "eEfFgGhHiI" {
Russ Cox00f9f0c2010-03-30 10:34:57 -070039 println("BUG: bug221c: ", s)
40 panic("fail")
Russ Cox272d1562009-12-02 23:54:51 -080041 }
42}