Sema: populate the sentinel for comptime array inits

This commit is contained in:
Andrew Kelley
2022-01-15 22:46:39 -07:00
parent 0d2f4d0654
commit 7c6f5d26ea
3 changed files with 33 additions and 15 deletions

View File

@@ -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();
}