stage2: out of bounds error for slicing

This commit is contained in:
Mitchell Hashimoto
2022-03-20 20:04:18 -07:00
committed by Andrew Kelley
parent 0fb005d1d0
commit 91fd0f42c8
3 changed files with 58 additions and 1 deletions
+23
View File
@@ -21,6 +21,29 @@ pub fn addCases(ctx: *TestContext) !void {
, &[_][]const u8{
":2:20: error: import of file outside package path: '../../above.zig'",
});
case.addError(
\\comptime {
\\ var array = [_:0]u8{ 1, 2, 3, 4 };
\\ var src_slice: [:0]u8 = &array;
\\ var slice = src_slice[2..5];
\\ _ = slice;
\\}
\\comptime {
\\ var array = [_:0]u8{ 1, 2, 3, 4 };
\\ var slice = array[2..5];
\\ _ = slice;
\\}
\\comptime {
\\ var array = [_:0]u8{ 1, 2, 3, 4 };
\\ var slice = array[3..2];
\\ _ = slice;
\\}
, &[_][]const u8{
":4:26: error: end index 5 out of bounds for slice of length 4",
":9:22: error: end index 5 out of bounds for array of length 4",
":14:22: error: start index 3 is larger than end index 2",
});
}
ctx.objErrStage1("exported enum without explicit integer tag type",