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.dhttp://dstress.kuehne.cn/run/o/opEquals_05_B.dhttp://dstress.kuehne.cn/run/o/opEquals_05_C.dhttp://dstress.kuehne.cn/run/o/opEquals_05_D.dhttp://dstress.kuehne.cn/run/o/opEquals_05_E.dhttp://dstress.kuehne.cn/run/o/opEquals_05_F.dhttp://dstress.kuehne.cn/run/o/opEquals_05_G.dhttp://dstress.kuehne.cn/run/o/opEquals_05_H.d
Comment #1 by smjg — 2006-08-17T06:16:46Z
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.
Comment #2 by thomas-dloop — 2006-08-18T03:30:16Z
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[email protected] 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
-----BEGIN PGP SIGNATURE-----
iD8DBQFE5YffLK5blCcjpWoRArZnAJ968NiHssrxp64Laey3wuAUXHKBvwCfeA74
w9FDlhgZht5/ii3rQAqHNN0=
=szwS
-----END PGP SIGNATURE-----
Comment #3 by gide — 2008-09-03T08:08:44Z
*** Bug 1989 has been marked as a duplicate of this bug. ***
Comment #4 by gide — 2009-04-03T14:36:18Z
Fixed in D2.016, D1 is keeping 'int opEquals' for backwards compatibility.