Skip to content

Commit d5cfbb4

Browse files
committed
Revert the last two commits in this branch
When the slice-by-length start position is runtime-known, it is likely protected by a runtime-known condition and therefore a compile error is less appropriate than a runtime panic check. This is demonstrated in the json code that was updated and then reverted in this commit. When ziglang#3806 is implemented, this decision can be reassessed. Revert "std: work around compiler unable to evaluate condition at compile time" Revert "frontend: comptime array slice-by-length OOB detection" This reverts commit 7741aca. This reverts commit 2583b38.
1 parent 3990c8e commit d5cfbb4

File tree

2 files changed

+2
-17
lines changed

2 files changed

+2
-17
lines changed

compile_errors/out of bounds array slice by length.zig

Lines changed: 0 additions & 15 deletions
This file was deleted.

safety/out of bounds array slice by length.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ const std = @import("std");
22

33
pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
44
_ = stack_trace;
5-
if (std.mem.eql(u8, message, "index out of bounds: index 9, len 5")) {
5+
if (std.mem.eql(u8, message, "index out of bounds: index 16, len 5")) {
66
std.process.exit(0);
77
}
88
std.process.exit(1);
99
}
1010
pub fn main() !void {
1111
var buf: [5]u8 = undefined;
12-
_ = buf[foo(6)..][0..3];
12+
_ = buf[foo(6)..][0..10];
1313
return error.TestFailed;
1414
}
1515
fn foo(a: u32) u32 {

0 commit comments

Comments
 (0)