www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22210] New: std.meta.allSatisfy in mutual recursion classes

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

          Issue ID: 22210
           Summary: std.meta.allSatisfy in mutual recursion classes cannot
                    be compiled
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: ttanjo gmail.com

The following code works with dmd 2.096.1 but does not work with dmd 2.097.0.
Digger shows that it was introduced by the commit 406e51c68 in druntime.

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

```dlang:sample.d
import std.meta : allSatisfy;

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

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

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

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

void main() {}
```

Error message:
```console
/dlang/dmd/linux/bin64/../../src/druntime/import/core/internal/traits.d(191):
Error: forward reference of variable `isHashable`
/dlang/dmd/linux/bin64/../../src/phobos/std/meta.d(842): Error: template
instance `core.internal.traits.allSat!(isHashable, int, B)` error instantiating
onlineapp.d(19):        instantiated from here: `allSatisfy!(isHashable, int,
B)`
onlineapp.d(14): Error: template instance `onlineapp.isHashable!(C)` error
instantiating
onlineapp.d(9): Error: template instance `onlineapp.isHashable!(B)` error
instantiating
```

I use the following commands to search for the commit that introduces this
issue:
```console
$ cat bisect.ini
bad  = master   v2.097.0
good = master   v2.096.1

reverse = false

tester = dmd -i -run sample.d

$ dub run digger -- bisect bisect.ini
...
digger: c717e2eda7063a583ada54182f3016139a50a61f is the first bad commit
commit c717e2eda7063a583ada54182f3016139a50a61f
Author: Andrei Alexandrescu <andrei erdani.com>
Date:   Tue May 4 15:45:09 2021 -0400

druntime: Simplify anySatisfy, allSatisfy, maxAlignment

diff --git a/druntime b/druntime
index 5cfc074f7..406e51c68 160000
--- a/druntime
+++ b/druntime
   -1 +1   
-Subproject commit 5cfc074f73d2087841e66871cd859946ba14003a
+Subproject commit 406e51c68c94a65e383da5aaa500c17d0a9c4d0e
```

- If we use `isHashable!int && isHashable!B` instead of
`allSatisfy!(isHashable, int, B)`, it works with both of dmd 2.096.1 and dmd
2.097.0.
- If we use `isHashable!B && isHashable!int` instead of
`allSatisfy!(isHashable, int, B)`, it is the case of Issue 22184 (does not work
with both versions)

--
Aug 14