1#exe {
2-Mroot=main.zig
3#}
4
5#write main.zig {
6pub const A = struct { b: B };
7pub const B = struct { a: A };
8pub fn main() void {
9 _ = @as(B, undefined);
10}
11#}
12#update
13#check errors {
14error: dependency loop with length 2
15 main.zig:2:27: note: type 'main.B' depends on type 'main.A' for field declared here
16 main.zig:1:27: note: type 'main.A' depends on type 'main.B' for field declared here
17 note: eliminate any one of these dependencies to break the loop
18#}
19
20#write main.zig {
21pub const A = struct { b: B };
22pub const B = struct { a: A };
23pub fn main() void {
24 _ = B;
25}
26#}
27#update "remove reference to dependency loop"
28#check stdout
29
30#write main.zig {
31pub const A = struct { b: B };
32pub const B = struct { a: *align(@alignOf(A)) A };
33pub fn main() void {
34 _ = B;
35}
36#}
37#update "change dependency loop without fixing it"
38#check stdout
39
40#write main.zig {
41pub const A = struct { b: B };
42pub const B = struct { a: *align(@alignOf(A)) A };
43pub fn main() void {
44 _ = @as(B, undefined);
45}
46#}
47#update "reference dependency loop again"
48#check errors {
49error: dependency loop with length 2
50 main.zig:2:43: note: type 'main.B' depends on type 'main.A' for alignment query here
51 main.zig:1:27: note: type 'main.A' depends on type 'main.B' for field declared here
52 note: eliminate any one of these dependencies to break the loop
53#}
54
55#write main.zig {
56pub const A = struct { b: B };
57pub const B = struct { a: *A };
58pub fn main() void {
59 _ = @as(B, undefined);
60}
61#}
62#update "fix dependency loop"
63#check stdout