summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmd/gc/range.c4
-rw-r--r--test/chan/perm.go5
2 files changed, 8 insertions, 1 deletions
diff --git a/src/cmd/gc/range.c b/src/cmd/gc/range.c
index 1909c9ec7..25d1131ec 100644
--- a/src/cmd/gc/range.c
+++ b/src/cmd/gc/range.c
@@ -46,6 +46,10 @@ typecheckrange(Node *n)
break;
case TCHAN:
+ if(!(t->chan & Crecv)) {
+ yyerror("invalid operation: range %N (receive from send-only type %T)", n->right, n->right->type);
+ goto out;
+ }
t1 = t->type;
t2 = nil;
if(count(n->list) == 2)
diff --git a/test/chan/perm.go b/test/chan/perm.go
index af054450e..a43df1982 100644
--- a/test/chan/perm.go
+++ b/test/chan/perm.go
@@ -48,7 +48,10 @@ func main() {
case x := <-cs: // ERROR "receive"
_ = x
}
-
+
+ for _ = range cs {// ERROR "receive"
+ }
+
close(c)
close(cs)
close(cr) // ERROR "receive"