when implicit assignment would have been okay.
R=ken
OCL=31225
CL=31227
t, iface, m->sym, m->type);
else if(!p->explicit && needexplicit) {
if(m)
- yyerror("need explicit conversion to use %T as %T\n\tmissing %S%hhT",
+ yyerror("need type assertion to use %T as %T\n\tmissing %S%hhT",
p->src, p->dst, m->sym, m->type);
else
- yyerror("need explicit conversion to use %T as %T",
+ yyerror("need type assertion to use %T as %T",
p->src, p->dst);
}
}
// if using .(T), interface assertion.
if(n->op == ODOTTYPE) {
- // interface conversion
defaultlit(l, T);
if(!isinter(l->type))
yyerror("type assertion requires interface on left, have %T", l->type);
n->op = OCONVNOP;
return;
}
+
+ // to/from interface.
+ // ifaceas1 will generate a good error
+ // if the conversion is invalid.
+ if(t->etype == TINTER || l->type->etype == TINTER) {
+ indir(n, ifacecvt(t, l, ifaceas1(t, l->type, 0)));
+ return;
+ }
// simple fix-float
if(isint[l->type->etype] || isfloat[l->type->etype])
resp.AddHeader(key, value);
}
- // TODO(rsc): Make this work:
- // r := io.Reader(reader);
- var r io.Reader = reader;
+ r := io.Reader(reader);
if v := resp.GetHeader("Transfer-Encoding"); v == "chunked" {
r = newChunkedReader(reader);
}
var i I
type I2 interface { M(); N(); }
-var i2 I2;
+var i2 I2
-var e interface { };
+type E interface { }
+var e E
func main() {
e = t; // ok
- t = e; // ERROR "need explicit"
+ t = e; // ERROR "need explicit|need type assertion"
// neither of these can work,
// because i has an extra method
t = i; // ERROR "missing|incompatible|is not"
i = i2; // ok
- i2 = i; // ERROR "need explicit"
+ i2 = i; // ERROR "need explicit|need type assertion"
+
+ i = I(i2); // ok
+ i2 = I2(i); // ERROR "need explicit|need type assertion"
+
+ e = E(t); // ok
+ t = T(e); // ERROR "need explicit|need type assertion"
}