mirror of
https://github.com/golang/go
synced 2024-11-11 19:51:37 -07:00
gc: Better error message for range over non-receive channel.
Fixes #2354 R=rsc CC=golang-dev https://golang.org/cl/5346044
This commit is contained in:
parent
0d6f857c3f
commit
ea9e93862d
@ -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)
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user