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:
parent
c134718611
commit
0d1f76ded2
@ -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 ; {} };`,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user