Commit f49dff64c6
src/Sema.zig
@@ -4071,6 +4071,19 @@ fn zirValidateArrayInit(
// Determine whether the value stored to this pointer is comptime-known.
+ if (array_ty.isTuple()) {
+ if (array_ty.structFieldValueComptime(i)) |opv| {
+ element_vals[i] = opv;
+ continue;
+ }
+ } else {
+ // Array has one possible value, so value is always comptime-known
+ if (opt_opv) |opv| {
+ element_vals[i] = opv;
+ continue;
+ }
+ }
+
const elem_ptr_air_ref = sema.inst_map.get(elem_ptr).?;
const elem_ptr_air_inst = Air.refToIndex(elem_ptr_air_ref).?;
// Find the block index of the elem_ptr so that we can look at the next
@@ -4087,19 +4100,6 @@ fn zirValidateArrayInit(
}
first_block_index = @minimum(first_block_index, block_index);
- if (array_ty.isTuple()) {
- if (array_ty.structFieldValueComptime(i)) |opv| {
- element_vals[i] = opv;
- continue;
- }
- } else {
- // Array has one possible value, so value is always comptime-known
- if (opt_opv) |opv| {
- element_vals[i] = opv;
- continue;
- }
- }
-
// If the next instructon is a store with a comptime operand, this element
// is comptime.
const next_air_inst = block.instructions.items[block_index + 1];
test/behavior/tuple.zig
@@ -290,3 +290,14 @@ test "coerce tuple to tuple" {
};
try S.foo(.{123});
}
+
+test "tuple type with void field" {
+ if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO
+
+ const T = std.meta.Tuple(&[_]type{void});
+ const x = T{{}};
+ try expect(@TypeOf(x[0]) == void);
+}