www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - opCast

This code:

//////////////////////////
class B
{
    void foo(int a) {}
}

class A:B {
    int opCast () { return 0; }
}

void main ()
{
    (new A).foo = 2;
}
//////////////////////////

Produces: "cannot implicitly convert expression new A .opCast() of type int to
B". If the opCast is moved to B, DMD crashes. If foo is moved to A, it works ok.

I'm using dmd 0.101, Windows XP. This bug seems to have been introduced by 0.99.

-----------------------
Carlos Santander Bernal
Sep 18 2004