From 42c26b734cf8cf148cf08ae30bf1e05a29bc8851 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 7 Oct 2010 03:33:42 -0400 Subject: [PATCH] gc: fix error for 1 <- "foo" 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 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cmd/gc/typecheck.c b/src/cmd/gc/typecheck.c index bb4571d9ff2..f139ee82102 100644 --- a/src/cmd/gc/typecheck.c +++ b/src/cmd/gc/typecheck.c @@ -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;