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: [email protected]
          Reporter: [email protected]

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() {}
---

--

Reply via email to