]> Cypherpunks repositories - gostls13.git/commitdiff
gc: better error message for bad type in channel send
authorAnthony Martin <ality@pbrane.org>
Mon, 22 Nov 2010 15:59:51 +0000 (10:59 -0500)
committerRuss Cox <rsc@golang.org>
Mon, 22 Nov 2010 15:59:51 +0000 (10:59 -0500)
# test program
1 package main
2
3 type C chan int
4
5 func F(c C) {
6  c <- true
7 }

# old error
test.go:6: cannot use true (type bool) as type int in function argument

# new error
test.go:6: cannot use true (type bool) as type int in channel send

R=rsc, ejsherry
CC=golang-dev
https://golang.org/cl/3231042

src/cmd/gc/typecheck.c

index 919d99ecf77edf413ee44b15f9abe6799d180e00..70464a4b7670e6eefcb60b1a8294429a451ac0cd 100644 (file)
@@ -656,6 +656,7 @@ reswitch:
                r = n->right;
                if((t = r->type) == T)
                        goto error;
+               r = assignconv(r, l->type->type, "send");
                // TODO: more aggressive
                n->etype = 0;
                n->type = T;