2012-02-18 14:15:42 -07:00
|
|
|
// run
|
2009-08-21 18:54:07 -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
|
|
|
var m = map[int]int{0: 0, 1: 0}
|
2009-08-21 18:54:07 -06:00
|
|
|
var nf = 0
|
|
|
|
var i int
|
|
|
|
|
2010-03-24 17:46:53 -06:00
|
|
|
func multi() (int, int) { return 1, 2 }
|
2009-08-21 18:54:07 -06:00
|
|
|
|
|
|
|
func xxx() {
|
2011-03-22 11:32:43 -06:00
|
|
|
var c chan int
|
|
|
|
x, ok := <-c
|
2009-08-21 18:54:07 -06:00
|
|
|
|
2010-03-24 17:46:53 -06:00
|
|
|
var m map[int]int
|
2011-03-22 11:32:43 -06:00
|
|
|
x, ok = m[1]
|
2009-08-21 18:54:07 -06:00
|
|
|
|
2010-03-24 17:46:53 -06:00
|
|
|
var i interface{}
|
|
|
|
var xx int
|
|
|
|
xx, ok = i.(int)
|
2009-08-21 18:54:07 -06:00
|
|
|
|
2010-03-24 17:46:53 -06:00
|
|
|
a, b := multi()
|
2009-09-14 22:03:53 -06:00
|
|
|
|
2010-03-24 17:46:53 -06:00
|
|
|
_, _, _, _, _ = x, ok, xx, a, b
|
2009-08-21 18:54:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func f() map[int]int {
|
2010-03-24 17:46:53 -06:00
|
|
|
nf++
|
|
|
|
return m
|
2009-08-21 18:54:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func g() *int {
|
2010-03-24 17:46:53 -06:00
|
|
|
nf++
|
2009-08-21 18:54:07 -06:00
|
|
|
return &i
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2010-03-24 17:46:53 -06:00
|
|
|
f()[0]++
|
|
|
|
f()[1] += 2
|
|
|
|
*g() %= 2
|
2009-08-21 18:54:07 -06:00
|
|
|
if nf != 3 {
|
2010-03-24 17:46:53 -06:00
|
|
|
println("too many calls:", nf)
|
|
|
|
panic("fail")
|
2009-08-21 18:54:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|