From 256df10eae78fd0cbb4f41960a3a8ad9f7cc63ae Mon Sep 17 00:00:00 2001 From: Quan Yong Zhai Date: Thu, 21 Apr 2011 12:09:29 -0400 Subject: [PATCH] gc: fix copy([]int, string) error message R=rsc CC=golang-dev https://golang.org/cl/4433064 --- src/cmd/gc/typecheck.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cmd/gc/typecheck.c b/src/cmd/gc/typecheck.c index 42e177e211..beabfcae0e 100644 --- a/src/cmd/gc/typecheck.c +++ b/src/cmd/gc/typecheck.c @@ -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); -- 2.50.0