From de72360261aa5245fb17e9f4d503d1f9f4fd0e41 Mon Sep 17 00:00:00 2001 From: Andrew Gerrand Date: Wed, 21 Aug 2013 11:08:25 +1000 Subject: [PATCH] go.tools/cmd/vet: fix build of testdata package R=golang-dev, r CC=golang-dev https://golang.org/cl/13144043 --- cmd/vet/testdata/nilfunc.go | 2 -- cmd/vet/testdata/shadow.go | 12 ++++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/cmd/vet/testdata/nilfunc.go b/cmd/vet/testdata/nilfunc.go index 8ee921ff..2ce7bc8c 100644 --- a/cmd/vet/testdata/nilfunc.go +++ b/cmd/vet/testdata/nilfunc.go @@ -4,8 +4,6 @@ package testdata -import "os" - func F() {} type T struct { diff --git a/cmd/vet/testdata/shadow.go b/cmd/vet/testdata/shadow.go index e0af5ec4..34a68068 100644 --- a/cmd/vet/testdata/shadow.go +++ b/cmd/vet/testdata/shadow.go @@ -14,11 +14,12 @@ func ShadowRead(f *os.File, buf []byte) (err error) { var x int if f != nil { err := 3 // OK - different type. + _ = err } if f != nil { _, err := f.Read(buf) // ERROR "declaration of err shadows declaration at testdata/shadow.go:13" if err != nil { - return + return err } i := 3 // OK _ = i @@ -26,7 +27,7 @@ func ShadowRead(f *os.File, buf []byte) (err error) { if f != nil { var _, err = f.Read(buf) // ERROR "declaration of err shadows declaration at testdata/shadow.go:13" if err != nil { - return + return err } } for i := 0; i < 10; i++ { @@ -39,14 +40,13 @@ func ShadowRead(f *os.File, buf []byte) (err error) { switch shadowTemp := shadowTemp.(type) { // OK: obviously intentional idiomatic redeclaration case int: println("OK") + _ = shadowTemp } - var shadowTemp = shadowTemp // OK: obviously intentional idiomatic redeclaration - if true { + if shadowTemp := shadowTemp; true { // OK: obviously intentional idiomatic redeclaration var f *os.File // OK because f is not mentioned later in the function. // The declaration of x is a shadow because x is mentioned below. var x int // ERROR "declaration of x shadows declaration at testdata/shadow.go:14" - _ = x - f = nil + _, _, _ = x, f, shadowTemp } // Use a couple of variables to trigger shadowing errors. _, _ = err, x