2009-09-09 10:16:19 +04:00
|
|
|
// $G $D/$F.go && $L $F.$A && ./$A.out
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
2009-09-10 03:59:41 +04:00
|
|
|
import _ "fmt"
|
|
|
|
|
2009-09-09 10:16:19 +04:00
|
|
|
var call string
|
|
|
|
|
|
|
|
type T struct {
|
2010-09-04 04:36:13 +04:00
|
|
|
_, _, _ int
|
2009-09-09 10:16:19 +04:00
|
|
|
}
|
|
|
|
|
2009-09-10 03:59:41 +04:00
|
|
|
func (T) _() {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (T) _() {
|
|
|
|
}
|
|
|
|
|
2009-09-09 10:16:19 +04:00
|
|
|
const (
|
2010-09-04 04:36:13 +04:00
|
|
|
c0 = iota
|
|
|
|
_
|
|
|
|
_
|
|
|
|
_
|
|
|
|
c4
|
2009-09-09 10:16:19 +04:00
|
|
|
)
|
|
|
|
|
|
|
|
var ints = []string {
|
|
|
|
"1",
|
|
|
|
"2",
|
2009-12-10 06:27:08 +03:00
|
|
|
"3",
|
2009-09-09 10:16:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
func f() (int, int) {
|
2010-09-04 04:36:13 +04:00
|
|
|
call += "f"
|
2009-09-09 10:16:19 +04:00
|
|
|
return 1,2
|
|
|
|
}
|
|
|
|
|
|
|
|
func g() (float, float) {
|
2010-09-04 04:36:13 +04:00
|
|
|
call += "g"
|
2009-09-09 10:16:19 +04:00
|
|
|
return 3,4
|
|
|
|
}
|
|
|
|
|
|
|
|
func h(_ int, _ float) {
|
|
|
|
}
|
|
|
|
|
|
|
|
func i() int {
|
2010-09-04 04:36:13 +04:00
|
|
|
call += "i"
|
|
|
|
return 23
|
2009-09-09 10:16:19 +04:00
|
|
|
}
|
|
|
|
|
2010-09-04 04:36:13 +04:00
|
|
|
var _ = i()
|
2009-10-20 06:27:40 +04:00
|
|
|
|
2009-09-10 03:59:41 +04:00
|
|
|
func main() {
|
2009-10-20 06:27:40 +04:00
|
|
|
if call != "i" {panic("init did not run")}
|
2010-09-04 04:36:13 +04:00
|
|
|
call = ""
|
|
|
|
_, _ = f()
|
|
|
|
a, _ := f()
|
2009-09-09 10:16:19 +04:00
|
|
|
if a != 1 {panic(a)}
|
2010-09-04 04:36:13 +04:00
|
|
|
b, _ := g()
|
2009-09-09 10:16:19 +04:00
|
|
|
if b != 3 {panic(b)}
|
2010-09-04 04:36:13 +04:00
|
|
|
_, a = f()
|
2009-09-09 10:16:19 +04:00
|
|
|
if a != 2 {panic(a)}
|
2010-09-04 04:36:13 +04:00
|
|
|
_, b = g()
|
2009-09-09 10:16:19 +04:00
|
|
|
if b != 4 {panic(b)}
|
2010-09-04 04:36:13 +04:00
|
|
|
_ = i()
|
2009-09-09 10:16:19 +04:00
|
|
|
if call != "ffgfgi" {panic(call)}
|
|
|
|
if c4 != 4 {panic(c4)}
|
|
|
|
|
2010-09-04 04:36:13 +04:00
|
|
|
out := ""
|
2009-09-09 10:16:19 +04:00
|
|
|
for _, s := range ints {
|
2010-09-04 04:36:13 +04:00
|
|
|
out += s
|
2009-09-09 10:16:19 +04:00
|
|
|
}
|
|
|
|
if out != "123" {panic(out)}
|
|
|
|
|
2010-09-04 04:36:13 +04:00
|
|
|
sum := 0
|
2009-09-09 10:16:19 +04:00
|
|
|
for s, _ := range ints {
|
2010-09-04 04:36:13 +04:00
|
|
|
sum += s
|
2009-09-09 10:16:19 +04:00
|
|
|
}
|
|
|
|
if sum != 3 {panic(sum)}
|
|
|
|
|
2010-09-04 04:36:13 +04:00
|
|
|
h(a,b)
|
2009-09-09 10:16:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// useless but legal
|
2010-09-04 04:36:13 +04:00
|
|
|
var _ int = 1
|
|
|
|
var _ = 2
|
|
|
|
var _, _ = 3, 4
|
|
|
|
const _ = 3
|
|
|
|
const _, _ = 4, 5
|
|
|
|
type _ int
|
2009-09-09 10:16:19 +04:00
|
|
|
func _() {
|
|
|
|
panic("oops")
|
|
|
|
}
|
|
|
|
|
|
|
|
func ff() {
|
2010-09-04 04:36:13 +04:00
|
|
|
var _ int = 1
|
2009-09-09 10:16:19 +04:00
|
|
|
}
|