zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 23295f64ca8b93f32e75cef42cc1293ec334e890 (tree)
parent 974a6fe757fd53873e7dace177ad3ae3c425b504
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Thu,  9 Mar 2023 14:17:25 -0700

fix ZIR decoding of error notes

Diffstat:
Msrc/AstGen.zig | 4++--
Msrc/Compilation.zig | 2+-
Msrc/Zir.zig | 6++++++
3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/AstGen.zig b/src/AstGen.zig @@ -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; } diff --git a/src/Compilation.zig b/src/Compilation.zig @@ -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), }); } diff --git a/src/Zir.zig b/src/Zir.zig @@ -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; + } }; };