Commit 3ea8d854 authored by Russ Cox's avatar Russ Cox

make string(array) take []byte only (and thus *[10]byte but not [10]byte)

R=ken
OCL=27581
CL=27585
parent e2bf2271
...@@ -1230,8 +1230,9 @@ walkconv(Node *n) ...@@ -1230,8 +1230,9 @@ walkconv(Node *n)
indir(n, stringop(n, Erv)); indir(n, stringop(n, Erv));
return; return;
} }
if(et == TARRAY) // can convert []byte and *[10]byte
if(istype(l->type->type, TUINT8)) { if((isptr[et] && isfixedarray(l->type->type) && istype(l->type->type->type, TUINT8))
|| (isslice(l->type) && istype(l->type->type, TUINT8))) {
n->op = OARRAY; n->op = OARRAY;
indir(n, stringop(n, Erv)); indir(n, stringop(n, Erv));
return; return;
...@@ -1267,6 +1268,9 @@ walkconv(Node *n) ...@@ -1267,6 +1268,9 @@ walkconv(Node *n)
} }
bad: bad:
if(n->diag)
return;
n->diag = 1;
if(l->type != T) if(l->type != T)
yyerror("invalid conversion: %T to %T", l->type, t); yyerror("invalid conversion: %T to %T", l->type, t);
else else
...@@ -2204,8 +2208,6 @@ stringop(Node *n, int top) ...@@ -2204,8 +2208,6 @@ stringop(Node *n, int top)
case OARRAY: case OARRAY:
// arraystring([]byte) string; // arraystring([]byte) string;
r = n->left; r = n->left;
if(isfixedarray(r->type))
r = nod(OADDR, r, N);
on = syslook("arraystring", 0); on = syslook("arraystring", 0);
r = nod(OCALL, on, r); r = nod(OCALL, on, r);
break; break;
......
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