Am 03.11.2010 13:07, schrieb zhang:
This code belown can be compiled with DMD 2.050. However, it throws an error 
message:
core.exception.HiddenFuncError: Hidden method called for main.AClass

I'm not sure about whether it is a bug. Thanks for any help.



import std.stdio;

class AClass
{
     int data;

// It's wrong
     bool opEquals(AClass a)
     {
         writefln("running here.");
         return data == a.data;
     }

// It works
//    bool opEquals(Object a)
//    {
//        writefln("running here.");
//        return data == (cast(AClass)a).data;
//    }

}


int main(string[] args)
{

     AClass class1 = new AClass();
     AClass class2 = new AClass();

     if(class1 == class2)
         writefln("==");
     else
         writefln("!=");

     return 0;
}

----------
Zhang<[email protected]>

s

I'm not shure if it is a bug or not, but to fix it you could add "alias object.opEquals opEquals;" before your first opEquals. Had that already many times, it also happens a lot with opCmp.

--
Kind Regards
Benjamin Thaut

Reply via email to