Comment #0 by alexandre.bourquelot — 2023-12-06T01:59:02Z
```
import std.typecons;
struct RecursiveClass {
int id;
bool flag;
Nullable!(RecursiveClass)* children;
}
```
This does not compile because the compiler is unable to infer the size of the struct, but given that the third member is a pointer, it should work.
```
/usr/lib/ldc/x86_64-linux-gnu/include/d/core/internal/traits.d(345): Error: unable to determine fields of `RecursiveClass` because of forward references
/usr/lib/ldc/x86_64-linux-gnu/include/d/std/traits.d(3343): Error: template instance `core.internal.traits._hasIndirections!(RecursiveClass)` error instantiating
```
Comment #1 by apz28 — 2023-12-06T16:20:43Z
I think you put '*' in wrong place. Try below
```
struct RecursiveClass {
int id;
bool flag;
Nullable!(RecursiveClass*) children;
}
```
Comment #2 by alexandre.bourquelot — 2023-12-07T05:14:00Z
The above works yes, but the semantics are a little different.
There is no reason why I should not be able to create a pointer on a nullable, if I wanted to.
Comment #3 by nick — 2023-12-10T18:58:34Z
Just to note that this compiles fine:
struct S(T)
{
int i;
T m;
}
struct R {
int i;
S!(R)* m;
}
Comment #4 by b2.temp — 2023-12-11T05:08:28Z
(In reply to Nick Treleaven from comment #3)
> Just to note that this compiles fine:
>
> struct S(T)
> {
> int i;
> T m;
> }
> struct R {
> int i;
> S!(R)* m;
> }
The problem shows the tip of its nose when performing static introspection and while the decl sema of the struct is not finished. Just start doing some `__traits` things and you'll get some similar errors.
Note that actually I think the error message is correct (and this report is likely a duplicate BTW, already seen that `hasIndirection` issue in the past)
Comment #5 by robert.schadek — 2024-12-01T16:42:04Z