]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: fix printing of untyped types in -W output
authorMatthew Dempsky <mdempsky@google.com>
Wed, 14 Feb 2018 21:51:51 +0000 (13:51 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 14 Feb 2018 22:18:07 +0000 (22:18 +0000)
It's always useful to distinguish "bool" and "string" from "untyped
bool" and "untyped string", so change typefmt to do this
unconditionally.

Also, while here, replace a bare 0 with its named constant FErr.

Fixes #23833.

Change-Id: I3fcb8d7204686937439caaaf8b3973fc236d0387
Reviewed-on: https://go-review.googlesource.com/94021
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/compile/internal/gc/fmt.go

index 4b2fdb0dca7e28670bf28bf210b4b0ac702c9771..2cebab28dd5e3933182a47d0d545f9db4d36498d 100644 (file)
@@ -701,15 +701,15 @@ func typefmt(t *types.Type, flag FmtFlag, mode fmtMode, depth int) string {
        }
 
        if int(t.Etype) < len(basicnames) && basicnames[t.Etype] != "" {
-               prefix := ""
-               if mode == FErr && (t == types.Idealbool || t == types.Idealstring) {
-                       prefix = "untyped "
+               name := basicnames[t.Etype]
+               if t == types.Idealbool || t == types.Idealstring {
+                       name = "untyped " + name
                }
-               return prefix + basicnames[t.Etype]
+               return name
        }
 
        if mode == FDbg {
-               return t.Etype.String() + "-" + typefmt(t, flag, 0, depth)
+               return t.Etype.String() + "-" + typefmt(t, flag, FErr, depth)
        }
 
        switch t.Etype {