]> Cypherpunks repositories - gostls13.git/commit
cmd/vet: %s is valid for an array of stringer
authorDaniel Martí <mvdan@mvdan.cc>
Mon, 29 Jan 2018 09:24:51 +0000 (09:24 +0000)
committerIan Lance Taylor <iant@golang.org>
Tue, 30 Jan 2018 14:36:11 +0000 (14:36 +0000)
commit4072608b58e32b761068538f254799669fdb9b1a
tree025747cb0d432252887b5d5526e9ca86cc716e88
parent1f85917fb618a27222ba0253c5dd4fdfdbca2fd2
cmd/vet: %s is valid for an array of stringer

vet was quiet for []stringer, but not for [N]stringer. The source of the
problem was how the recursive call used .Elem().Underlying() for arrays,
but .Elem() for slices. In the first case, the named type is dropped,
thus losing all information of attached methods.

Be consistent across slices and arrays, by dropping the Underlying call
that is causing trouble. Add regression tests too, including cases where
the element type does not implement fmt.Stringer.

Fixes #23552.

Change-Id: I0fde07d101f112d5768be0a79207ef0b3dc45f2e
Reviewed-on: https://go-review.googlesource.com/90455
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/testdata/print.go
src/cmd/vet/types.go