fix ZIR decoding of error notes

This commit is contained in:
Andrew Kelley 2023-03-09 14:17:25 -07:00
parent 974a6fe757
commit 23295f64ca
3 changed files with 9 additions and 3 deletions

View File

@ -10382,7 +10382,7 @@ fn appendErrorTok(
comptime format: []const u8,
args: anytype,
) !void {
try astgen.appendErrorTokNotes(token, format, args, &[0]u32{});
try astgen.appendErrorTokNotesOff(token, 0, format, args, &[0]u32{});
}
fn failTokNotes(
@ -10392,7 +10392,7 @@ fn failTokNotes(
args: anytype,
notes: []const u32,
) InnerError {
try appendErrorTokNotes(astgen, token, format, args, notes);
try appendErrorTokNotesOff(astgen, token, 0, format, args, notes);
return error.AnalysisFail;
}

View File

@ -2909,7 +2909,7 @@ pub fn addZirErrorMessages(eb: *ErrorBundle.Wip, file: *Module.File) !void {
.column = @intCast(u32, err_loc.column),
.source_line = try eb.addString(err_loc.source_line),
}),
.notes_len = item.data.notes,
.notes_len = item.data.notesLen(file.zir),
});
}

View File

@ -3594,6 +3594,12 @@ pub const Inst = struct {
/// 0 or a payload index of a `Block`, each is a payload
/// index of another `Item`.
notes: u32,
pub fn notesLen(item: Item, zir: Zir) u32 {
if (item.notes == 0) return 0;
const block = zir.extraData(Block, item.notes);
return block.data.body_len;
}
};
};