diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-08-02 19:54:54 +0300 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-08-03 16:45:33 +0300 |
| commit | aa78ebaf95af5a3587194d8dbcb101a49c0bb898 (patch) | |
| tree | 9bcaccf99a4460368f9e9bafc9032d6167864e92 /test/cases/compile_errors | |
| parent | 797ded47f05ce033be58d3fb78d777ec3218048b (diff) | |
| download | zig-aa78ebaf95af5a3587194d8dbcb101a49c0bb898.tar.gz zig-aa78ebaf95af5a3587194d8dbcb101a49c0bb898.zip | |
Sema: improve circular dependency errors
Diffstat (limited to 'test/cases/compile_errors')
| -rw-r--r-- | test/cases/compile_errors/direct_struct_loop.zig | 9 | ||||
| -rw-r--r-- | test/cases/compile_errors/indirect_struct_loop.zig | 13 | ||||
| -rw-r--r-- | test/cases/compile_errors/instantiating_an_undefined_value_for_an_invalid_struct_that_contains_itself.zig (renamed from test/cases/compile_errors/stage1/obj/instantiating_an_undefined_value_for_an_invalid_struct_that_contains_itself.zig) | 5 | ||||
| -rw-r--r-- | test/cases/compile_errors/instantiating_an_undefined_value_for_an_invalid_union_that_contains_itself.zig | 16 | ||||
| -rw-r--r-- | test/cases/compile_errors/stage1/obj/direct_struct_loop.zig | 8 | ||||
| -rw-r--r-- | test/cases/compile_errors/stage1/obj/indirect_struct_loop.zig | 10 | ||||
| -rw-r--r-- | test/cases/compile_errors/struct_depends_on_itself_via_optional_field.zig (renamed from test/cases/compile_errors/stage1/obj/struct_depends_on_itself_via_optional_field.zig) | 8 |
7 files changed, 45 insertions, 24 deletions
diff --git a/test/cases/compile_errors/direct_struct_loop.zig b/test/cases/compile_errors/direct_struct_loop.zig new file mode 100644 index 0000000000..0abc1a4f73 --- /dev/null +++ b/test/cases/compile_errors/direct_struct_loop.zig @@ -0,0 +1,9 @@ +const A = struct { a : A, }; +export fn entry() usize { return @sizeOf(A); } + +// error +// backend=stage2 +// target=native +// +// :1:11: error: struct 'tmp.A' depends on itself +// :1:20: note: while checking this field diff --git a/test/cases/compile_errors/indirect_struct_loop.zig b/test/cases/compile_errors/indirect_struct_loop.zig new file mode 100644 index 0000000000..dca2b9c3f6 --- /dev/null +++ b/test/cases/compile_errors/indirect_struct_loop.zig @@ -0,0 +1,13 @@ +const A = struct { b : B, }; +const B = struct { c : C, }; +const C = struct { a : A, }; +export fn entry() usize { return @sizeOf(A); } + +// error +// backend=stage2 +// target=native +// +// :1:11: error: struct 'tmp.A' depends on itself +// :3:20: note: while checking this field +// :2:20: note: while checking this field +// :1:20: note: while checking this field diff --git a/test/cases/compile_errors/stage1/obj/instantiating_an_undefined_value_for_an_invalid_struct_that_contains_itself.zig b/test/cases/compile_errors/instantiating_an_undefined_value_for_an_invalid_struct_that_contains_itself.zig index dd6909b1c2..74cafabe7c 100644 --- a/test/cases/compile_errors/stage1/obj/instantiating_an_undefined_value_for_an_invalid_struct_that_contains_itself.zig +++ b/test/cases/compile_errors/instantiating_an_undefined_value_for_an_invalid_struct_that_contains_itself.zig @@ -9,7 +9,8 @@ export fn entry() usize { } // error -// backend=stage1 +// backend=stage2 // target=native // -// tmp.zig:1:13: error: struct 'Foo' depends on itself +// :1:13: error: struct 'tmp.Foo' depends on itself +// :2:5: note: while checking this field diff --git a/test/cases/compile_errors/instantiating_an_undefined_value_for_an_invalid_union_that_contains_itself.zig b/test/cases/compile_errors/instantiating_an_undefined_value_for_an_invalid_union_that_contains_itself.zig new file mode 100644 index 0000000000..6030ca4d3e --- /dev/null +++ b/test/cases/compile_errors/instantiating_an_undefined_value_for_an_invalid_union_that_contains_itself.zig @@ -0,0 +1,16 @@ +const Foo = union { + x: Foo, +}; + +var foo: Foo = undefined; + +export fn entry() usize { + return @sizeOf(@TypeOf(foo.x)); +} + +// error +// backend=stage2 +// target=native +// +// :1:13: error: union 'tmp.Foo' depends on itself +// :2:5: note: while checking this field diff --git a/test/cases/compile_errors/stage1/obj/direct_struct_loop.zig b/test/cases/compile_errors/stage1/obj/direct_struct_loop.zig deleted file mode 100644 index 3062e617d6..0000000000 --- a/test/cases/compile_errors/stage1/obj/direct_struct_loop.zig +++ /dev/null @@ -1,8 +0,0 @@ -const A = struct { a : A, }; -export fn entry() usize { return @sizeOf(A); } - -// error -// backend=stage1 -// target=native -// -// tmp.zig:1:11: error: struct 'A' depends on itself diff --git a/test/cases/compile_errors/stage1/obj/indirect_struct_loop.zig b/test/cases/compile_errors/stage1/obj/indirect_struct_loop.zig deleted file mode 100644 index 12214923d0..0000000000 --- a/test/cases/compile_errors/stage1/obj/indirect_struct_loop.zig +++ /dev/null @@ -1,10 +0,0 @@ -const A = struct { b : B, }; -const B = struct { c : C, }; -const C = struct { a : A, }; -export fn entry() usize { return @sizeOf(A); } - -// error -// backend=stage1 -// target=native -// -// tmp.zig:1:11: error: struct 'A' depends on itself diff --git a/test/cases/compile_errors/stage1/obj/struct_depends_on_itself_via_optional_field.zig b/test/cases/compile_errors/struct_depends_on_itself_via_optional_field.zig index 46086172f7..cad779e3d7 100644 --- a/test/cases/compile_errors/stage1/obj/struct_depends_on_itself_via_optional_field.zig +++ b/test/cases/compile_errors/struct_depends_on_itself_via_optional_field.zig @@ -11,9 +11,9 @@ export fn entry() void { } // error -// backend=stage1 +// backend=stage2 // target=native // -// tmp.zig:1:17: error: struct 'LhsExpr' depends on itself -// tmp.zig:5:5: note: while checking this field -// tmp.zig:2:5: note: while checking this field +// :1:17: error: struct 'tmp.LhsExpr' depends on itself +// :5:5: note: while checking this field +// :2:5: note: while checking this field |
