authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-02-05 18:31:39+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-02-05 18:31:39+00:00
log3ce857d0543780e96bfd50d75d53d870ff308fef
tree25ed83292cde880900700a6239dac455a3ffe357
parentf01f1e33c96f0b00db8e036a654c1b3bf8531cd8
signature Commit is signed but in an unrecognized format.

Sema: fix incorrectly succeeding type resolution

Resolves: #21436

2 files changed, 13 insertions(+), 1 deletions(-)

src/InternPool.zig+1-1
...@@ -4011,7 +4011,7 @@ pub const LoadedStructType = struct {...@@ -4011,7 +4011,7 @@ pub const LoadedStructType = struct {
40114011
4012 pub fn haveFieldTypes(s: LoadedStructType, ip: *const InternPool) bool {4012 pub fn haveFieldTypes(s: LoadedStructType, ip: *const InternPool) bool {
4013 const types = s.field_types.get(ip);4013 const types = s.field_types.get(ip);
4014 return types.len == 0 or types[0] != .none;4014 return types.len == 0 or types[types.len - 1] != .none;
4015 }4015 }
40164016
4017 pub fn haveFieldInits(s: LoadedStructType, ip: *const InternPool) bool {4017 pub fn haveFieldInits(s: LoadedStructType, ip: *const InternPool) bool {
test/cases/compile_errors/struct_depends_on_itself_via_non_initial_field.zig created+12
...@@ -0,0 +1,12 @@
1const A = struct {
2 a: u8,
3 bytes: [@sizeOf(A)]u8,
4};
5
6comptime {
7 _ = A;
8}
9
10// error
11//
12// :1:11: error: struct 'tmp.A' depends on itself