2012-02-16 21:49:30 -07:00
|
|
|
// run
|
2009-08-07 15:38:31 -06:00
|
|
|
|
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
2010-03-24 17:46:53 -06:00
|
|
|
func g() {}
|
2009-08-07 15:38:31 -06:00
|
|
|
|
|
|
|
func f1() (a, b int) {
|
2010-03-24 17:46:53 -06:00
|
|
|
a, b = 2, 1
|
|
|
|
g() // defeat optimizer
|
|
|
|
return a, b
|
2009-08-07 15:38:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func f2() (a, b int) {
|
2010-03-24 17:46:53 -06:00
|
|
|
a, b = 1, 2
|
|
|
|
g() // defeat optimizer
|
|
|
|
return b, a
|
2009-08-07 15:38:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2010-03-24 17:46:53 -06:00
|
|
|
x, y := f1()
|
2009-08-07 15:38:31 -06:00
|
|
|
if x != 2 || y != 1 {
|
2010-03-24 17:46:53 -06:00
|
|
|
println("f1", x, y)
|
|
|
|
panic("fail")
|
2009-08-07 15:38:31 -06:00
|
|
|
}
|
|
|
|
|
2010-03-24 17:46:53 -06:00
|
|
|
x, y = f2()
|
2009-08-07 15:38:31 -06:00
|
|
|
if x != 2 || y != 1 {
|
2010-03-24 17:46:53 -06:00
|
|
|
println("f2", x, y)
|
|
|
|
panic("fail")
|
2009-08-07 15:38:31 -06:00
|
|
|
}
|
|
|
|
}
|