Thread overview
[Issue 19554] [2.084.0] Confusing message - Warning: struct Foo has method toHash
Jan 07, 2019
Simen Kjaeraas
Jan 07, 2019
Radu Racariu
Jan 07, 2019
Radu Racariu
Jan 07, 2019
Radu Racariu
Jan 07, 2019
Simen Kjaeraas
Aug 14, 2020
Dlang Bot
Aug 17, 2020
Dlang Bot
January 07, 2019
https://issues.dlang.org/show_bug.cgi?id=19554

Simen Kjaeraas <simen.kjaras@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simen.kjaras@gmail.com

--- Comment #1 from Simen Kjaeraas <simen.kjaras@gmail.com> ---
Speaking of non-informative - could you include some kind of code that gives this error message?

--
January 07, 2019
https://issues.dlang.org/show_bug.cgi?id=19554

--- Comment #2 from Radu Racariu <radu.racariu@gmail.com> ---
Just using github search one could pinpoint the location where the message is generated:

https://github.com/dlang/druntime/blob/2b6673fd6e008d7f1ece0414f3ad693840005c88/src/core/internal/hash.d#L544

--
January 07, 2019
https://issues.dlang.org/show_bug.cgi?id=19554

Radu Racariu <radu.racariu@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|dmd                         |druntime

--
January 07, 2019
https://issues.dlang.org/show_bug.cgi?id=19554

--- Comment #3 from Radu Racariu <radu.racariu@gmail.com> ---
Changed the `component` to druntime.

--
January 07, 2019
https://issues.dlang.org/show_bug.cgi?id=19554

--- Comment #4 from Simen Kjaeraas <simen.kjaras@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
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.

--
August 14, 2020
https://issues.dlang.org/show_bug.cgi?id=19554

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #5 from Dlang Bot <dlang-bot@dlang.rocks> ---
@Biotronic created dlang/druntime pull request #3195 "Fix issue 19554 - Confusing message - Warning: struct Foo has method …" fixing this issue:

- Fix issue 19554 - Confusing message - Warning: struct Foo has method toHash

https://github.com/dlang/druntime/pull/3195

--
August 17, 2020
https://issues.dlang.org/show_bug.cgi?id=19554

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/druntime pull request #3195 "Fix issue 19554 - Confusing message - Warning: struct Foo has method …" was merged into master:

- c29afdbfe491ebdbee891b10604147e15eccb969 by Simen Kjærås:
  Fix issue 19554 - Confusing message - Warning: struct Foo has method toHash

https://github.com/dlang/druntime/pull/3195

--