[Issue 694] New: Doc mistake: a == null is not a.opCmp(null)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Dec 17 06:38:46 PST 2006
http://d.puremagic.com/issues/show_bug.cgi?id=694
Summary: Doc mistake: a == null is not a.opCmp(null)
Product: D
Version: 0.177
Platform: All
URL: http://www.digitalmars.com/d/operatoroverloading.html
OS/Version: All
Status: NEW
Keywords: spec
Severity: normal
Priority: P2
Component: www.digitalmars.com
AssignedTo: bugzilla at digitalmars.com
ReportedBy: deewiant at gmail.com
OtherBugsDependingO 677
nThis:
Under "Overloading == and !=" the spec claims that "if (a == null)" is
converted to "if (a.opCmp(null))", when it is actually converted to "if
(a.opEquals(null))". This has been reported a few times now, but left unfixed.
Proof: the following program outputs "opEquals\nopEquals\nopCmp\n" and not
"opCmp\nopEquals\nopCmp\n":
class Foo {
override int opEquals(Object o) {
printf("opEquals\n");
return 0;
}
override int opCmp(Object o) {
printf("opCmp\n");
return 0;
}
}
void main() {
Foo f = new Foo();
if (f == null) {}
if (f.opEquals(null)) {}
if (f.opCmp(null)) {}
}
--
More information about the Digitalmars-d-bugs
mailing list