Bug 12905 – [AA] `opCmp` in any struct allow other struct usage in associative array
Status
RESOLVED
Resolution
INVALID
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-06-13T07:53:00Z
Last change time
2014-07-09T15:11:14Z
Keywords
accepts-invalid
Assigned to
nobody
Creator
verylonglogin.reg
Comments
Comment #0 by verylonglogin.reg — 2014-06-13T07:53:08Z
This code compiles but shouldn't:
---
struct T { int opCmp(); }
struct S {}
int[S] aa; // Compiles iff `T` with `opCmp` exists
---
Currently the compiler tries to enforce `opCmp` existence on AA keys so this is accepts-invalid bug. Also there is Issue 12255 complaining about `opCmp` requirement, but anyway this code must either compile or not without depending on `T` existence.
IMO, this bug causes huge confusion in AAs and should be fixed ASAP.
Comment #1 by k.hara.pg — 2014-07-09T15:11:14Z
In git head, int[S] is valid AA type, and equality and hashing of key object is done by the bit representation.