| 1 | #exe { |
| 2 | -Mroot=main.zig |
| 3 | #} |
| 4 | |
| 5 | #write main.zig { |
| 6 | pub const A = struct { b: B }; |
| 7 | pub const B = struct { a: A }; |
| 8 | pub fn main() void { |
| 9 | _ = @as(B, undefined); |
| 10 | } |
| 11 | #} |
| 12 | #update |
| 13 | #check errors { |
| 14 | error: 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 { |
| 21 | pub const A = struct { b: B }; |
| 22 | pub const B = struct { a: A }; |
| 23 | pub fn main() void { |
| 24 | _ = B; |
| 25 | } |
| 26 | #} |
| 27 | #update "remove reference to dependency loop" |
| 28 | #check stdout |
| 29 | |
| 30 | #write main.zig { |
| 31 | pub const A = struct { b: B }; |
| 32 | pub const B = struct { a: *align(@alignOf(A)) A }; |
| 33 | pub fn main() void { |
| 34 | _ = B; |
| 35 | } |
| 36 | #} |
| 37 | #update "change dependency loop without fixing it" |
| 38 | #check stdout |
| 39 | |
| 40 | #write main.zig { |
| 41 | pub const A = struct { b: B }; |
| 42 | pub const B = struct { a: *align(@alignOf(A)) A }; |
| 43 | pub fn main() void { |
| 44 | _ = @as(B, undefined); |
| 45 | } |
| 46 | #} |
| 47 | #update "reference dependency loop again" |
| 48 | #check errors { |
| 49 | error: 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 { |
| 56 | pub const A = struct { b: B }; |
| 57 | pub const B = struct { a: *A }; |
| 58 | pub fn main() void { |
| 59 | _ = @as(B, undefined); |
| 60 | } |
| 61 | #} |
| 62 | #update "fix dependency loop" |
| 63 | #check stdout |