[Issue 22075] New: [Reg 2.068] "AA key type S should have 'size_t toHash() const nothrow @safe' if opEquals defined" is not triggered if any field of S has its own 'alias this'

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jun 22 22:30:47 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=22075

          Issue ID: 22075
           Summary: [Reg 2.068] "AA key type S should have 'size_t
                    toHash() const nothrow @safe' if opEquals defined" is
                    not triggered if any field of S has its own 'alias
                    this'
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: n8sh.secondary at hotmail.com

Demonstration:

---
struct HasAliasThis { int a; alias a this; }

struct LacksAliasThis { int a; }

struct S(T)
{
    private T a;

    bool opEquals(const S rhs) const @nogc nothrow @safe
    {
        return rhs is this;
    }
}

int[S!HasAliasThis] aa1; // Compiles but should not.
int[S!LacksAliasThis] aa2; // Correctly fails to compile with "Error: AA key
     // type `S` should have `extern (D) size_t toHash() const nothrow @safe`
     // if `opEquals` defined"".

void main() {}
---

--


More information about the Digitalmars-d-bugs mailing list