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