#exe {
-Mroot=main.zig
#}

#write main.zig {
pub const A = struct { b: B };
pub const B = struct { a: A };
pub fn main() void {
    _ = @as(B, undefined);
}
#}
#update
#check errors {
error: dependency loop with length 2
    main.zig:2:27: note: type 'main.B' depends on type 'main.A' for field declared here
    main.zig:1:27: note: type 'main.A' depends on type 'main.B' for field declared here
    note: eliminate any one of these dependencies to break the loop
#}

#write main.zig {
pub const A = struct { b: B };
pub const B = struct { a: A };
pub fn main() void {
    _ = B;
}
#}
#update "remove reference to dependency loop"
#check stdout

#write main.zig {
pub const A = struct { b: B };
pub const B = struct { a: *align(@alignOf(A)) A };
pub fn main() void {
    _ = B;
}
#}
#update "change dependency loop without fixing it"
#check stdout

#write main.zig {
pub const A = struct { b: B };
pub const B = struct { a: *align(@alignOf(A)) A };
pub fn main() void {
    _ = @as(B, undefined);
}
#}
#update "reference dependency loop again"
#check errors {
error: dependency loop with length 2
    main.zig:2:43: note: type 'main.B' depends on type 'main.A' for alignment query here
    main.zig:1:27: note: type 'main.A' depends on type 'main.B' for field declared here
    note: eliminate any one of these dependencies to break the loop
#}

#write main.zig {
pub const A = struct { b: B };
pub const B = struct { a: *A };
pub fn main() void {
    _ = @as(B, undefined);
}
#}
#update "fix dependency loop"
#check stdout
