summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-09-13 15:42:14 -0400
committerRuss Cox <rsc@golang.org>2010-09-13 15:42:14 -0400
commit30e0a765ad096eabf4a27fa25109c36293238a40 (patch)
treefb6deccfc2c572741ed57a765a07278cbe8bcccb
parent94443dcef6d965bd9b279309a71b645845a8b79a (diff)
downloadgo-30e0a765ad096eabf4a27fa25109c36293238a40.tar.gz
gc: bug306
Fixes issue 1040. R=ken2 CC=golang-dev http://codereview.appspot.com/2132047
-rw-r--r--src/cmd/gc/print.c2
-rw-r--r--src/cmd/gc/subr.c2
-rw-r--r--test/fixedbugs/bug306.dir/p1.go9
-rw-r--r--test/fixedbugs/bug306.dir/p2.go8
-rw-r--r--test/fixedbugs/bug306.go7
5 files changed, 26 insertions, 2 deletions
diff --git a/src/cmd/gc/print.c b/src/cmd/gc/print.c
index bb6ebfe36..5db118f06 100644
--- a/src/cmd/gc/print.c
+++ b/src/cmd/gc/print.c
@@ -192,7 +192,7 @@ exprfmt(Fmt *f, Node *n, int prec)
exprfmt(f, n->left, 0);
} else {
fmtprint(f, " ");
- if(n->left->op == OTCHAN && n->left->etype == Crecv) {
+ if(n->left->op == OTCHAN && n->left->sym == S && n->left->etype == Crecv) {
fmtprint(f, "(");
exprfmt(f, n->left, 0);
fmtprint(f, ")");
diff --git a/src/cmd/gc/subr.c b/src/cmd/gc/subr.c
index 9c9377c4f..d938c2d65 100644
--- a/src/cmd/gc/subr.c
+++ b/src/cmd/gc/subr.c
@@ -1161,7 +1161,7 @@ Tpretty(Fmt *fp, Type *t)
case Csend:
return fmtprint(fp, "chan<- %T", t->type);
}
- if(t->type != T && t->type->etype == TCHAN && t->type->chan == Crecv)
+ if(t->type != T && t->type->etype == TCHAN && t->type->sym == S && t->type->chan == Crecv)
return fmtprint(fp, "chan (%T)", t->type);
return fmtprint(fp, "chan %T", t->type);
diff --git a/test/fixedbugs/bug306.dir/p1.go b/test/fixedbugs/bug306.dir/p1.go
new file mode 100644
index 000000000..bf87ea149
--- /dev/null
+++ b/test/fixedbugs/bug306.dir/p1.go
@@ -0,0 +1,9 @@
+// Copyright 2010 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 p1
+
+type T <-chan int
+var x = make(chan T)
+
diff --git a/test/fixedbugs/bug306.dir/p2.go b/test/fixedbugs/bug306.dir/p2.go
new file mode 100644
index 000000000..3f8bd9d49
--- /dev/null
+++ b/test/fixedbugs/bug306.dir/p2.go
@@ -0,0 +1,8 @@
+// Copyright 2010 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 p2
+
+import _ "./p1"
+
diff --git a/test/fixedbugs/bug306.go b/test/fixedbugs/bug306.go
new file mode 100644
index 000000000..a0a43507d
--- /dev/null
+++ b/test/fixedbugs/bug306.go
@@ -0,0 +1,7 @@
+// $G $D/$F.dir/p1.go && $G $D/$F.dir/p2.go
+
+// Copyright 2010 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.
+
+ignored