Sema: correct one possible value for tuples

Closes #12376
This commit is contained in:
Veikka Tuominen
2022-08-28 14:00:26 +03:00
parent 776caaf999
commit e2dc77ab62
3 changed files with 41 additions and 13 deletions

View File

@@ -301,3 +301,30 @@ test "tuple type with void field" {
const x = T{{}};
try expect(@TypeOf(x[0]) == void);
}
test "zero sized struct in tuple handled correctly" {
const State = struct {
const Self = @This();
data: @Type(.{
.Struct = .{
.is_tuple = true,
.layout = .Auto,
.decls = &.{},
.fields = &.{.{
.name = "0",
.field_type = struct {},
.default_value = null,
.is_comptime = false,
.alignment = 0,
}},
},
}),
pub fn do(this: Self) usize {
return @sizeOf(@TypeOf(this));
}
};
var s: State = undefined;
try expect(s.do() == 0);
}