[Issue 19541] Confusing error message about missing opEquals for AA key

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Apr 25 13:13:46 UTC 2023


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

RazvanN <razvan.nitu1305 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |razvan.nitu1305 at gmail.com
         Resolution|---                         |WORKSFORME

--- Comment #1 from RazvanN <razvan.nitu1305 at gmail.com> ---
Compiling this example with the latest git master, I get:

test.d(8): Error: AA key type `S` should have `extern (D) size_t toHash() const
nothrow @safe` if `opEquals` defined

Fine, I added the toHash myself:

  struct S { 
    bool opEquals(ref const(S) that) const {
        here_is_a_compilation_error;
    }
    size_t toHash() const { return 1; }                                         
  }

  struct T { 
    string[S] aa;    // <-- Compilation error
  }

  void main(){
  }

But now I get:

test.d(3): Error: undefined identifier `here_is_a_compilation_error`

This seems to have been fixed.

--


More information about the Digitalmars-d-bugs mailing list