1
0
mirror of https://github.com/golang/go synced 2024-09-30 18:08:33 -06:00

go.tools/cmd/vet: don't check for shadowing of blank identifier

It's pointless.
Also this fixes a crash, because the blank identifier no longer appears as a
defined object after CL 74190043 so we were getting nil pointer violations.
Even better, we get to re-enable a disabled test.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/75140043
This commit is contained in:
Rob Pike 2014-03-13 10:27:55 +11:00
parent ea79d922e6
commit e239f1b3f2
2 changed files with 5 additions and 5 deletions

View File

@ -91,9 +91,6 @@ func (pkg *Package) growSpan(ident *ast.Ident, obj types.Object) {
// checkShadowAssignment checks for shadowing in a short variable declaration.
func (f *File) checkShadowAssignment(a *ast.AssignStmt) {
// TODO(r) remove this return once tests pass again
return
if !vet("shadow") {
return
}
@ -192,6 +189,10 @@ func (f *File) checkShadowDecl(d *ast.GenDecl) {
// checkShadowing checks whether the identifier shadows an identifier in an outer scope.
func (f *File) checkShadowing(ident *ast.Ident) {
if ident.Name == "_" {
// Can't shadow the blank identifier.
return
}
obj := f.pkg.defs[ident]
if obj == nil {
return

View File

@ -17,8 +17,7 @@ func ShadowRead(f *os.File, buf []byte) (err error) {
_ = err
}
if f != nil {
// TODO(r) enable this error again once tests pass
_, err := f.Read(buf) // DISABLED ERROR "declaration of err shadows declaration at testdata/shadow.go:13"
_, err := f.Read(buf) // ERROR "declaration of err shadows declaration at testdata/shadow.go:13"
if err != nil {
return err
}