This commit is contained in:
xdBronch 2025-11-24 13:06:59 -03:00 committed by GitHub
commit 3acbc65624
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -32057,9 +32057,15 @@ fn analyzeSlice(
var runtime_src: ?LazySrcLoc = null; var runtime_src: ?LazySrcLoc = null;
// requirement: start <= end // requirement: start <= end
if (try sema.resolveDefinedValue(block, end_src, end)) |end_val| { if (try sema.resolveDefinedValue(block, start_src, start)) |start_val| {
if (try sema.resolveDefinedValue(block, start_src, start)) |start_val| { if (try sema.compareAll(start_val, .eq, .zero_usize, .usize)) {
if (!by_length and !(try sema.compareAll(start_val, .lte, end_val, .usize))) { checked_start_lte_end = true;
}
if (try sema.resolveDefinedValue(block, end_src, end)) |end_val| {
if (!checked_start_lte_end and
!by_length and
!(try sema.compareAll(start_val, .lte, end_val, .usize)))
{
return sema.fail( return sema.fail(
block, block,
start_src, start_src,
@ -32115,10 +32121,10 @@ fn analyzeSlice(
runtime_src = ptr_src; runtime_src = ptr_src;
} }
} else { } else {
runtime_src = start_src; runtime_src = end_src;
} }
} else { } else {
runtime_src = end_src; runtime_src = start_src;
} }
if (!checked_start_lte_end and block.wantSafety() and !block.isComptime()) { if (!checked_start_lte_end and block.wantSafety() and !block.isComptime()) {
@ -32181,7 +32187,8 @@ fn analyzeSlice(
else else
end; end;
try sema.addSafetyCheckIndexOob(block, src, actual_end, actual_len, .cmp_lte); if (try sema.resolveDefinedValue(block, src, actual_end) == null)
try sema.addSafetyCheckIndexOob(block, src, actual_end, actual_len, .cmp_lte);
} }
// requirement: result[new_len] == slice_sentinel // requirement: result[new_len] == slice_sentinel
@ -32246,9 +32253,6 @@ fn analyzeSlice(
end; end;
try sema.addSafetyCheckIndexOob(block, src, actual_end, len_inst, .cmp_lte); try sema.addSafetyCheckIndexOob(block, src, actual_end, len_inst, .cmp_lte);
} }
// requirement: start <= end
try sema.addSafetyCheckIndexOob(block, src, start, end, .cmp_lte);
} }
const result = try block.addInst(.{ const result = try block.addInst(.{
.tag = .slice, .tag = .slice,