diff options
author | Rémy Oudompheng <oudomphe@phare.normalesup.org> | 2012-10-07 00:52:40 +0200 |
---|---|---|
committer | Rémy Oudompheng <oudomphe@phare.normalesup.org> | 2012-10-07 00:52:40 +0200 |
commit | 0b2ca9e62f778adb95c31e57e120ef1cbfc42b25 (patch) | |
tree | 21457891bcf4b4d92a86ba2993daec92179c0a23 /test/fixedbugs/bug459.go | |
parent | 46fcfdaa7dc4c35cf593df2b883db28814e641fe (diff) | |
download | go-git-0b2ca9e62f778adb95c31e57e120ef1cbfc42b25.tar.gz |
cmd/gc: avoid clobbering the AST in cgen_callmeth.
It confused the detection of init loops when involving
method calls.
Fixes #3890.
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6620067
Diffstat (limited to 'test/fixedbugs/bug459.go')
-rw-r--r-- | test/fixedbugs/bug459.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/fixedbugs/bug459.go b/test/fixedbugs/bug459.go new file mode 100644 index 0000000000..80abe5d518 --- /dev/null +++ b/test/fixedbugs/bug459.go @@ -0,0 +1,35 @@ +// errorcheck + +// Copyright 2012 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 3890: missing detection of init loop involving +// method calls in function bodies. + +package flag + +var commandLine = NewFlagSet() // ERROR "loop" + +type FlagSet struct { +} + +func (f *FlagSet) failf(format string, a ...interface{}) { + f.usage() +} + +func (f *FlagSet) usage() { + if f == commandLine { + panic(3) + } +} + +func NewFlagSet() *FlagSet { + f := &FlagSet{} + f.setErrorHandling(true) + return f +} + +func (f *FlagSet) setErrorHandling(b bool) { + f.failf("DIE") +} |