www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 958] New: opEquals and opCmp doesn't take Object anymore

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=958

           Summary: opEquals and opCmp doesn't take Object anymore
           Product: D
           Version: 1.005
          Platform: PC
               URL: http://www.digitalmars.com/d/operatoroverloading.html
        OS/Version: Windows
            Status: NEW
          Keywords: spec
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: torhu yahoo.com


class C {
        bool opCmp(Object) { return true; }
}

void main()
{
        C c1 = new C;
        C c2 = new C;

        if (c1 == c2) { }
}

This produces the error:
opcmp.d(2): function opcmp.C.opCmp of type bool(Object) overrides but is not
cov
ariant with object.Object.opCmp of type int(Object o)

The same thing applies to opEquals.  So the section called "Overloading == and
!=" is doesn't match the compiler's behavior anymore.


-- 
Feb 13 2007
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=958


torhu yahoo.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID





Nevermind.  I used 'bool opCmp(Object)' instead of 'int opCmp(Object)'.  How
embarrassing.


-- 
Feb 13 2007