Thread overview
[Issue 288] New: type of opEquals
Aug 15, 2006
d-bugmail
Aug 17, 2006
d-bugmail
Aug 18, 2006
Thomas Kuehne
Sep 03, 2008
d-bugmail
Apr 03, 2009
d-bugmail
August 15, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=288

           Summary: type of opEquals
           Product: D
           Version: 0.163
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: thomas-dloop@kuehne.cn


Bruno Medeiros schrieb am 2006-08-14:
> I don't think this test case is correct. You test the type-of a TypeInfo (which is an Object) equality operation vs the type-of an int(which is a primitive type) equality operation. Nothing says that such type-of should be the same (even though I very much think it should).
>
> What I do think is not correct is the following (second line) :
>
> writefln( typeid(typeof(typeid(int) == typeid(char))) );// int
> writefln( typeid(typeof(typeid(int) == typeid(int))) );//bool INCORRECT?
> writefln( typeid(typeof(new Object == new Object)) ); // int
>
> writefln( typeid(typeof(typeid(int) != typeid(char))) ); // bool
> writefln( typeid(typeof(typeid(int) != typeid(int))) );  // bool
> writefln( typeid(typeof(new Object != new Object)) ); // bool

http://www.digitalmars.com/d/expression.html#EqualExpression
#
# Equality expressions compare the two operands for equality (==) or
# inequality (!=). The type of the result is bool.
#

Thus samples 1 and 3 are incorrect.

Sources with issues:
dmd-0.164/src/dmd/typinf.c:341:     *   int function(void*,void*) xopEquals;
dmd-0.164/src/phobos/std/bitarray.d:289:    int opEquals(BitArray a2)
dmd-0.164/src/phobos/std/boxer.d:323:    bool opEquals(Box other)
dmd-0.164/src/phobos/object.d:23:    int opEquals(Object o);
dmd-0.164/src/phobos/object.d:109:    int function(void*,void*) xopEquals;
dmd-0.164/src/phobos/internal/object.d:123:    int opEquals(Object o)
dmd-0.164/src/phobos/internal/object.d:181:    int opEquals(Object o)
dmd-0.164/src/phobos/internal/object.d:570:    int function(void*,void*)
xopEquals;

Added to DStress as http://dstress.kuehne.cn/run/o/opEquals_05_A.d http://dstress.kuehne.cn/run/o/opEquals_05_B.d http://dstress.kuehne.cn/run/o/opEquals_05_C.d http://dstress.kuehne.cn/run/o/opEquals_05_D.d http://dstress.kuehne.cn/run/o/opEquals_05_E.d http://dstress.kuehne.cn/run/o/opEquals_05_F.d http://dstress.kuehne.cn/run/o/opEquals_05_G.d http://dstress.kuehne.cn/run/o/opEquals_05_H.d


-- 

August 17, 2006
http://d.puremagic.com/issues/show_bug.cgi?id=288


smjg@iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg@iname.com




------- Comment #1 from smjg@iname.com  2006-08-17 06:16 -------
AIUI all expressions involving == and != are supposed to be of type bool.

The fact that Object.opEquals is of type int is another matter.  See digitalmars.D.bugs:7933, "int opEquals(Object), and other legacy ints".  Walter claimed it's "for efficiency reasons", but the cited efficiency reasons don't work here for as long as it's opEquals rather than opNotEquals.


-- 

August 18, 2006
d-bugmail@puremagic.com schrieb am 2006-08-17:
> http://d.puremagic.com/issues/show_bug.cgi?id=288

> AIUI all expressions involving == and != are supposed to be of type bool.
>
> The fact that Object.opEquals is of type int is another matter.

http://www.digitalmars.com/d/expression.html#EqualExpression
> For class and struct objects, the expression (a == b)  is rewritten
> as a.opEquals(b), and (a != b) is rewritten as !a.opEquals(b)

Thus opEquals should return a boolean result.

Thomas

September 03, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=288





------- Comment #3 from gide@nwawudu.com  2008-09-03 08:08 -------
*** Bug 1989 has been marked as a duplicate of this bug. ***


-- 

April 03, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=288


gide@nwawudu.com changed:

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




------- Comment #4 from gide@nwawudu.com  2009-04-03 14:36 -------
Fixed in D2.016, D1 is keeping 'int opEquals' for backwards compatibility.


--