]> Cypherpunks repositories - gostls13.git/commit
fmt: fix %d and other non-string verbs on errors
authorDamien Neil <dneil@google.com>
Thu, 28 Feb 2019 17:10:36 +0000 (09:10 -0800)
committerDamien Neil <dneil@google.com>
Thu, 28 Feb 2019 17:31:37 +0000 (17:31 +0000)
commit444039e0546c3db1e8f73fb0a74ed21e45a09cb9
tree8549079be800a1df9ad2f381d7f202ea480e0b11
parent72d24a7484063d1ca1113badb481f725382e39b8
fmt: fix %d and other non-string verbs on errors

When formatting an error with a non-string formatting verb such as %d,
use the default formatting behavior rather than treating this as a bad
verb.

For example, this should print 42, not %!d(main.E=42):

  var E int
  func (E) Error() string { return "error" }
  fmt.Printf("%d", E(42))

Fixes #30472

Change-Id: I62fd309c8ee9839a69052b0ec7f1808449dcee8e
Reviewed-on: https://go-review.googlesource.com/c/164557
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/fmt/errors.go
src/fmt/errors_test.go