1
0
mirror of https://github.com/golang/go synced 2024-11-21 17:54:39 -07:00

gc: fix copy([]int, string) error message

R=rsc
CC=golang-dev
https://golang.org/cl/4433064
This commit is contained in:
Quan Yong Zhai 2011-04-21 12:09:29 -04:00 committed by Russ Cox
parent 29d78f1243
commit 256df10eae

View File

@ -1006,9 +1006,13 @@ reswitch:
defaultlit(&n->right, T);
// copy([]byte, string)
if(isslice(n->left->type) && n->left->type->type == types[TUINT8] && n->right->type->etype == TSTRING)
goto ret;
if(isslice(n->left->type) && n->right->type->etype == TSTRING) {
if (n->left->type->type ==types[TUINT8])
goto ret;
yyerror("arguments to copy have different element types: %lT and string", n->left->type);
goto error;
}
if(!isslice(n->left->type) || !isslice(n->right->type)) {
if(!isslice(n->left->type) && !isslice(n->right->type))
yyerror("arguments to copy must be slices; have %lT, %lT", n->left->type, n->right->type);