]> Cypherpunks.ru repositories - gostls13.git/blob - test/fixedbugs/bug459.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / test / fixedbugs / bug459.go
1 // errorcheck
2
3 // Copyright 2012 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
6
7 // Issue 3890: missing detection of init cycle involving
8 // method calls in function bodies.
9
10 package flag
11
12 var commandLine = NewFlagSet() // ERROR "initialization cycle|depends upon itself"
13
14 type FlagSet struct {
15 }
16
17 func (f *FlagSet) failf(format string, a ...interface{}) {
18         f.usage()
19 }
20
21 func (f *FlagSet) usage() {
22         if f == commandLine {
23                 panic(3)
24         }
25 }
26
27 func NewFlagSet() *FlagSet {
28         f := &FlagSet{}
29         f.setErrorHandling(true)
30         return f
31 }
32
33 func (f *FlagSet) setErrorHandling(b bool) {
34         f.failf("DIE")
35 }