authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-22 15:58:19-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-03-22 15:58:19-07:00
log44f9061b718e9bdcd43d258291f89930b74aa56a
treebb753832ef6ab9ed8fb3bc873222627453033639
parent60d8c4739de14823c407245f01c9b7483f3b6e7f

fix merge conflicts and test cases


2 files changed, 14 insertions(+), 5 deletions(-)

src/Sema.zig+13-4
......@@ -19732,7 +19732,10 @@ fn analyzeSlice(
1973219732 block,
1973319733 end_src,
1973419734 "end index {} out of bounds for array of length {}",
19735 .{ end_val.fmtValue(Type.usize), len_val.fmtValue(Type.usize) },
19735 .{
19736 end_val.fmtValue(Type.usize, target),
19737 len_val.fmtValue(Type.usize, target),
19738 },
1973619739 );
1973719740 }
1973819741 if (end_val.eql(len_val, Type.usize, target)) {
......@@ -19758,7 +19761,10 @@ fn analyzeSlice(
1975819761 block,
1975919762 end_src,
1976019763 "end index {} out of bounds for slice of length {}",
19761 .{ end_val.fmtValue(Type.usize), slice_len_val.fmtValue(Type.usize) },
19764 .{
19765 end_val.fmtValue(Type.usize, target),
19766 slice_len_val.fmtValue(Type.usize, target),
19767 },
1976219768 );
1976319769 }
1976419770 if (end_val.eql(slice_len_val, Type.usize, target)) {
......@@ -19794,12 +19800,15 @@ fn analyzeSlice(
1979419800 // requirement: start <= end
1979519801 if (try sema.resolveDefinedValue(block, src, end)) |end_val| {
1979619802 if (try sema.resolveDefinedValue(block, src, start)) |start_val| {
19797 if (start_val.compare(.gt, end_val, Type.usize)) {
19803 if (start_val.compare(.gt, end_val, Type.usize, target)) {
1979819804 return sema.fail(
1979919805 block,
1980019806 start_src,
1980119807 "start index {} is larger than end index {}",
19802 .{ start_val.fmtValue(Type.usize), end_val.fmtValue(Type.usize) },
19808 .{
19809 start_val.fmtValue(Type.usize, target),
19810 end_val.fmtValue(Type.usize, target),
19811 },
1980319812 );
1980419813 }
1980519814 }
test/stage2/x86_64.zig+1-1
......@@ -1166,7 +1166,7 @@ pub fn addCases(ctx: *TestContext) !void {
11661166 \\ _ = x;
11671167 \\}
11681168 , &[_][]const u8{
1169 ":2:9: error: variable of type '@Type(.Null)' must be const or comptime",
1169 ":2:9: error: variable of type '@TypeOf(null)' must be const or comptime",
11701170 });
11711171 }
11721172