]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc: fix <-<-expr
authorRuss Cox <rsc@golang.org>
Mon, 19 May 2014 19:08:04 +0000 (15:08 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 19 May 2014 19:08:04 +0000 (15:08 -0400)
The temporary-introducing pass was not recursing
into the argumnt of a receive operation.

Fixes #8011.

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews, iant, khr
https://golang.org/cl/91540043

src/cmd/gc/order.c
test/fixedbugs/issue8011.go [new file with mode: 0644]

index 1311c6e5e2da7ee8a7079d93b0bd43ec129eb666..b9f2d35ce4dca318ba1087ee3de3f7ff08c422ad 100644 (file)
@@ -1053,6 +1053,7 @@ orderexpr(Node **np, Order *order)
                break;
 
        case ORECV:
+               orderexpr(&n->left, order);
                n = ordercopyexpr(n, n->type, order, 1);
                break;
        }
diff --git a/test/fixedbugs/issue8011.go b/test/fixedbugs/issue8011.go
new file mode 100644 (file)
index 0000000..b966174
--- /dev/null
@@ -0,0 +1,18 @@
+// run
+
+// Copyright 2014 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+func main() {
+       c := make(chan chan int, 1)
+       c1 := make(chan int, 1)
+       c1 <- 42
+       c <- c1
+       x := <-<-c
+       if x != 42 {
+               println("BUG:", x, "!= 42")
+       }
+}