1
0
mirror of https://github.com/golang/go synced 2024-09-25 09:10:14 -06:00

gc: be more specific about copy type errors

Fixes #539.

R=ken2
CC=golang-dev
https://golang.org/cl/190043
This commit is contained in:
Russ Cox 2010-01-18 16:00:13 -08:00
parent da225c231f
commit 07fc145744

View File

@ -810,12 +810,19 @@ reswitch:
goto error;
toslice(&n->left);
toslice(&n->right);
defaultlit(&n->left, T);
defaultlit(&n->right, T);
if(!isslice(n->left->type) || !isslice(n->right->type)) {
yyerror("arguments to copy must be slices or array pointers");
if(!isslice(n->left->type) && !isslice(n->right->type))
yyerror("arguments to copy must be array pointer or slice; have %lT, %lT", n->left->type, n->right->type);
else if(!isslice(n->left->type))
yyerror("first argument to copy should be array pointer or slice; have %lT", n->left->type);
else
yyerror("second argument to copy should be array pointer or slice; have %lT", n->right->type);
goto error;
}
if(!eqtype(n->left->type, n->right->type)) {
yyerror("arguments to copy must have the same type element type");
yyerror("arguments to copy have different element types %lT and %lT", n->left->type, n->right->type);
goto error;
}
goto ret;