www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Certain upcasted class syntax cannot be an lvalue

reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
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.
Jan 09 2005
parent Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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

-----BEGIN PGP SIGNATURE-----

iD8DBQFB40+M3w+/yD4P9tIRAtYkAKCoOs16eHd8usmDxA1wlaD0KuCV7gCghekM
CjfWL0DqBpTk+o22F1CNx00=
=LPLU
-----END PGP SIGNATURE-----
Jan 10 2005