1
0
mirror of https://github.com/golang/go synced 2024-11-19 22:54:39 -07:00

go/parser: accept parenthesized receive operations in select statements

R=rsc
CC=golang-dev
https://golang.org/cl/4439082
This commit is contained in:
Robert Griesemer 2011-04-29 13:06:03 -07:00
parent c134718611
commit 0d1f76ded2
2 changed files with 1 additions and 4 deletions

View File

@ -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 {

View File

@ -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 ; {} };`,
}