diff options
Diffstat (limited to 'src/Compilation.zig')
| -rw-r--r-- | src/Compilation.zig | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index 28c5efab6c..cee9513ac5 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -3435,6 +3435,7 @@ pub fn addModuleErrorMsg( var notes: std.ArrayHashMapUnmanaged(ErrorBundle.ErrorMessage, void, ErrorNoteHashContext, true) = .empty; defer notes.deinit(gpa); + var last_note_loc: ?std.zig.Loc = null; for (module_err_msg.notes) |module_note| { const note_src_loc = module_note.src_loc.upgrade(zcu); const source = try note_src_loc.file_scope.getSource(gpa); @@ -3443,6 +3444,9 @@ pub fn addModuleErrorMsg( const note_file_path = try note_src_loc.file_scope.fullPath(gpa); defer gpa.free(note_file_path); + const omit_source_line = loc.eql(err_loc) or (last_note_loc != null and loc.eql(last_note_loc.?)); + last_note_loc = loc; + const gop = try notes.getOrPutContext(gpa, .{ .msg = try eb.addString(module_note.msg), .src_loc = try eb.addSourceLocation(.{ @@ -3452,7 +3456,7 @@ pub fn addModuleErrorMsg( .span_end = span.end, .line = @intCast(loc.line), .column = @intCast(loc.column), - .source_line = if (err_loc.eql(loc)) 0 else try eb.addString(loc.source_line), + .source_line = if (omit_source_line) 0 else try eb.addString(loc.source_line), }), }, .{ .eb = eb }); if (gop.found_existing) { |
