https://issues.dlang.org/show_bug.cgi?id=13179
--- Comment #2 from Kenji Hara <k.hara...@gmail.com> --- (In reply to Jacob Carlborg from comment #0) > Building Tango with 2.066.0-b5 results in the following error: > > tango/text/Regex.d(2532): Error: AA key type TagIndex now requires equality > rather than comparison > tango/text/Regex.d(2532): Please define opEquals, or remove opCmp to > also rely on default memberwise comparison. > > I can see that opEquals should be used and not opCmp for AA keys, but if > opCmp is defined, why doesn't the compiler automatically generate opEquals > that calls opCmp? It's intended behavior, because compiler cannot know whether the generated opEquals is what programmer is expecting. (In reply to Jacob Carlborg from comment #1) > Reduced test case: > > struct TagIndex > { > uint tag, index; > > const int opCmp(ref const TagIndex o) > { [snip] > } > } > > int[TagIndex] a; In D, all struct define default member-wise equality for == operator. TagIndex t1, t2; // t1 == t2 will be rewritten as: // t1.tupleof == t2.tupleof // and then it will mean: // t1.tag == t2.tag && t1.index == t2.index If TagIndex is used for AA keys, compiler cannot determine which is the intended 'equality', t1 == t2 or t1.opCmp(t2) == 0. So compiler requests you to resolve the ambiguity by defining opEquals or removing opCmp. --