You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't know if this is a dupe of #2746 or simply related, or even intended behavior, but a recursive struct type with an optional:
constFoo=struct {
nested: ?Foo,
};
Fails to compile with:
error: struct 'Foo' depends on itself
However, using an optional pointer:
constFoo=struct {
nested: ?*Foo,
};
Works.
Is my understanding correct that in Zig ?T on a struct type should be equivalent (at least internally) to a nullable pointer to T? If that's the case then I don't know why the first case fails since they should be equivalent.
I was hoping I could just build these Foo values on the stack and nest them and return them, but even if this compiled would that be legal behavior? (i.e. would copy elision take over and construct the whole hierarchy on the caller's stack?)
I don't know if this is a dupe of #2746 or simply related, or even intended behavior, but a recursive struct type with an optional:
Fails to compile with:
However, using an optional pointer:
Works.
Is my understanding correct that in Zig
?T
on a struct type should be equivalent (at least internally) to a nullable pointer toT
? If that's the case then I don't know why the first case fails since they should be equivalent.I was hoping I could just build these
Foo
values on the stack and nest them and return them, but even if this compiled would that be legal behavior? (i.e. would copy elision take over and construct the whole hierarchy on the caller's stack?)For example:
Would this be sane?
The text was updated successfully, but these errors were encountered: