www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19541] New: Confusing error message about missing opEquals

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

          Issue ID: 19541
           Summary: Confusing error message about missing opEquals for AA
                    key
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: acehreli yahoo.com

struct S {
  bool opEquals(ref const(S) that) const {
    here_is_a_compilation_error;
  }
}

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

void main() {
}

  Error: AA key type `S` does not have `bool opEquals(ref const S) const`

The message is confusing because the AA key type S satisfies what it says.

Apparently, the problem is actually with a compilation error inside that
function but the user is fooled by the message and is now looking for
unnecessary workarounds instead of fixing the compilation error.

Ali

--
Jan 02 2019