[Issue 18652] New: hashOf example doesn't compile
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Mar 23 20:06:40 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=18652
Issue ID: 18652
Summary: hashOf example doesn't compile
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: regression
Priority: P1
Component: druntime
Assignee: nobody at puremagic.com
Reporter: elpenguino+D at gmail.com
The example in the documentation for object.hashOf does not compile.
```
struct Test
{
int a;
string b;
MyObject c;
size_t toHash() const @safe pure nothrow
{
size_t hash = a.hashOf();
hash = b.hashOf(hash);
size_t h1 = c.myMegaHash();
hash = h1.hashOf(hash); //Mix two hash values
return hash;
}
}
```
This is entirely due to it being marked @safe, while hashOf(string) is @system.
This example should be made into a documented unittest and corrected.
--
More information about the Digitalmars-d-bugs
mailing list