]> Cypherpunks.ru repositories - gostls13.git/commitdiff
gc: allow select case expr = <-c
authorRuss Cox <rsc@golang.org>
Mon, 27 Sep 2010 16:04:21 +0000 (12:04 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 27 Sep 2010 16:04:21 +0000 (12:04 -0400)
Fixes #1139.

R=ken2
CC=golang-dev
https://golang.org/cl/2194046

src/cmd/gc/go.y
test/chan/select4.go [new file with mode: 0644]

index 6bc63e91182a6e03eca69bbfc16822e56a72e7a8..b6774c1dd0985818d9494d9343751873212ed8e7 100644 (file)
@@ -461,7 +461,7 @@ case:
                }
                break;
        }
-|      LCASE name '=' expr ':'
+|      LCASE expr '=' expr ':'
        {
                // will be converted to OCASE
                // right will point to next case
diff --git a/test/chan/select4.go b/test/chan/select4.go
new file mode 100644 (file)
index 0000000..46618ac
--- /dev/null
@@ -0,0 +1,25 @@
+// $G $D/$F.go && $L $F.$A && ./$A.out
+
+package main
+
+func f() *int {
+       println("BUG: called f")
+       return new(int)
+}
+
+func main() {
+       var x struct {
+               a int
+       }
+       c := make(chan int, 1)
+       c1 := make(chan int)
+       c <- 42
+       select {
+       case *f() = <-c1:
+               // nothing
+       case x.a = <-c:
+               if x.a != 42 {
+                       println("BUG:", x.a)
+               }
+       }
+}