| 1 |
// https://issues.dlang.org/show_bug.cgi?id=22075 |
| 2 |
|
| 3 |
/* |
| 4 |
TEST_OUTPUT: |
| 5 |
--- |
| 6 |
fail_compilation/fail22075.d(25): Error: AA key type `S` should have `extern (D) size_t toHash() const nothrow @safe` if `opEquals` defined |
| 7 |
fail_compilation/fail22075.d(26): Error: AA key type `S` should have `extern (D) size_t toHash() const nothrow @safe` if `opEquals` defined |
| 8 |
--- |
| 9 |
*/ |
| 10 |
|
| 11 |
struct HasAliasThis { int a; alias a this; } |
| 12 |
|
| 13 |
struct LacksAliasThis { int a; } |
| 14 |
|
| 15 |
struct S(T) |
| 16 |
{ |
| 17 |
private T a; |
| 18 |
|
| 19 |
bool opEquals(const S rhs) const @nogc nothrow @safe |
| 20 |
{ |
| 21 |
return rhs is this; |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
int[S!HasAliasThis] aa1; // Compiles but should not. |
| 26 |
int[S!LacksAliasThis] aa2; // Correctly fails to compile with "Error: AA key |
| 27 |
// type `S` should have `extern (D) size_t toHash() const nothrow @safe` |
| 28 |
// if `opEquals` defined"". |
| 29 |
|
| 30 |
void main() {} |