www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10549] New: Default object equality test not properly implemented


           Summary: Default object equality test not properly implemented
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: nobody puremagic.com
        ReportedBy: anoneuron gmail.com

--- Comment #0 from anoneuron gmail.com 2013-07-05 04:46:49 PDT ---
In the base object class ("Object") the opEquals overload (which is inherited
as the default EqualExpression operation for objects) does not appear to be
implemented the way it is described.

The function is defined in object_.d
as this:
* Returns !=0 if this object does have the same contents as obj.
bool opEquals(Object o)
    return this is o;

(I'm not exactly sure what "!=0" is supposed to mean there, but I'll take it to
mean "true").
As I understand it, the "is" operator tests whether two object references refer
to the same instance, not whether "this object does have the same contents as

This also contradicts the official description of EqualExpression
"For class objects, the == and != operators compare the contents of the
Clearly, this functionality is not satisfied by an IdentityExpression.

Perhaps something like "this.tupleof == o.tupleof" would be more appropriate?

Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 05 2013