Fix dmd bug 7504: Cannot assign an object of type 'typeof(null)' to an array

This commit is contained in:
Alexey Prokhin 2012-04-21 18:24:10 +04:00
parent 8364ad4675
commit d739588d4a

View file

@ -748,6 +748,15 @@ DValue* DtoCastNull(Loc& loc, DValue* val, Type* to)
LLValue *rval = DtoBitCast(val->getRVal(), tolltype);
return new DImValue(to, rval);
}
if (totype->ty == Tarray)
{
if (Logger::enabled())
Logger::cout() << "cast null to array: " << *tolltype << '\n';
LLValue *rval = val->getRVal();
rval = DtoBitCast(rval, DtoType(to->nextOf()->pointerTo()));
rval = DtoAggrPair(DtoConstSize_t(0), rval, "null_array");
return new DImValue(to, rval);
}
else
{
error(loc, "invalid cast from null to '%s'", to->toChars());