1#update=initial version
2#file=main.zig
3pub fn main() void {}
4comptime {
5 var array = [_:0]u8{ 1, 2, 3, 4 };
6 const src_slice: [:0]u8 = &array;
7 const slice = src_slice[2..6];
8 _ = slice;
9}
10comptime {
11 var array = [_:0]u8{ 1, 2, 3, 4 };
12 const slice = array[2..6];
13 _ = slice;
14}
15comptime {
16 var array = [_]u8{ 1, 2, 3, 4 };
17 const slice = array[2..5];
18 _ = slice;
19}
20comptime {
21 var array = [_:0]u8{ 1, 2, 3, 4 };
22 const slice = array[3..2];
23 _ = slice;
24}
25#expect_error=main.zig:5:32: error: end index 6 out of bounds for slice of length 4 +1 (sentinel)
26#expect_error=main.zig:10:28: error: end index 6 out of bounds for array of length 4 +1 (sentinel)
27#expect_error=main.zig:15:28: error: end index 5 out of bounds for array of length 4
28#expect_error=main.zig:20:25: error: start index 3 is larger than end index 2
29
30#update=delete and modify comptime decls
31#file=main.zig
32pub fn main() void {}
33comptime {
34 const x: [*c]u8 = null;
35 var runtime_len: usize = undefined;
36 runtime_len = 0;
37 const y = x[0..runtime_len];
38 _ = y;
39}
40#expect_error=main.zig:6:16: error: slice of null pointer