Comment #0 by verylonglogin.reg — 2013-11-24T00:46:59Z
At least a year ago `const`/`immutable` `std.typecons.Tuple`-s with classes worked as associative array keys. The fact it fails at runtime now is rather nasty. It should either work or fail to compile.
---
import std.typecons;
void main()
{
alias T = Tuple!Object;
int[const T] aa; // No CT errors
aa[T()] = 1;
aa[T()] = 1; // Error at runtime
}
---
object.Error: TypeInfo.compare is not implemented
---
E.g. fixing Issue 11590 will fix this issue by rejecting such associative arrays to compile unless Issue 1824 is fixed.
Comment #1 by verylonglogin.reg — 2013-11-24T01:33:08Z
Sorry, original comment is wrong. The regression is for unqualified tuples:
---
import std.typecons;
void main()
{
alias T = Tuple!Object;
int[T] aa; // No CT errors
aa[T()] = 1;
aa[T()] = 1; // Error at runtime
}
---
Comment #2 by bugzilla — 2013-12-31T14:22:05Z
This comes about because std.typecons.Tuple generates a struct but does not generate an opCmp operator overload function for it. Actually, it does build an opCmp, but as a template, whereas in clone.c buildXopCmp() looks for a function named opCmp, not a template.
Comment #3 by verylonglogin.reg — 2013-12-31T14:53:25Z
(In reply to comment #2)
> This comes about because std.typecons.Tuple generates a struct but does not
> generate an opCmp operator overload function for it. Actually, it does build an
> opCmp, but as a template, whereas in clone.c buildXopCmp() looks for a function
> named opCmp, not a template.
Actually there is no problem with the fact it's a template here IIRC. The problem is the template (a `const` overload) can't be instantiated.
Comment #4 by bugzilla — 2013-12-31T18:53:04Z
I did some more digging on this. The fundamental problem is that for AA's to work, then opCmp() has to work. opCmp needs an ordering, a "<" operation. But there is no defined ordering for Object.
Hence, it fails.
I don't see how const makes any difference. Nor is this really about Tuples, it's about using Object as a key for an associative array.