authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-09-06 11:42:57-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-09-20 18:33:00-07:00
logaacff8c80091c0187057e65d96108f46962f98a3
tree22c59cf724f036d55fcdacc33adad24c9969ecff
parent7b8a7989ef54b7ac859035cbc603b8012f8f4102

add compile error coverage for dependency loop


2 files changed, 19 insertions(+), 2 deletions(-)

test/cases/compile_errors/enum_field_value_references_enum.zig+3-2
...@@ -1,6 +1,8 @@...@@ -1,6 +1,8 @@
1pub const Foo = enum(c_int) {1pub const Foo = enum(c_int) {
2 A = Foo.B,2 A = Foo.B,
3 C = D,3 C = D,
4
5 pub const B = 0;
4};6};
5export fn entry() void {7export fn entry() void {
6 const s: Foo = Foo.E;8 const s: Foo = Foo.E;
...@@ -10,5 +12,4 @@ const D = 1;...@@ -10,5 +12,4 @@ const D = 1;
1012
11// error13// error
12//14//
13// :2:13: error: enum 'tmp.Foo' has no member named 'B'15// :1:5: error: dependency loop detected
14// :1:17: note: enum declared here
test/cases/compile_errors/enum_field_value_references_nonexistent_circular.zig created+16
...@@ -0,0 +1,16 @@
1pub const Foo = enum(c_int) {
2 A = Foo.B,
3 C = D,
4};
5export fn entry() void {
6 const s: Foo = Foo.E;
7 _ = s;
8}
9const D = 1;
10
11// error
12// backend=stage2
13// target=native
14//
15// :2:13: error: enum 'tmp.Foo' has no member named 'B'
16// :1:17: note: enum declared here