aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-08-28 14:00:26 +0300
committerVeikka Tuominen <git@vexu.eu>2022-08-28 15:41:21 +0300
commite2dc77ab62edf5446af830356eceef8eefb67cfa (patch)
treeca09907e11ad2b5a10d3e11acf69cae7be220f2d /test
parent776caaf99927181a2bb135afa9b502014782691c (diff)
downloadzig-e2dc77ab62edf5446af830356eceef8eefb67cfa.tar.gz
zig-e2dc77ab62edf5446af830356eceef8eefb67cfa.zip
Sema: correct one possible value for tuples
Closes #12376
Diffstat (limited to 'test')
-rw-r--r--test/behavior/tuple.zig27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/behavior/tuple.zig b/test/behavior/tuple.zig
index 971e52a0b5..2b715c3b23 100644
--- a/test/behavior/tuple.zig
+++ b/test/behavior/tuple.zig
@@ -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);
+}