If I define this nested sumtype using `This` to be recursive:
```d
import std.sumtype;
struct X {
SumType!(int, SumType!(int,This)[]) value;
}
```
then the compiler gives this error:
```console
Error: unknown, please file report on issues.dlang.org
onlineapp.d(3): Error: template instance `std.sumtype.SumType!(int, This)` error instantiating
```
Also, if instead I replace `This` with the wrapping struct:
```d
import std.sumtype;
struct X {
SumType!(int, SumType!(int,X)[]) value;
}
```
then this static assert fails within the match statement in sumtype's destructor:
```console
/dlang/dmd/linux/bin64/../../src/phobos/std/sumtype.d(2018): Error: static assert: "No matching handler for types `(X)`"
/dlang/dmd/linux/bin64/../../src/phobos/std/sumtype.d(1649): instantiated from here: `matchImpl!(SumType!(int, X))`
/dlang/dmd/linux/bin64/../../src/phobos/std/sumtype.d(752): instantiated from here: `match!(SumType!(int, X))`
onlineapp.d(3): instantiated from here: `SumType!(int, X)`
```
Small modifications that also error:
```d
SumType!(int, SumType!(int,This)*) value; // Error: unknown ...
SumType!(int, Tuple!(int,X)[]) value; // Error: unknown ...
```
Small modifications that don't error:
```d
SumType!(int, SumType!(int,X)*) value;
SumType!(int, SumType!(int,X*)[]) value;
SumType!(int, SumType!(int,This*)[]) value;
SumType!(int, Tuple!(int,This)[]) value;
SumType!(int, Tuple!(int,X)*) value;
SumType!(int, Tuple!(int,This)*) value;
SumType!(int,This[]) value;
SumType!(int,X[]) value;
```
Error output is from run.dlang.io and is similar on all settings of dmd/ldc and versions since std.sumtype was released.
Possibly similar 2022 issue marked as FIXED: https://issues.dlang.org/show_bug.cgi?id=22860
Comment #1 by robert.schadek — 2024-12-13T19:33:46Z