]> Cypherpunks repositories - gostls13.git/commitdiff
fmt: fix internal unknownType function
authorRob Pike <r@golang.org>
Wed, 1 Oct 2014 21:35:12 +0000 (21:35 +0000)
committerRob Pike <r@golang.org>
Wed, 1 Oct 2014 21:35:12 +0000 (21:35 +0000)
This thing should never be called, but before
151960044 it was being called, incorrectly.
This is now just a precaution but let's pretend it
Fixes #8843
even though that was fixed by 151960044.
The test case was already there and ran, another mystery.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/151970043

src/fmt/print.go

index 679c577dbd1aad806ff0c243a60ab82a011cf11e..de69e90fb79f4541438df280ad37d51e3b7b53ce 100644 (file)
@@ -297,13 +297,13 @@ func parsenum(s string, start, end int) (num int, isnum bool, newi int) {
        return
 }
 
-func (p *pp) unknownType(v interface{}) {
-       if v == nil {
+func (p *pp) unknownType(v reflect.Value) {
+       if !v.IsValid() {
                p.buf.Write(nilAngleBytes)
                return
        }
        p.buf.WriteByte('?')
-       p.buf.WriteString(reflect.TypeOf(v).String())
+       p.buf.WriteString(v.Type().String())
        p.buf.WriteByte('?')
 }