From 7c6f5d26eadb137ab3fb2be340485ebd860a85fe Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 15 Jan 2022 22:46:39 -0700 Subject: Sema: populate the sentinel for comptime array inits --- test/behavior/array_llvm.zig | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/behavior/array_llvm.zig') diff --git a/test/behavior/array_llvm.zig b/test/behavior/array_llvm.zig index f1a57d9c29..5bbb06cffe 100644 --- a/test/behavior/array_llvm.zig +++ b/test/behavior/array_llvm.zig @@ -166,3 +166,16 @@ test "anonymous literal in array" { try S.doTheTest(); comptime try S.doTheTest(); } + +test "access the null element of a null terminated array" { + const S = struct { + fn doTheTest() !void { + var array: [4:0]u8 = .{ 'a', 'o', 'e', 'u' }; + try expect(array[4] == 0); + var len: usize = 4; + try expect(array[len] == 0); + } + }; + try S.doTheTest(); + comptime try S.doTheTest(); +} -- cgit v1.2.3