]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.12] cmd/vet: add tests for point-release issues
authorRuss Cox <rsc@golang.org>
Tue, 30 Apr 2019 17:32:57 +0000 (13:32 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 1 May 2019 15:18:09 +0000 (15:18 +0000)
Add explicit tests for:

 #30465 cmd/vet: Consider reverting tag conflict for embedded fields
 #30399 cmd/vet: possible to get a printf false positive with big.Int

because we have managed not to fix them in the last
couple point releases, and it will be too embarrassing
to do that yet again.

Change-Id: Ib1da5df870348b6eb9bfc8a87c507ecc6d44b8dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/174520
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/vet/testdata/src/print2/big.go [new file with mode: 0644]
src/cmd/vet/testdata/src/structtag/structtag.go
src/cmd/vet/vet_test.go

diff --git a/src/cmd/vet/testdata/src/print2/big.go b/src/cmd/vet/testdata/src/print2/big.go
new file mode 100644 (file)
index 0000000..dd5bef5
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright 2019 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.
+
+package print2
+
+import ( // NOTE: Does not import "fmt"
+       "log"
+       "math/big"
+)
+
+var fmt int
+
+func f() {
+       log.Printf("%d", new(big.Int))
+       log.Printf("%d", 1.0) // ERROR "Printf format %d has arg 1.0 of wrong type float64"
+}
index cbcc453376070a2fb78aaf6e5a5da3842a94b7af..e40139e8b15a9b2d89629f506d2c69ec4bc1840e 100644 (file)
@@ -6,6 +6,20 @@
 
 package structtag
 
+import "encoding/json"
+
 type StructTagTest struct {
        A int "hello" // ERROR "`hello` not compatible with reflect.StructTag.Get: bad syntax for struct tag pair"
 }
+
+func Issue30465() {
+       type T1 struct {
+               X string `json:"x"`
+       }
+       type T2 struct {
+               T1
+               X string `json:"x"`
+       }
+       var t2 T2
+       json.Marshal(&t2)
+}
index d106c5c29ce7c1c1405fcaceb66179746c44cddc..f3b9a56515d02001b7d8e18c405c957e49ea6d1c 100644 (file)
@@ -88,6 +88,7 @@ func TestVet(t *testing.T) {
                "method",
                "nilfunc",
                "print",
+               "print2",
                "rangeloop",
                "shift",
                "structtag",