fix merge conflicts and test cases

This commit is contained in:
Andrew Kelley 2022-03-22 15:58:19 -07:00
parent 60d8c4739d
commit 44f9061b71
2 changed files with 14 additions and 5 deletions

View File

@ -19732,7 +19732,10 @@ fn analyzeSlice(
block, block,
end_src, end_src,
"end index {} out of bounds for array of length {}", "end index {} out of bounds for array of length {}",
.{ end_val.fmtValue(Type.usize), len_val.fmtValue(Type.usize) }, .{
end_val.fmtValue(Type.usize, target),
len_val.fmtValue(Type.usize, target),
},
); );
} }
if (end_val.eql(len_val, Type.usize, target)) { if (end_val.eql(len_val, Type.usize, target)) {
@ -19758,7 +19761,10 @@ fn analyzeSlice(
block, block,
end_src, end_src,
"end index {} out of bounds for slice of length {}", "end index {} out of bounds for slice of length {}",
.{ end_val.fmtValue(Type.usize), slice_len_val.fmtValue(Type.usize) }, .{
end_val.fmtValue(Type.usize, target),
slice_len_val.fmtValue(Type.usize, target),
},
); );
} }
if (end_val.eql(slice_len_val, Type.usize, target)) { if (end_val.eql(slice_len_val, Type.usize, target)) {
@ -19794,12 +19800,15 @@ fn analyzeSlice(
// requirement: start <= end // requirement: start <= end
if (try sema.resolveDefinedValue(block, src, end)) |end_val| { if (try sema.resolveDefinedValue(block, src, end)) |end_val| {
if (try sema.resolveDefinedValue(block, src, start)) |start_val| { if (try sema.resolveDefinedValue(block, src, start)) |start_val| {
if (start_val.compare(.gt, end_val, Type.usize)) { if (start_val.compare(.gt, end_val, Type.usize, target)) {
return sema.fail( return sema.fail(
block, block,
start_src, start_src,
"start index {} is larger than end index {}", "start index {} is larger than end index {}",
.{ start_val.fmtValue(Type.usize), end_val.fmtValue(Type.usize) }, .{
start_val.fmtValue(Type.usize, target),
end_val.fmtValue(Type.usize, target),
},
); );
} }
} }

View File

@ -1166,7 +1166,7 @@ pub fn addCases(ctx: *TestContext) !void {
\\ _ = x; \\ _ = x;
\\} \\}
, &[_][]const u8{ , &[_][]const u8{
":2:9: error: variable of type '@Type(.Null)' must be const or comptime", ":2:9: error: variable of type '@TypeOf(null)' must be const or comptime",
}); });
} }