#Strange "struct depends on itself" behaviour

1 messages · Page 1 of 1 (latest)

hushed oak
#

The following doesn't give me an error, which is expected:

pub const B = struct {
    b: *B,
};

but when I change B to struct { B }, it errors with struct 'test.B' depends on itself:

pub const B = struct {
    b: *struct { B },
};

I just updated to Zig 0.14.0 and this is still present. It's not a problem personally since I can just add a pointer, but I ran into this and was wondering if there's an explanation.

#

I looked through zig issues and apparently false dependency loops are a known problem? Didn't find this exact example though so maybe I'm missing something

#

Oh nevermind after changing my example to pointers i found relevant discussion

wooden marsh
#

The latter really can't work because it requires the B to be fully known first

#

thus the loop

#

b: struct { *B } or such would be valid

hushed oak
#

thanks for the explanation

wooden marsh
#

Actually I think I'm wrong, the second should work too, but seems like regression