Bug 12540 – Algebraic recursive alias declaration when a class contains an Algebraic member that can accept itself
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-04-07T12:03:58Z
Last change time
2018-10-16T19:22:32Z
Assigned to
No Owner
Creator
Dylan Knutson
Comments
Comment #0 by tcdknutson — 2014-04-07T12:03:58Z
It's not possible to create an Algebraic alias which can take a class, where that class has the same algebraic type as a member.
Example code:
```
import std.variant;
alias SomeAlg = Algebraic!SomeClass;
class SomeClass {
SomeAlg entity;
}
void main() {}
```
Yielding the error:
```
/d519/f212.d(3): Error: alias f212.SomeAlg recursive alias declaration
/opt/compilers/dmd2/include/std/variant.d(1227): Error: template instance std.variant.maxSize!(SomeClass) error instantiating
/d519/f212.d(3): instantiated from here: Algebraic!(SomeClass)
/d519/f212.d(3): Error: template instance std.variant.Algebraic!(SomeClass) error instantiating
```
What's perhaps stranger is that this code does work:
```
import std.variant;
//alias SomeAlg = Algebraic!SomeClass;
class SomeClass {
Algebraic!SomeClass entity;
}
void main() {}
```
But it's doing, as far as I can tell, the exact same thing.
Comment #1 by Jesse.K.Phillips+D — 2014-06-25T03:27:18Z
I think this is a duplicate of issue 10705.
Comment #2 by n8sh.secondary — 2018-10-16T19:22:32Z