[Issue 19994] New: Can't nest self-referential Algebraic types

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jun 22 13:59:04 UTC 2019


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 at puremagic.com
          Reporter: snarwin+bugzilla at 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.

--


More information about the Digitalmars-d-bugs mailing list