www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22075] New: [Reg 2.068] "AA key type S should have 'size_t

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 puremagic.com
          Reporter: n8sh.secondary 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() {}
---

--
Jun 22