authorgravatar for 4678790+dweiller@users.noreply.github.comDominic <4678790+dweiller@users.noreply.github.com> 2023-05-03 11:30:30+10:00
committergravatar for 4678790+dweiller@users.noreply.github.comDominic <4678790+dweiller@users.noreply.github.com> 2023-05-07 15:55:21+10:00
logcba9077cc12b953dd00369f9c0340d7667af1611
tree4a15721ac1f1aa7b3868dbe2badbaa254f346e9a
parentbd3360e03d89fe947e3728ccacd4274653926376

sema: fix slice by length non-array, non-slice case


1 files changed, 5 insertions(+), 1 deletions(-)

src/Sema.zig+5-1
...@@ -29384,7 +29384,11 @@ fn analyzeSlice(...@@ -29384,7 +29384,11 @@ fn analyzeSlice(
29384 break :e try sema.analyzeSliceLen(block, src, ptr_or_slice);29384 break :e try sema.analyzeSliceLen(block, src, ptr_or_slice);
29385 }29385 }
29386 if (!end_is_len) {29386 if (!end_is_len) {
29387 break :e try sema.coerce(block, Type.usize, uncasted_end_opt, end_src);29387 if (by_length) {
29388 const len = try sema.coerce(block, Type.usize, uncasted_end_opt, end_src);
29389 const uncasted_end = try sema.analyzeArithmetic(block, .add, start, len, src, start_src, end_src, false);
29390 break :e try sema.coerce(block, Type.usize, uncasted_end, end_src);
29391 } else break :e try sema.coerce(block, Type.usize, uncasted_end_opt, end_src);
29388 }29392 }
29389 return sema.fail(block, src, "slice of pointer must include end value", .{});29393 return sema.fail(block, src, "slice of pointer must include end value", .{});
29390 };29394 };