The TLDR version is to make the field with the same type as the parent into a pointer of that type.
pub const Node {
next: *Node, // good
prev: Node // bad
}
There is no way for the compiler to determine the size of the struct, as it would put it into a loop. If you use a pointer, then the total size of the struct can be calculated regardless.
Because A refers to B via a pointer the compiler (can) should already be able to determine the sizes of the structs. The issue is that Something(A) creates a cyclic dependency between A and B.
It gets even weirder:
test {
@compileLog(@sizeOf(A)); // if only this line exists, the compile error occurs
@compileLog(@sizeOf(B)); // if only this line exists, the correct size is logged
@compileLog(@sizeOf(C)); // if only this line exists, the compile error occurs
}