Commit 01c2de0c authored by Ken Thompson's avatar Ken Thompson

allow copy to be used without a return value

R=rsc
https://golang.org/cl/156060
parent 41554e25
...@@ -762,7 +762,7 @@ reswitch: ...@@ -762,7 +762,7 @@ reswitch:
goto ret; goto ret;
case OCOPY: case OCOPY:
ok |= Erv; ok |= Etop|Erv;
args = n->list; args = n->list;
if(args == nil || args->next == nil) { if(args == nil || args->next == nil) {
yyerror("missing arguments to copy"); yyerror("missing arguments to copy");
...@@ -772,19 +772,19 @@ reswitch: ...@@ -772,19 +772,19 @@ reswitch:
yyerror("too many arguments to copy"); yyerror("too many arguments to copy");
goto error; goto error;
} }
typecheck(&args->n, Erv); n->left = args->n;
typecheck(&args->next->n, Erv); n->right = args->next->n;
if(!isslice(args->n->type) || !isslice(args->next->n->type)) { n->type = types[TINT];
typecheck(&n->left, Erv);
typecheck(&n->right, Erv);
if(!isslice(n->left->type) || !isslice(n->right->type)) {
yyerror("arguments to copy must be slices"); yyerror("arguments to copy must be slices");
goto error; goto error;
} }
if(!eqtype(args->n->type, args->next->n->type)) { if(!eqtype(n->left->type, n->right->type)) {
yyerror("arguments to copy must be slices of the same type"); yyerror("arguments to copy must be slices of the same type");
goto error; goto error;
} }
n->left = args->n;
n->right = args->next->n;
n->type = types[TINT];
goto ret; goto ret;
case OCONV: case OCONV:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment