[Issue 19554] [2.084.0] Confusing message - Warning: struct Foo has method toHash

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jan 7 14:15:56 UTC 2019


--- Comment #4 from Simen Kjaeraas <simen.kjaras at gmail.com> ---
Thanks a lot. :) So, example code:

struct Foo {
    ulong toHash() { return 0; }

unittest {
    auto a = Foo().hashOf;

Interestingly, this was a static assert until 4 years ago, changed by this

A static assert would give the line on which hashOf is called. One might
reasonably expect to instead get the line on which toHash is defined.
Currently, this is impossible, and would require something like
__traits(getLocation, T). Created a separate issue for that in issue 19555.

For now, the best that could be done is probably to pass the file and line to
hashOf as it's being called.


More information about the Digitalmars-d-bugs mailing list