Sema: fix crash accessing array of opv types

Closes #19499
This commit is contained in:
Jacob Young
2024-04-02 04:01:52 -04:00
committed by Andrew Kelley
parent d2be725e4b
commit 4794c6a526
2 changed files with 19 additions and 2 deletions

View File

@@ -944,3 +944,14 @@ test "union that needs padding bytes inside an array" {
const a = as[0].B;
try std.testing.expect(a.D == 1);
}
test "runtime index of array of zero-bit values" {
var runtime: struct { array: [1]void, index: usize } = undefined;
runtime = .{ .array = .{{}}, .index = 0 };
const result = struct { index: usize, value: void }{
.index = runtime.index,
.value = runtime.array[runtime.index],
};
try std.testing.expect(result.index == 0);
try std.testing.expect(result.value == {});
}