diff options
| author | Robert Griesemer <gri@golang.org> | 2017-06-21 16:20:00 -0700 |
|---|---|---|
| committer | Robert Griesemer <gri@golang.org> | 2017-06-22 03:53:04 +0000 |
| commit | 1d3a0df4bb77af0158d25854c85ad87cc36fe8dc (patch) | |
| tree | 33134546e50382a639446e53e5bda7511a49e28b | |
| parent | 7a2fb4048e4f16c5cad5e90f87a62afd199d3367 (diff) | |
| download | go-1d3a0df4bb77af0158d25854c85ad87cc36fe8dc.tar.xz | |
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>
| -rw-r--r-- | src/go/types/operand.go | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/go/types/operand.go b/src/go/types/operand.go index b2f16b64d8..07247bd6f5 100644 --- a/src/go/types/operand.go +++ b/src/go/types/operand.go @@ -122,13 +122,15 @@ func operandString(x *operand, qf Qualifier) string { case invalid, novalue, builtin, typexpr: // no type default: - // has type - if isUntyped(x.typ) { - buf.WriteString(x.typ.(*Basic).name) - buf.WriteByte(' ') - break + // should have a type, but be cautious (don't crash during printing) + if x.typ != nil { + if isUntyped(x.typ) { + buf.WriteString(x.typ.(*Basic).name) + buf.WriteByte(' ') + break + } + hasType = true } - hasType = true } // <mode> |
