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

[email protected] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]
          Component|phobos                      |druntime

--- Comment #3 from [email protected] ---
I'd argue it behaves correctly now. Private state should be private. If
`.hashOf`, or any other external funtion, needs to access it directly, it ought
to fail. The correct thing to do is to add `toHash` member function to the
element `struct`.

Current `-dip1000` prevents errors like this:

```
struct Ternary
{ private ubyte state;
  @safe auto opEquals(const Ternary rhs) const
  { if (state >= 2) return rhs.state >= 2;
    else return state == rhs.state;
  }
}

@safe void main()
{ Ternary a = void, b = void;
  //fails with high likelihood
  if(a == b) assert(.hashOf(a) == .hashOf(b), "WAT?");
}
```

Perhaps the error message should suggest adding the `toHash` function, though.

--

Reply via email to