1
0
mirror of https://github.com/golang/go synced 2024-11-23 17:50:06 -07:00

go/types: more robust operand printing

Not a fix but useful for further debugging, and safe.

For #18643.

Change-Id: I5fb4f4a8662007a26e945fff3986347855f00eab
Reviewed-on: https://go-review.googlesource.com/46393
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Robert Griesemer 2017-06-21 16:20:00 -07:00
parent 7a2fb4048e
commit 1d3a0df4bb

View File

@ -122,13 +122,15 @@ func operandString(x *operand, qf Qualifier) string {
case invalid, novalue, builtin, typexpr: case invalid, novalue, builtin, typexpr:
// no type // no type
default: default:
// has type // should have a type, but be cautious (don't crash during printing)
if isUntyped(x.typ) { if x.typ != nil {
buf.WriteString(x.typ.(*Basic).name) if isUntyped(x.typ) {
buf.WriteByte(' ') buf.WriteString(x.typ.(*Basic).name)
break buf.WriteByte(' ')
break
}
hasType = true
} }
hasType = true
} }
// <mode> // <mode>