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

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Jul 24 18:27:48 PDT 2014


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

--- Comment #19 from Jonathan M Davis <jmdavisProg at gmx.com> ---
Okay. Clearly, I was not paying enough attention to what was going on here. It
always has been the case that opEquals is generated for for structs, if you
don't define it. That hasn't changed for 2.066. Rather, in the case where you
try and use it as an AA key, it now screams at you for not having defined
opEquals, even though the default opEquals was almost certainly fine, because
that's what was being used.

It's a major bug IMHO if lhs.opCmp(rhs) == 0 is not equivalent to lhs == rhs,
so if we change the AAs to use opEquals but do not give the error that we're
currently giving, then all we'd be doing is exposing an existing bug in
someone's code, and that bug probably exists elsewhere in their code, since
they probably use opEquals with their keys _somewhere_.

And it seems kind of messed up to me to require that opEquals be defined just
because you're using an AA when the default opEquals already does the right
thing.

IMHO, we should either require that opEquals be defined in general if opCmp is
defined (which I think is a bad idea), or we should just use the default
opEquals with AAs without complaining about it (much better idea IMHO). The
only code that would be negatively affected is already broken anyway. But
requiring folks to define opEquals instead of using the perfectly good default
just because they're using an AA seems very wrong to me.

--


More information about the Digitalmars-d-bugs mailing list