Thread overview
[Issue 22184] std.sumtype.SumType with mutual recursion causes a forward reference of variable `isHashable`
Aug 06, 2021
Tomoya Tanjo
Aug 11, 2021
Tomoya Tanjo
Aug 11, 2021
Paul Backus
[Issue 22184] Template instantiation in static ifs in mutual recursion classes fail
Aug 11, 2021
Tomoya Tanjo
Aug 11, 2021
Tomoya Tanjo
Aug 13, 2021
Tomoya Tanjo
Aug 13, 2021
Paul Backus
Sep 23, 2022
Tomoya Tanjo
August 06, 2021
https://issues.dlang.org/show_bug.cgi?id=22184

--- Comment #1 from Tomoya Tanjo <ttanjo@gmail.com> ---
It works if we declare the classes in the following order: C, A and B.

run.dlang.io: https://run.dlang.io/is/qRsc7e

--
August 11, 2021
https://issues.dlang.org/show_bug.cgi?id=22184

--- Comment #2 from Tomoya Tanjo <ttanjo@gmail.com> ---
I reduced the above code as follows:

run.dlang.io: https://run.dlang.io/is/VZtiPO


```dlang
class A
{
    static if (isHashable!B) {}
}

class B
{
    static if (isHashable!C) {}
}

class C
{
    static if (isHashable!B && isHashable!int) {}
}

enum isHashable(T) = __traits(compiles,
    () { T.init; }
);

void main(){}
```

- It compiles successfully if `isHashable` checks `T t;` rather than `T.init;`

--
August 11, 2021
https://issues.dlang.org/show_bug.cgi?id=22184

Paul Backus <snarwin+bugzilla@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |snarwin+bugzilla@gmail.com

--
August 11, 2021
https://issues.dlang.org/show_bug.cgi?id=22184

Tomoya Tanjo <ttanjo@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|std.sumtype.SumType with    |Template instantiation in
                   |mutual recursion causes a   |static ifs in mutual
                   |forward reference of        |recursion classes fail
                   |variable `isHashable`       |

--
August 11, 2021
https://issues.dlang.org/show_bug.cgi?id=22184

Tomoya Tanjo <ttanjo@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|phobos                      |dmd

--- Comment #3 from Tomoya Tanjo <ttanjo@gmail.com> ---
I fixed the issue title and the `Component` section because it is a issue of dmd rather than std.sumtype.

--
August 13, 2021
https://issues.dlang.org/show_bug.cgi?id=22184

--- Comment #4 from Tomoya Tanjo <ttanjo@gmail.com> ---
Sorry, I found that I made an inappropriate reproducible code for the issue. The first example fails both of dmd 2.096.1 and dmd 2.097.0.

Please close this issue as invalid.

--
August 13, 2021
https://issues.dlang.org/show_bug.cgi?id=22184

Paul Backus <snarwin+bugzilla@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|regression                  |normal

--- Comment #5 from Paul Backus <snarwin+bugzilla@gmail.com> ---
Even if it's not a regression, it's still a valid issue. I'll change the category to "normal" and leave it open for now.

Possibly related to issue 20443.

--
September 23, 2022
https://issues.dlang.org/show_bug.cgi?id=22184

Tomoya Tanjo <ttanjo@gmail.com> changed:

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

--- Comment #6 from Tomoya Tanjo <ttanjo@gmail.com> ---
I close this issue because the first example now works with dmd 2.100.2.

However, the reduced example still does not work.
I will make a comment about the reduced case to the issue 20443 instead of keep
open this issue.

--