mirror of
https://github.com/golang/go
synced 2024-11-14 23:20:27 -07:00
66c8935f73
The compiler computes initialization order by finding a spanning tree between a package's global variables. But it does so by walking both variables and functions and stops detecting cycles between variables when they mix with a cycle of mutually recursive functions. Fixes #4847. R=golang-dev, daniel.morsing, rsc CC=golang-dev https://golang.org/cl/9663047
25 lines
497 B
Go
25 lines
497 B
Go
// errorcheck
|
|
|
|
// Copyright 2013 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.
|
|
|
|
// Issue 4847: initialization loop is not detected.
|
|
|
|
package p
|
|
|
|
type (
|
|
E int
|
|
S int
|
|
)
|
|
|
|
type matcher func(s *S) E
|
|
|
|
func matchList(s *S) E { return matcher(matchAnyFn)(s) }
|
|
|
|
var foo = matcher(matchList)
|
|
|
|
var matchAny = matcher(matchList) // ERROR "initialization loop"
|
|
|
|
func matchAnyFn(s *S) (err E) { return matchAny(s) }
|