From 4794c6a526ea507984af8aa460a6897da1c7c785 Mon Sep 17 00:00:00 2001 From: Jacob Young Date: Tue, 2 Apr 2024 04:01:52 -0400 Subject: Sema: fix crash accessing array of opv types Closes #19499 --- test/behavior/array.zig | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/behavior/array.zig') diff --git a/test/behavior/array.zig b/test/behavior/array.zig index 9761ac5bd7..23ea10557f 100644 --- a/test/behavior/array.zig +++ b/test/behavior/array.zig @@ -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 == {}); +} -- cgit v1.2.3