[Issue 11557] Can't compare `const`/`immutable` classes

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 20 01:26:09 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=11557



--- Comment #2 from Kenji Hara <k.hara.pg at gmail.com> 2013-11-20 01:26:06 PST ---
(In reply to comment #0)
> Currently because of Issue 1824 `opEquals` and `opCmp` aren't `const`. It's bad
> but works if these functions are implemented carefully.
> 
> Current dmd rejects `opCmp` call:
> ---
> const Object o1, o2;
> assert(o1 == o2); // ok, calls `opEquals`
> assert(o1 <= o2); // Error: mutable method object.Object.opCmp is not callable
> using a const object
> ---
> 
> As a result e.g. `std.typecons.Tuple`-s with classes don't have `opCmp` and
> fails with "TypeInfo.compare is not implemented" `Error` if used as an
> associative array key. Error at runtime is really nasty.

Why this issue is marked as "regression"? As far as I know, the code you shown
had never worked correctly.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list