mirror of
https://github.com/golang/go
synced 2024-11-16 20:24:54 -07:00
5d0d87ae16
This CL rewrites cmd/compile's package-level initialization ordering algorithm to be compliant with the Go spec. See documentation in initorder.go for details. Incidentally, this CL also improves fidelity of initialization loop diagnostics by including referenced functions in the emitted output like go/types does. Fixes #22326. Change-Id: I7c9ac47ff563df4d4f700cf6195387a0f372cc7b Reviewed-on: https://go-review.googlesource.com/c/go/+/170062 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
26 lines
350 B
Go
26 lines
350 B
Go
// run
|
|
|
|
// Copyright 2019 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
|
|
|
|
var (
|
|
_ = d
|
|
_ = f("_", c, b)
|
|
a = f("a")
|
|
b = f("b")
|
|
c = f("c")
|
|
d = f("d")
|
|
)
|
|
|
|
func f(s string, rest ...int) int {
|
|
print(s)
|
|
return 0
|
|
}
|
|
|
|
func main() {
|
|
println()
|
|
}
|