authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-09 14:17:25-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-15 10:48:14-07:00
log23295f64ca8b93f32e75cef42cc1293ec334e890
treeedb46c61f32219966c1796f4008ba41ac3fabeae
parent974a6fe757fd53873e7dace177ad3ae3c425b504

fix ZIR decoding of error notes


3 files changed, 9 insertions(+), 3 deletions(-)

src/AstGen.zig+2-2
...@@ -10382,7 +10382,7 @@ fn appendErrorTok(...@@ -10382,7 +10382,7 @@ fn appendErrorTok(
10382 comptime format: []const u8,10382 comptime format: []const u8,
10383 args: anytype,10383 args: anytype,
10384) !void {10384) !void {
10385 try astgen.appendErrorTokNotes(token, format, args, &[0]u32{});10385 try astgen.appendErrorTokNotesOff(token, 0, format, args, &[0]u32{});
10386}10386}
1038710387
10388fn failTokNotes(10388fn failTokNotes(
...@@ -10392,7 +10392,7 @@ fn failTokNotes(...@@ -10392,7 +10392,7 @@ fn failTokNotes(
10392 args: anytype,10392 args: anytype,
10393 notes: []const u32,10393 notes: []const u32,
10394) InnerError {10394) InnerError {
10395 try appendErrorTokNotes(astgen, token, format, args, notes);10395 try appendErrorTokNotesOff(astgen, token, 0, format, args, notes);
10396 return error.AnalysisFail;10396 return error.AnalysisFail;
10397}10397}
1039810398
src/Compilation.zig+1-1
...@@ -2909,7 +2909,7 @@ pub fn addZirErrorMessages(eb: *ErrorBundle.Wip, file: *Module.File) !void {...@@ -2909,7 +2909,7 @@ pub fn addZirErrorMessages(eb: *ErrorBundle.Wip, file: *Module.File) !void {
2909 .column = @intCast(u32, err_loc.column),2909 .column = @intCast(u32, err_loc.column),
2910 .source_line = try eb.addString(err_loc.source_line),2910 .source_line = try eb.addString(err_loc.source_line),
2911 }),2911 }),
2912 .notes_len = item.data.notes,2912 .notes_len = item.data.notesLen(file.zir),
2913 });2913 });
2914 }2914 }
29152915
src/Zir.zig+6
...@@ -3594,6 +3594,12 @@ pub const Inst = struct {...@@ -3594,6 +3594,12 @@ pub const Inst = struct {
3594 /// 0 or a payload index of a `Block`, each is a payload3594 /// 0 or a payload index of a `Block`, each is a payload
3595 /// index of another `Item`.3595 /// index of another `Item`.
3596 notes: u32,3596 notes: u32,
3597
3598 pub fn notesLen(item: Item, zir: Zir) u32 {
3599 if (item.notes == 0) return 0;
3600 const block = zir.extraData(Block, item.notes);
3601 return block.data.body_len;
3602 }
3597 };3603 };
3598 };3604 };
35993605