]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: avoid panic when printing *<N>
authorJosh Bleecher Snyder <josharian@gmail.com>
Wed, 3 May 2017 14:45:20 +0000 (07:45 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Wed, 3 May 2017 14:59:29 +0000 (14:59 +0000)
commite41fb5591fa02f69b046a14048215f2d96414f96
tree6118c440f3bf3996aee940e5d957cebfb3850677
parent6e9b6e1d222a4f8ad3d50929ee1d6178fb3c6077
cmd/compile: avoid panic when printing *<N>

When compiling the program:

package p

func _(){
*;:=
}

Before:

x.go:4:3: syntax error: unexpected semicolon, expecting expression
x.go:4:4: non-name *%!v(PANIC=runtime error: invalid memory address or nil pointer dereference) on left side of :=
x.go:5:1: syntax error: unexpected }, expecting expression

After:

x.go:4:3: syntax error: unexpected semicolon, expecting expression
x.go:4:4: non-name *<N> on left side of :=
x.go:5:1: syntax error: unexpected }, expecting expression

No test because:

(1) we don't have a good mechanism to check for the
    absence of the string "PANIC" in an error message
(2) the string "*<N>", while better, is itself ugly enough
    that I don't want to actively check for it
(3) the bug isn't very important, the kind of thing only fuzzers encounter
(4) the fix is obvious and trivial

Fixes #20220

Change-Id: I35faa986b60b671414ee999d6264b06937f250e3
Reviewed-on: https://go-review.googlesource.com/42498
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/cmd/compile/internal/gc/fmt.go