[Issue 22859] New: Error: forward reference of variable `isAssignableTo` for mutually recursed SumType

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 8 06:03:08 UTC 2022


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

          Issue ID: 22859
           Summary: Error: forward reference of variable `isAssignableTo`
                    for mutually recursed SumType
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: ttanjo at gmail.com

The following code works with dmd 2.098.1 but does not work with dmd 2.099.0
(beta).

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

```d
import std.sumtype : SumType;

struct None{}

class C1
{
    SumType!(None, C2) field;
}

class C2
{
    SumType!(None, C1, C2) field;
}

void main() {}
```

dmd 2.099.0 shows the following message:

```console
> rdmd playground.d

/dlang/dmd-beta/linux/bin64/../../src/phobos/std/sumtype.d(551): Error: forward
reference of variable `isAssignableTo`
/dlang/dmd-beta/linux/bin64/../../src/druntime/import/core/internal/traits.d(193):
Error: forward reference of variable `isAssignableTo`
/dlang/dmd-beta/linux/bin64/../../src/phobos/std/sumtype.d(595): Error:
template instance `core.internal.traits.allSatisfy!(isAssignableTo, None, C1,
C2)` error instantiating
onlineapp.d(12):        instantiated from here: `SumType!(None, C1, C2)`
/dlang/dmd-beta/linux/bin64/../../src/phobos/std/traits.d(5179): Error:
template instance `std.traits.isRvalueAssignable!(C2, C2)` error instantiating
/dlang/dmd-beta/linux/bin64/../../src/phobos/std/sumtype.d(256):       
instantiated from here: `isAssignable!(C2, C2)`
/dlang/dmd-beta/linux/bin64/../../src/phobos/std/sumtype.d(551):       
instantiated from here: `isAssignableTo!(C2)`
onlineapp.d(7):        instantiated from here: `SumType!(None, C2)`
/dlang/dmd-beta/linux/bin64/../../src/phobos/std/sumtype.d(595): Error:
template instance `core.internal.traits.allSatisfy!(isAssignableTo, None, C2)`
error instantiating
onlineapp.d(7):        instantiated from here: `SumType!(None, C2)`
```

--


More information about the Digitalmars-d-bugs mailing list