1
0
mirror of https://github.com/golang/go synced 2024-11-18 17:04:41 -07: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:
Rob Pike 2013-06-10 15:58:32 -07:00
parent ba51e7a586
commit 73612ddbfd

View File

@ -107,6 +107,16 @@ func (f *File) Visit(node ast.Node) ast.Visitor {
} }
} }
n.List = f.addCounters(n.Pos(), n.End(), n.List) 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 return f
} }