Thread overview
[Issue 24270] Pointer to Nullable of recursive struct
Dec 06, 2023
apham
Dec 06, 2023
dlang@ygrek.org
Dec 10, 2023
Nick Treleaven
Dec 11, 2023
Basile-z
December 06, 2023
https://issues.dlang.org/show_bug.cgi?id=24270

apham <apz28@hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |apz28@hotmail.com

--- Comment #1 from apham <apz28@hotmail.com> ---
I think you put '*' in wrong place. Try below

```
struct RecursiveClass {
    int id;
    bool flag;
    Nullable!(RecursiveClass*) children;
}
```

--
December 06, 2023
https://issues.dlang.org/show_bug.cgi?id=24270

dlang@ygrek.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dlang@ygrek.org

--
December 07, 2023
https://issues.dlang.org/show_bug.cgi?id=24270

--- Comment #2 from Alexandre Bourquelot <alexandre.bourquelot@ahrefs.com> ---
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.

--
December 10, 2023
https://issues.dlang.org/show_bug.cgi?id=24270

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nick@geany.org

--- Comment #3 from Nick Treleaven <nick@geany.org> ---
Just to note that this compiles fine:

struct S(T)
{
    int i;
    T m;
}
struct R {
    int i;
    S!(R)* m;
}

--
December 11, 2023
https://issues.dlang.org/show_bug.cgi?id=24270

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |b2.temp@gmx.com

--- Comment #4 from Basile-z <b2.temp@gmx.com> ---
(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)

--