blob: 014f2ef01f77caf3556886b727c24760bbc05fdc [file] [log] [blame]
Rémy Oudompheng0b2ca9e2012-10-07 00:52:40 +02001// 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 loop involving
8// method calls in function bodies.
9
10package flag
11
Rémy Oudompheng004dd3d72013-06-20 08:21:14 +020012var commandLine = NewFlagSet() // ERROR "loop|depends upon itself"
Rémy Oudompheng0b2ca9e2012-10-07 00:52:40 +020013
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}