From 07fc1457441110648abf4f01eced1741d509154e Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 18 Jan 2010 16:00:13 -0800 Subject: [PATCH] gc: be more specific about copy type errors Fixes #539. R=ken2 CC=golang-dev https://golang.org/cl/190043 --- src/cmd/gc/typecheck.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cmd/gc/typecheck.c b/src/cmd/gc/typecheck.c index c63480faa2..0c18097dac 100644 --- a/src/cmd/gc/typecheck.c +++ b/src/cmd/gc/typecheck.c @@ -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;