1
0
mirror of https://github.com/golang/go synced 2024-11-14 23:20:27 -07:00
go/test/fixedbugs/issue4847.go
Rémy Oudompheng 66c8935f73 cmd/gc: fix detection of initialization loop.
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
2013-08-29 10:16:09 +02:00

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) }