mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-04 17:11:44 +03:00
Fix dmd bug 7504: Cannot assign an object of type 'typeof(null)' to an array
This commit is contained in:
parent
8364ad4675
commit
d739588d4a
1 changed files with 9 additions and 0 deletions
|
@ -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());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue