]> Cypherpunks repositories - gostls13.git/commitdiff
gc: fix copy([]int, string) error message
authorQuan Yong Zhai <qyzhai@gmail.com>
Thu, 21 Apr 2011 16:09:29 +0000 (12:09 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 21 Apr 2011 16:09:29 +0000 (12:09 -0400)
R=rsc
CC=golang-dev
https://golang.org/cl/4433064

src/cmd/gc/typecheck.c

index 42e177e211c9e6d0ea708a12d19d850c09365021..beabfcae0e970dea309c5d93d511cb9185e0ee09 100644 (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);