Thread overview
[Issue 19517] Spurious compiler warning with const toHash and alias this classes
Jan 16, 2019
Simon Naarmann
Dec 17, 2022
Iain Buclaw
January 16, 2019
https://issues.dlang.org/show_bug.cgi?id=19517

Simon Naarmann <eiderdaus@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |eiderdaus@gmail.com

--- Comment #1 from Simon Naarmann <eiderdaus@gmail.com> ---
Right, this has nothing to do with Nullable in particular. This warning appeared in my existing codebase after I switched from DMD 2.083.2 to 2.084.0, and the codebase doesn't use Nullable.

The workaround is to remove the 'alias this' in S.

But it's very common to wrap class references in structs and then alias-this to the class. Would love to see a quick fix!

--
July 13, 2020
https://issues.dlang.org/show_bug.cgi?id=19517

--- Comment #2 from hsteoh@quickfur.ath.cx ---
Found this (partial) workaround:

------
class C { /* ... */ }
struct S
{
    C c;
    auto opDispatch(string field)() inout
    {
        return mixin("c."~field);
    }
}
------

The key here is the `inout`.

This works as long as you don't expect to implicitly convert S to C. You can access class fields as if they were fields in S.

For implicit conversion, though, I haven't come up with a good workaround yet.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=19517

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
December 13
https://issues.dlang.org/show_bug.cgi?id=19517

--- Comment #3 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/17890

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--