Thread overview
[Issue 24482] Recursive alias out of order fails to compile with a misleading error message.
Apr 04
basile-z
Apr 04
basile-z
April 04
https://issues.dlang.org/show_bug.cgi?id=24482

scrubereal@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|recursive alias out of      |Recursive alias out of
                   |order fails to compile with |order fails to compile with
                   |a misleading error message  |a misleading error message.

--
April 04
https://issues.dlang.org/show_bug.cgi?id=24482

basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |b2.temp@gmx.com
           Hardware|x86_64                      |All
                 OS|Linux                       |All

--- Comment #1 from basile-z <b2.temp@gmx.com> ---
slightly minimized

```
struct Array(E) {}
struct Enum(T) {T t;} // <-- here T size is not known yet
alias NodeArray = Array!(Enum!(Object));
struct Object {NodeArray values;}
```

IMO the error message is correct, for example

```
struct Array(E) {}
struct Enum(T) {T t;}
alias NodeArray = Array!(Enum!(Object*));
struct Object {NodeArray values;}
```

compiles. However that's a typical case of "how forward references are handled in D" is under-specified.

--
April 04
https://issues.dlang.org/show_bug.cgi?id=24482

--- Comment #2 from basile-z <b2.temp@gmx.com> ---
Moving decls does not solve anything, just try

```
struct Array(E) { E e;}
struct Enum(T) {T t;}
struct Object {NodeArray values;}
alias NodeArray = Array!Node;
alias Node = Enum!(Object);
```

The point is that at some point you must know the size of a member. When the member is a pointer you can guess the size without knowing the actual pointee type size. Might be zero, might be 3 Billions, but in fine it's a pointer so let's see that later ;)

--
April 04
https://issues.dlang.org/show_bug.cgi?id=24482

--- Comment #3 from scrubereal@gmail.com ---
Right; and an actual array would store an `E[]` or an `E*`. When `e`'s type is one of those, the program compiles.

--