cmd/vet: fix internal comments

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/163070043
This commit is contained in:
Robert Griesemer 2014-10-23 10:59:27 -07:00
parent e2e1830b02
commit bdfcf50b6f
1 changed files with 6 additions and 6 deletions

View File

@ -212,23 +212,23 @@ func checkShadowing(f *File, ident *ast.Ident) {
return return
} }
// obj.Parent.Parent is the surrounding scope. If we can find another declaration // obj.Parent.Parent is the surrounding scope. If we can find another declaration
// starting from there, we have a shadowed variable. // starting from there, we have a shadowed identifier.
_, shadowed := obj.Parent().Parent().LookupParent(obj.Name()) _, shadowed := obj.Parent().Parent().LookupParent(obj.Name())
if shadowed == nil { if shadowed == nil {
return return
} }
// Don't complain if it's shadowing a universe-declared variable; that's fine. // Don't complain if it's shadowing a universe-declared identifier; that's fine.
if shadowed.Parent() == types.Universe { if shadowed.Parent() == types.Universe {
return return
} }
if *strictShadowing { if *strictShadowing {
// The shadowed variable must appear before this one to be an instance of shadowing. // The shadowed identifier must appear before this one to be an instance of shadowing.
if shadowed.Pos() > ident.Pos() { if shadowed.Pos() > ident.Pos() {
return return
} }
} else { } else {
// Don't complain if the span of validity of the shadowed variable doesn't include // Don't complain if the span of validity of the shadowed identifier doesn't include
// the shadowing variable. // the shadowing identifier.
span, ok := f.pkg.spans[shadowed] span, ok := f.pkg.spans[shadowed]
if !ok { if !ok {
f.Badf(ident.Pos(), "internal error: no range for %s", ident.Name) f.Badf(ident.Pos(), "internal error: no range for %s", ident.Name)
@ -238,7 +238,7 @@ func checkShadowing(f *File, ident *ast.Ident) {
return return
} }
} }
// Don't complain if the types differ: that implies the programmer really wants two variables. // Don't complain if the types differ: that implies the programmer really wants two different things.
if types.Identical(obj.Type(), shadowed.Type()) { if types.Identical(obj.Type(), shadowed.Type()) {
f.Badf(ident.Pos(), "declaration of %s shadows declaration at %s", obj.Name(), f.loc(shadowed.Pos())) f.Badf(ident.Pos(), "declaration of %s shadows declaration at %s", obj.Name(), f.loc(shadowed.Pos()))
} }