aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-01-13 23:20:33 -0700
committerAndrew Kelley <andrew@ziglang.org>2024-01-13 23:21:44 -0700
commitbd46410419086acd274e33b47d9ae5dc1f678a1b (patch)
tree7899c29d06764ad2b64dea83137847b4d3f2710e /src
parent0f9345ea9a138a23937321cde3f83a76838ee36a (diff)
downloadzig-bd46410419086acd274e33b47d9ae5dc1f678a1b.tar.gz
zig-bd46410419086acd274e33b47d9ae5dc1f678a1b.zip
Revert "Merge pull request #18410 from dweiller/by-length-slice-bug"
This reverts commit d9d840a33ac8abb0e616de862f592821a7f4a35e, reversing changes made to a04d4330945565b8d6f298ace993f6954c42d0f3. This is not an adequate implementation of the missing safety check, as evidenced by the changes to std.json that are reverted in this commit. Reopens #18382 Closes #18510
Diffstat (limited to 'src')
-rw-r--r--src/Sema.zig24
1 files changed, 0 insertions, 24 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index f66b505e5c..941c91fcd0 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -32635,30 +32635,6 @@ fn analyzeSlice(
if (!end_is_len) {
const end = if (by_length) end: {
const len = try sema.coerce(block, Type.usize, uncasted_end_opt, end_src);
- if (try sema.resolveValue(len)) |slice_len_val| {
- const len_s_val = try mod.intValue(
- Type.usize,
- array_ty.arrayLenIncludingSentinel(mod),
- );
- if (!(try sema.compareScalar(slice_len_val, .lte, len_s_val, Type.usize))) {
- const sentinel_label: []const u8 = if (array_ty.sentinel(mod) != null)
- " +1 (sentinel)"
- else
- "";
-
- return sema.fail(
- block,
- end_src,
- "length {} out of bounds for array of length {}{s}",
- .{
- slice_len_val.fmtValue(Type.usize, mod),
- len_val.fmtValue(Type.usize, mod),
- sentinel_label,
- },
- );
- }
- }
- // check len is less than array size if comptime known
const uncasted_end = try sema.analyzeArithmetic(block, .add, start, len, src, start_src, end_src, false);
break :end try sema.coerce(block, Type.usize, uncasted_end, end_src);
} else try sema.coerce(block, Type.usize, uncasted_end_opt, end_src);