January 10, 2005
This works:

class A
{}

class B : A
{}

void main()
{
    B b=new B;
    A a=cast(A)b;
    a=null;
}

Change main() to this, however:

void main()
{
    B b=new B;
    cast(A)b=null;
}

And it flags it as an error.

This also makes it impossible to do something like:

void fork(inout A a)
{}

void main()
{
    B b=new B;
    fork(b);  // explicitly casting doesn't work either
}

It also has this problem if A is an interface.


January 11, 2005
Added to DStress as

http://dstress.kuehne.cn/run/cast_08.d http://dstress.kuehne.cn/run/cast_09.d http://dstress.kuehne.cn/run/cast_10.d

Thomas