add compile error coverage for dependency loop

This commit is contained in:
Andrew Kelley 2025-09-06 11:42:57 -07:00
parent 7b8a7989ef
commit aacff8c800
2 changed files with 19 additions and 2 deletions

View File

@ -1,6 +1,8 @@
pub const Foo = enum(c_int) {
A = Foo.B,
C = D,
pub const B = 0;
};
export fn entry() void {
const s: Foo = Foo.E;
@ -10,5 +12,4 @@ const D = 1;
// error
//
// :2:13: error: enum 'tmp.Foo' has no member named 'B'
// :1:17: note: enum declared here
// :1:5: error: dependency loop detected

View File

@ -0,0 +1,16 @@
pub const Foo = enum(c_int) {
A = Foo.B,
C = D,
};
export fn entry() void {
const s: Foo = Foo.E;
_ = s;
}
const D = 1;
// error
// backend=stage2
// target=native
//
// :2:13: error: enum 'tmp.Foo' has no member named 'B'
// :1:17: note: enum declared here