D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 19994 - Can't nest self-referential Algebraic types
Summary: Can't nest self-referential Algebraic types
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 enhancement
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2019-06-22 13:59 UTC by Paul Backus
Modified: 2019-07-08 03:15 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Paul Backus 2019-06-22 13:59:04 UTC
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.
Comment 1 Dlang Bot 2019-06-22 15:47:27 UTC
@pbackus created dlang/phobos pull request #7084 "Fix issue 19994 - Can't nest self-referential Algebraic types" fixing this issue:

- Fix issue 19994 - Can't nest self-referential Algebraic types

https://github.com/dlang/phobos/pull/7084
Comment 2 Dlang Bot 2019-07-08 03:15:10 UTC
dlang/phobos pull request #7084 "Fix issue 19994 - Can't nest self-referential Algebraic types" was merged into master:

- 8124b17e2c24e1b67cb7a40dcb80f460ef6825f1 by Paul Backus:
  Fix issue 19994 - Can't nest self-referential Algebraic types

https://github.com/dlang/phobos/pull/7084