Skip to content

Commit ead8769

Browse files
author
dweiller
committed
sema: omit extraneous addition when safety is unwanted
1 parent a14d70a commit ead8769

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/Sema.zig

+1
Original file line numberDiff line numberDiff line change
@@ -29124,6 +29124,7 @@ fn analyzeSlice(
2912429124
var end_is_len = uncasted_end_opt == .none;
2912529125
const end = e: {
2912629126
if (by_length and !end_is_len) {
29127+
if (!block.wantSafety()) break :e undefined;
2912729128
const len = try sema.coerce(block, Type.usize, uncasted_end_opt, end_src);
2912829129
const uncasted_end = try sema.analyzeArithmetic(block, .add, start, len, src, start_src, end_src, false);
2912929130
const end = try sema.coerce(block, Type.usize, uncasted_end, end_src);

0 commit comments

Comments
 (0)