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
10package flag
11
12var commandLine = NewFlagSet() // ERROR "initialization cycle|depends upon itself"
13
14type FlagSet struct {
15}
16
17func (f *FlagSet) failf(format string, a ...interface{}) {
18	f.usage()
19}
20
21func (f *FlagSet) usage() {
22	if f == commandLine {
23		panic(3)
24	}
25}
26
27func NewFlagSet() *FlagSet {
28	f := &FlagSet{}
29	f.setErrorHandling(true)
30	return f
31}
32
33func (f *FlagSet) setErrorHandling(b bool) {
34	f.failf("DIE")
35}
36