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:
parent
87e741c38f
commit
9d6cc5fd08
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -2118,3 +2118,8 @@ var _ = func() int {
|
|||
}
|
||||
println() // ok
|
||||
}
|
||||
|
||||
var _ = func() {
|
||||
// goto without label used to panic
|
||||
goto
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue