Commit 1d3a0df4 authored by Robert Griesemer's avatar Robert Griesemer

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: default avatarMatthew Dempsky <mdempsky@google.com>
parent 7a2fb404
...@@ -122,7 +122,8 @@ func operandString(x *operand, qf Qualifier) string { ...@@ -122,7 +122,8 @@ 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 x.typ != nil {
if isUntyped(x.typ) { if isUntyped(x.typ) {
buf.WriteString(x.typ.(*Basic).name) buf.WriteString(x.typ.(*Basic).name)
buf.WriteByte(' ') buf.WriteByte(' ')
...@@ -130,6 +131,7 @@ func operandString(x *operand, qf Qualifier) string { ...@@ -130,6 +131,7 @@ func operandString(x *operand, qf Qualifier) string {
} }
hasType = true hasType = true
} }
}
// <mode> // <mode>
buf.WriteString(operandModeString[x.mode]) buf.WriteString(operandModeString[x.mode])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment