go.tools/cmd/vet: prevent panic on goto without label

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/107260043
This commit is contained in:
Josh Bleecher Snyder 2014-06-20 11:08:45 -07:00
parent 87e741c38f
commit 9d6cc5fd08
2 changed files with 8 additions and 1 deletions

View File

@ -81,7 +81,9 @@ func (d *deadState) findLabels(stmt ast.Stmt) {
case *ast.BranchStmt:
switch x.Tok {
case token.GOTO:
d.hasGoto[x.Label.Name] = true
if x.Label != nil {
d.hasGoto[x.Label.Name] = true
}
case token.BREAK:
stmt := d.breakTarget

View File

@ -2118,3 +2118,8 @@ var _ = func() int {
}
println() // ok
}
var _ = func() {
// goto without label used to panic
goto
}