Bug 22075 – [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'

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-06-22T22:30:47Z
Last change time
2021-07-08T17:05:12Z
Keywords
pull
Assigned to
No Owner
Creator
Nathan S.
Blocks
22065

Comments

Comment #0 by n8sh.secondary — 2021-06-22T22:30:47Z
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() {} ---
Comment #1 by razvan.nitu1305 — 2021-06-25T14:19:56Z
I'm fairly certain this is the cause: https://issues.dlang.org/show_bug.cgi?id=14948
Comment #2 by n8sh.secondary — 2021-06-29T22:44:12Z
*** Issue 22065 has been marked as a duplicate of this issue. ***
Comment #3 by dlang-bot — 2021-07-08T15:15:04Z
@RazvanN7 created dlang/dmd pull request #12840 "Fix Issue 22075 - [Reg 2.068] AA key type S should have size_t toHash…" fixing this issue: - Fix Issue 22075 - [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 https://github.com/dlang/dmd/pull/12840
Comment #4 by dlang-bot — 2021-07-08T17:05:12Z
dlang/dmd pull request #12840 "Fix Issue 22075 - [Reg 2.068] AA key type S should have size_t toHash…" was merged into master: - d28aadf324414afc697a5b71d960de82c568e191 by RazvanN7: Fix Issue 22075 - [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 https://github.com/dlang/dmd/pull/12840