Sema: fix error location when casting pointer to slice

Co-authored-by: Veikka Tuominen <git@vexu.eu>
This commit is contained in:
Ali Chraghi
2022-10-06 16:22:05 +03:30
committed by Veikka Tuominen
parent 3234e8de3a
commit 6672921e32
2 changed files with 11 additions and 1 deletions

View File

@@ -27202,7 +27202,7 @@ fn analyzeSlice(
if (!end_is_len) {
break :e try sema.coerce(block, Type.usize, uncasted_end_opt, end_src);
}
return sema.fail(block, end_src, "slice of pointer must include end value", .{});
return sema.fail(block, src, "slice of pointer must include end value", .{});
};
const sentinel = s: {

View File

@@ -0,0 +1,10 @@
comptime {
var ptr: [*]u8 = undefined;
_ = ptr[0..];
}
// error
// backend=stage2
// target=native
//
// :3:12: error: slice of pointer must include end value