]> Cypherpunks repositories - gostls13.git/commit
cmd/vet: **T is not Stringer if *T has a String method
authorDaniel Martí <mvdan@mvdan.cc>
Mon, 29 Jan 2018 09:50:50 +0000 (09:50 +0000)
committerIan Lance Taylor <iant@golang.org>
Tue, 30 Jan 2018 14:35:34 +0000 (14:35 +0000)
commit1f85917fb618a27222ba0253c5dd4fdfdbca2fd2
treedc709809b500b0ad6a33b08554f19131e9edafdb
parent8c1f21d9a2674dd9a410e0af94adf6fa7d2877d2
cmd/vet: **T is not Stringer if *T has a String method

vet recorded what types had String methods defined on them, but it did
not record whether the receivers were pointer types. That information is
important, as the following program is valid:

type T string

func (t *T) String() string {
return fmt.Sprint(&t) // prints address
}

Teach vet that, if *T is Stringer, **T is not.

Fixes #23550.

Change-Id: I1062e60e6d82e789af9cca396546db6bfc3541e8
Reviewed-on: https://go-review.googlesource.com/90417
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
src/cmd/vet/main.go
src/cmd/vet/print.go
src/cmd/vet/testdata/print.go