Skip to content

Commit

Permalink
go/types: more robust operand printing
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
griesemer committed Jun 22, 2017
1 parent 7a2fb40 commit 1d3a0df
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/go/types/operand.go
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 1d3a0df

Please sign in to comment.