aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorMatthew Lugg <mlugg@mlugg.co.uk>2024-12-31 14:35:28 +0000
committerGitHub <noreply@github.com>2024-12-31 14:35:28 +0000
commit0df1f3df2f25bf12071f11e9b738a356dfbd214d (patch)
treefd7830fb82c95f52a79fd9984af4caacb090f3fe /src/Compilation.zig
parent6d67658965bc298a697dc756a4e06bda144427de (diff)
parent106df881d3a3fe3b744f0563b99cff88d7ef6549 (diff)
downloadzig-0df1f3df2f25bf12071f11e9b738a356dfbd214d.tar.gz
zig-0df1f3df2f25bf12071f11e9b738a356dfbd214d.zip
Merge pull request #22352 from mlugg/zir-comptime-reason
Zir: attach reason to `block_comptime` and improve corresponding error reporting
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig6
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) {