]> Cypherpunks repositories - gostls13.git/commitdiff
go/parser: accept parenthesized receive operations in select statements
authorRobert Griesemer <gri@golang.org>
Fri, 29 Apr 2011 20:06:03 +0000 (13:06 -0700)
committerRobert Griesemer <gri@golang.org>
Fri, 29 Apr 2011 20:06:03 +0000 (13:06 -0700)
R=rsc
CC=golang-dev
https://golang.org/cl/4439082

src/pkg/go/parser/parser.go
src/pkg/go/parser/parser_test.go

index 5c57e41d130fa5fe7f39f5a5e593db23870adea2..afa9ae517b6f0ce2bf1f51e60a7d6c460227639c 100644 (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 {
index 2f1ee6bfc094594355ad638d5261916b4833ceb3..5b52f51d4a5776219f93d8e91364614d9df2bf97 100644 (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 ; {} };`,
 }