January 10, 2005 Certain upcasted class syntax cannot be an lvalue | ||||
|---|---|---|---|---|
| ||||
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 Re: Certain upcasted class syntax cannot be an lvalue | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley Attachments: | 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 | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply