Commit 0d1f76de authored by Robert Griesemer's avatar Robert Griesemer

go/parser: accept parenthesized receive operations in select statements

R=rsc
CC=golang-dev
https://golang.org/cl/4439082
parent c1347186
......@@ -1780,10 +1780,6 @@ func (p *parser) parseCommClause() *ast.CommClause {
rhs = lhs[0]
lhs = nil // there is no lhs
}
if x, isUnary := rhs.(*ast.UnaryExpr); !isUnary || x.Op != token.ARROW {
p.errorExpected(rhs.Pos(), "send or receive operation")
rhs = &ast.BadExpr{rhs.Pos(), rhs.End()}
}
if lhs != nil {
comm = &ast.AssignStmt{lhs, pos, tok, []ast.Expr{rhs}}
} else {
......
......@@ -51,6 +51,7 @@ var validPrograms = []interface{}{
`package p; type T []int; func f() { for _ = range []int{T{42}[0]} {} };`,
`package p; var a = T{{1, 2}, {3, 4}}`,
`package p; func f() { select { case <- c: case c <- d: case c <- <- d: case <-c <- d: } };`,
`package p; func f() { select { case x := (<-c): } };`,
`package p; func f() { if ; true {} };`,
`package p; func f() { switch ; {} };`,
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment