From: Aliaksandr Valialkin Date: Mon, 29 May 2017 16:50:24 +0000 (+0300) Subject: cmd/vet: add a test for embedded stringer X-Git-Tag: go1.9beta1~140 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=708a01fbf40cfd82675923f88dd306ef6eb17114;p=gostls13.git cmd/vet: add a test for embedded stringer This should help narrowing down the possible cause of #20514. Updates #20514. Change-Id: Ie997400c9749aace7783bd585b23dbb4cefc181d Reviewed-on: https://go-review.googlesource.com/44375 Reviewed-by: Josh Bleecher Snyder Reviewed-by: Rob Pike Run-TryBot: Josh Bleecher Snyder TryBot-Result: Gobot Gobot --- diff --git a/src/cmd/vet/testdata/print.go b/src/cmd/vet/testdata/print.go index b5c59ebd1b..76e7bd71f1 100644 --- a/src/cmd/vet/testdata/print.go +++ b/src/cmd/vet/testdata/print.go @@ -87,6 +87,9 @@ func PrintfTests() { fmt.Printf("%s", &stringerv) fmt.Printf("%v", &stringerv) fmt.Printf("%T", &stringerv) + fmt.Printf("%s", &embeddedStringerv) + fmt.Printf("%v", &embeddedStringerv) + fmt.Printf("%T", &embeddedStringerv) fmt.Printf("%v", notstringerv) fmt.Printf("%T", notstringerv) fmt.Printf("%q", stringerarrayv) @@ -123,6 +126,8 @@ func PrintfTests() { fmt.Printf("%X", 2.3) // ERROR "arg 2.3 for printf verb %X of wrong type" fmt.Printf("%s", stringerv) // ERROR "arg stringerv for printf verb %s of wrong type" fmt.Printf("%t", stringerv) // ERROR "arg stringerv for printf verb %t of wrong type" + fmt.Printf("%s", embeddedStringerv) // ERROR "arg embeddedStringerv for printf verb %s of wrong type" + fmt.Printf("%t", embeddedStringerv) // ERROR "arg embeddedStringerv for printf verb %t of wrong type" fmt.Printf("%q", notstringerv) // ERROR "arg notstringerv for printf verb %q of wrong type" fmt.Printf("%t", notstringerv) // ERROR "arg notstringerv for printf verb %t of wrong type" fmt.Printf("%t", stringerarrayv) // ERROR "arg stringerarrayv for printf verb %t of wrong type" @@ -346,6 +351,14 @@ func (*stringer) Warnf(int, string, ...interface{}) string { return "warnf" } +type embeddedStringer struct { + foo string + stringer + bar int +} + +var embeddedStringerv embeddedStringer + type notstringer struct { f float64 }