https://issues.dlang.org/show_bug.cgi?id=13074
Issue ID: 13074 Summary: Old opCmp requirement for AA keys should be detected Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: diagnostic Severity: blocker Priority: P1 Component: DMD Assignee: nob...@puremagic.com Reporter: k.hara...@gmail.com For code migration from 2.065 to 2.066, following code should report diagnostic error. struct S { int x; int y; int opCmp(ref const S other) const { return x < other.x ? -1 : x > other.x ? 1 : 0; } hash_t toHash() const { return x; } } void main() { S s1 = S(1, 1); S s2 = S(1, 2); S s3 = S(2, 1); S s4 = S(2, 2); bool[S] arr; // line 22 arr[s1] = true; arr[s2] = true; arr[s3] = true; arr[s4] = true; import std.stdio; writeln(arr); } For example: test.d(22): Error: AA key type S is now required equality rather than comparison test.d(22): Please define opEquals, or remove it to rely on default memberwise equality Note that, the error should be removed in the future. Because opCmp should have no effect when the struct is used for AA keys. --