mirror of
https://github.com/golang/go
synced 2024-09-30 22:48:32 -06:00
go.tools/cmd/cover: handle empty select
Putting a coverage counter inside select{} is invalid Go. R=adonovan CC=golang-dev https://golang.org/cl/10175043
This commit is contained in:
parent
ba51e7a586
commit
73612ddbfd
@ -107,6 +107,16 @@ func (f *File) Visit(node ast.Node) ast.Visitor {
|
||||
}
|
||||
}
|
||||
n.List = f.addCounters(n.Pos(), n.End(), n.List)
|
||||
case *ast.SelectStmt:
|
||||
// Don't annotate an empty select - creates a syntax error.
|
||||
if n.Body == nil || len(n.Body.List) == 0 {
|
||||
return nil
|
||||
}
|
||||
case *ast.SwitchStmt:
|
||||
// Don't annotate an empty switch - creates a syntax error.
|
||||
if n.Body == nil || len(n.Body.List) == 0 {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return f
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user