I'm trying to define some structs that contain sumTypes (using the sumtype library) that refer to each other, but I get a recursive template instantiation error. It looks like typically recursion is handled in that library with the This type, but I don't see how that would apply here. Any advice on how to get this to work?

```
struct Terminal{
 string name;
}

struct Op(string op){
  alias ElemType = SumType!(Terminal, Term);
  ElemType[] elems;

}

struct Term{
  alias ElemType = SumType!(Op!"+", Op!"-", Op!"*", Terminal);
  ElemType[] elems;
}

```

Errors with

```
Error: template instance SumType!(Op!"+", Op!"-", Op!"*", Terminal) recursive template expansion
../../../.dub/packages/sumtype-0.9.4/sumtype/src/sumtype.d(331,14): Error: 
template instance std.traits.isCopyable!(Term) error instantiating
source/errorbound/tracked.d(25,20): instantiated from here: SumType!(Terminal, Term) source/errorbound/tracked.d(31,29): instantiated from here: Op!"+" /usr/local/opt/dmd/include/dlang/dmd/std/meta.d(839,24): Error: template instance core.internal.traits.allSat!(isCopyable, Terminal, Term) error instantiating
```

Reply via email to