digitalmars.D.bugs - [Issue 12593] New: [REG2.065] AA cannot have struct as key
- via Digitalmars-d-bugs (42/42) Apr 18 2014 https://issues.dlang.org/show_bug.cgi?id=12593
https://issues.dlang.org/show_bug.cgi?id=12593 Issue ID: 12593 Summary: [REG2.065] AA cannot have struct as key Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: regression Priority: P1 Component: DMD Assignee: nobody puremagic.com Reporter: yazan.dabain gmail.com Code: int[R] aa; struct R {} void main() {} Compiler output: test.d(1): Error: associative array key type R does not have 'const int opCmp(ref const R)' member function which is understandable. However, let's add the missing member function. Code: int[R] aa; struct R { const int opCmp(ref const R) { return 0; } } void main() {} Compiler output: test.d(1): Error: associative array key type R does not have 'const int opCmp(ref const R)' member function We still have the same error although the member function exists! I tried adding opEquals and toHash functions too, but I get the same output. Now let's try the following: Code: import std.array; // can be other modules also (e.g. range, algorithm, string, format) but not all modules enable this code to compile (e.g. typetuple) int[R] aa; struct R {} void main() {} Now with having some arbitrary import, the code compiles! Although opCmp is missing. --
Apr 18 2014