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

--- Comment #4 from Simen Kjaeraas <[email protected]> ---
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
commit:
https://github.com/dlang/druntime/commit/463c9d5fef8dd01082ac9bd1bd6971a4a56124f3#diff-1cb07fafd18644ca9974aea7a74483e9L117

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.

--

Reply via email to