Thread overview
[Issue 21705] Nullable!T.opEquals fails for T with non-const opEquals overload
Mar 12, 2021
Paul Backus
Mar 13, 2021
Dlang Bot
Mar 15, 2021
Dlang Bot
March 12, 2021
https://issues.dlang.org/show_bug.cgi?id=21705

--- Comment #1 from Paul Backus <snarwin+bugzilla@gmail.com> ---
Another example:

---
import std.typecons;

struct S
{
    int n;
    bool opEquals(S rhs) { return n == rhs.n; }
}

void main()
{
    Nullable!S example1 = S(1), example2 = S(1);
    assert(example1 == example2);
}
---

Produces the following error message with DMD 2.095.1:

---
/usr/include/dmd/phobos/std/typecons.d(2726): Error: mutable method
`bug.S.opEquals` is not callable using a `const` object
bug.d(6):        Consider adding `const` or `inout` here
bug.d(12): Error: template instance
`std.typecons.Nullable!(S).Nullable.opEquals!()` error instantiating
---

--
March 13, 2021
https://issues.dlang.org/show_bug.cgi?id=21705

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #2 from Dlang Bot <dlang-bot@dlang.rocks> ---
@pbackus created dlang/phobos pull request #7852 "Fix Issue 21705 - Nullable!T.opEquals fails for T with non-const opEq…" fixing this issue:

- Fix Issue 21705 - Nullable!T.opEquals fails for T with non-const opEquals overload

https://github.com/dlang/phobos/pull/7852

--
March 15, 2021
https://issues.dlang.org/show_bug.cgi?id=21705

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/phobos pull request #7852 "Fix Issue 21705 - Nullable!T.opEquals fails for T with non-const opEq…" was merged into master:

- 4fb71b8c768f9afd79ca1bf73405216d0b557990 by Paul Backus:
  Fix Issue 21705 - Nullable!T.opEquals fails for T with non-const opEquals
overload

https://github.com/dlang/phobos/pull/7852

--