#target=x86_64-linux-selfhosted #target=x86_64-windows-selfhosted #target=x86_64-linux-cbe #target=x86_64-windows-cbe #target=wasm32-wasi-selfhosted #update=initial version #file=main.zig pub fn main() void {} comptime { var array = [_:0]u8{ 1, 2, 3, 4 }; const src_slice: [:0]u8 = &array; const slice = src_slice[2..6]; _ = slice; } comptime { var array = [_:0]u8{ 1, 2, 3, 4 }; const slice = array[2..6]; _ = slice; } comptime { var array = [_]u8{ 1, 2, 3, 4 }; const slice = array[2..5]; _ = slice; } comptime { var array = [_:0]u8{ 1, 2, 3, 4 }; const slice = array[3..2]; _ = slice; } #expect_error=main.zig:5:32: error: end index 6 out of bounds for slice of length 4 +1 (sentinel) #expect_error=main.zig:10:28: error: end index 6 out of bounds for array of length 4 +1 (sentinel) #expect_error=main.zig:15:28: error: end index 5 out of bounds for array of length 4 #expect_error=main.zig:20:25: error: start index 3 is larger than end index 2 #update=delete and modify comptime decls #file=main.zig pub fn main() void {} comptime { const x: [*c]u8 = null; var runtime_len: usize = undefined; runtime_len = 0; const y = x[0..runtime_len]; _ = y; } #expect_error=main.zig:6:16: error: slice of null pointer