[Issue 13179] AA key type TagIndex now requires equality rather than comparison

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Jul 21 14:14:05 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13179

--- Comment #4 from hsteoh at quickfur.ath.cx ---
(In reply to Kenji Hara from comment #2)
[...]
> It's intended behavior, because compiler cannot know whether the generated
> opEquals is what programmer is expecting.
[...]

That doesn't make sense. The programmer has already defined opCmp, which means
"a == b" is already compiled to be "a.opCmp(b)==0". Therefore, if the
programmer didn't define opEquals, it should simply default to:
----
bool opEquals(T b) { return a.opCmp(b)==0; }
----

By your logic, the compiler should reject "a == b" when the programmer hasn't
defined opEquals, because the compiler cannot know whether a.opCmp(b)==0 is
what the programmer is expecting. I don't understand how this could make any
sense.

--


More information about the Digitalmars-d-bugs mailing list