www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19994] New: Can't nest self-referential Algebraic types

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

          Issue ID: 19994
           Summary: Can't nest self-referential Algebraic types
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: snarwin+bugzilla gmail.com

import std.variant;
import std.meta: AliasSeq;

alias Inner = Algebraic!(This*);
alias Outer = Algebraic!(Inner, This*);

static assert(is(Outer.AllowedTypes == AliasSeq!(Inner, Outer*)));

---

$ dmd -c example.d
/usr/include/dmd/phobos/std/typecons.d(8730): Error: template instance
`std.typecons.ReplaceType!(This, U!(8LU, U!(8LU, U!(8LU, U!(8LU, U!(8LU,
U!(8LU, U!(8LU, U!(8LU, U!(8LU, U!(8LU, U!(8LU, U!(8LU, U!(8LU, VariantN!(16LU,
VariantN!(8LU, This*), This*)*)*)*)*)*)*)*)*)*)*)*)*)*), U!(8LU,
VariantN!(16LU, VariantN!(8LU, This*), This*)*)*)` recursive expansion

To avoid this error, Algebraic should not attempt to replace occurrences of
This that appear inside other instances of Algebraic.

--
Jun 22 2019