]> Cypherpunks repositories - gostls13.git/commit
cmd/compile/internal/gc: fix panic in Type Stringer
authorDidier Spezia <didier.06@gmail.com>
Sat, 29 Aug 2015 11:30:10 +0000 (11:30 +0000)
committerRuss Cox <rsc@golang.org>
Mon, 7 Dec 2015 20:18:03 +0000 (20:18 +0000)
commit7ebb96a4890de3245f00cfb969945ff2438cc267
treedcf6ea6c22a510d1b54472d383b70be5cd16afee
parent423b0cc25ad8f75825db70a370ea9b696a17074d
cmd/compile/internal/gc: fix panic in Type Stringer

The following code:

func n() {(interface{int})}

generates:

3: interface contains embedded non-interface int
3: type %!v(PANIC=runtime error: invalid memory address or nil pointer dereference) is not an expression

It is because the corresponding symbol (Sym field in Type object)
is nil, resulting in a panic in typefmt.

Just skip the symbol if it is nil, so that the error message becomes:

3: interface contains embedded non-interface int
3: type interface { int } is not an expression

Fixes #11614

Change-Id: I219ae7eb01edca264fad1d4a1bd261d026294b00
Reviewed-on: https://go-review.googlesource.com/14015
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
src/cmd/compile/internal/gc/fmt.go
test/fixedbugs/issue11614.go [new file with mode: 0644]