Bug 18652 – hashOf example doesn't compile

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-03-23T20:06:40Z
Last change time
2018-04-01T09:29:10Z
Assigned to
No Owner
Creator
elpenguino+D

Comments

Comment #0 by elpenguino+D — 2018-03-23T20:06:40Z
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.
Comment #1 by bugzilla — 2018-03-26T03:05:55Z
Comment #2 by github-bugzilla — 2018-04-01T09:29:08Z
Commits pushed to master at https://github.com/dlang/druntime https://github.com/dlang/druntime/commit/41eb363d75f38bace0a9a1f8e39bd5805cd98c61 Fix Issue 18652 - hashOf example doesn't compile https://github.com/dlang/druntime/commit/11aecf478a6a23dca1cee27fad5dac052cb0e0ba Merge pull request #2152 from WalterBright/fix18652 Issue 18652 - hashOf example doesn't compile