aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-12-19 16:30:09 +0200
committerVeikka Tuominen <git@vexu.eu>2022-12-19 17:01:44 +0200
commit0c1d8659c51d9544fb8d5de7481e750149c262ae (patch)
tree0b751f4d3a5dfcd0bd8c3fead2d06ff579c55ed5 /src
parentee334aea801c71cbcc567b1d19be9c04d911beda (diff)
downloadzig-0c1d8659c51d9544fb8d5de7481e750149c262ae.tar.gz
zig-0c1d8659c51d9544fb8d5de7481e750149c262ae.zip
Sema: print notes and reference traces when using `--debug-compile-errors`
Diffstat (limited to 'src')
-rw-r--r--src/Compilation.zig2
-rw-r--r--src/Sema.zig21
2 files changed, 11 insertions, 12 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index 1d0997d20c..b385fa5f72 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -572,7 +572,7 @@ pub const AllErrors = struct {
self.arena.promote(gpa).deinit();
}
- fn add(
+ pub fn add(
module: *Module,
arena: *std.heap.ArenaAllocator,
errors: *std.ArrayList(Message),
diff --git a/src/Sema.zig b/src/Sema.zig
index 02f6b24e2d..f03211210c 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -113,6 +113,7 @@ const target_util = @import("target.zig");
const Package = @import("Package.zig");
const crash_report = @import("crash_report.zig");
const build_options = @import("build_options");
+const Compilation = @import("Compilation.zig");
pub const default_branch_quota = 1000;
pub const default_reference_trace_len = 2;
@@ -2191,18 +2192,16 @@ fn failWithOwnedErrorMsg(sema: *Sema, err_msg: *Module.ErrorMsg) CompileError {
@setCold(true);
if (crash_report.is_enabled and sema.mod.comp.debug_compile_errors) {
- const err_path = err_msg.src_loc.file_scope.fullPath(sema.mod.gpa) catch unreachable;
- const err_source = err_msg.src_loc.file_scope.getSource(sema.mod.gpa) catch unreachable;
if (err_msg.src_loc.lazy == .unneeded) return error.NeededSourceLocation;
- const err_span = err_msg.src_loc.span(sema.mod.gpa) catch unreachable;
- const err_loc = std.zig.findLineColumn(err_source.bytes, err_span.main);
- std.debug.print("compile error during Sema:\n{s}:{d}:{d}: error: {s}\n{s}\n\n", .{
- err_path,
- err_loc.line + 1,
- err_loc.column + 1,
- err_msg.msg,
- err_loc.source_line,
- });
+ var arena = std.heap.ArenaAllocator.init(sema.gpa);
+ errdefer arena.deinit();
+ var errors = std.ArrayList(Compilation.AllErrors.Message).init(sema.gpa);
+ defer errors.deinit();
+
+ Compilation.AllErrors.add(sema.mod, &arena, &errors, err_msg.*) catch unreachable;
+
+ std.debug.print("compile error during Sema:\n", .{});
+ Compilation.AllErrors.Message.renderToStdErr(errors.items[0], .no_color);
crash_report.compilerPanic("unexpected compile error occurred", null, null);
}