]> Cypherpunks repositories - gostls13.git/commitdiff
gc: fix error for 1 <- "foo"
authorRuss Cox <rsc@golang.org>
Thu, 7 Oct 2010 07:33:42 +0000 (03:33 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 7 Oct 2010 07:33:42 +0000 (03:33 -0400)
was
x.go:4: invalid operation: 1 <- "foo" (send to receive-only type int)

now
x.go:4: invalid operation: 1 <- "foo" (send to non-chan type int)

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

src/cmd/gc/typecheck.c

index bb4571d9ff2ea497631f27995887fa862e7b9e23..f139ee8210233dd2f375dbd9c87383c20108b421 100644 (file)
@@ -644,6 +644,10 @@ reswitch:
                l = n->left;
                if((t = l->type) == T)
                        goto error;
+               if(t->etype != TCHAN) {
+                       yyerror("invalid operation: %#N (send to non-chan type %T)", n, t);
+                       goto error;
+               }
                if(!(t->chan & Csend)) {
                        yyerror("invalid operation: %#N (send to receive-only type %T)", n, t);
                        goto error;