diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2025-03-30 22:59:25 +0100 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2025-05-16 11:55:35 +0100 |
| commit | 70040778fbde5d7fcbbfc26dbabc700024c538d5 (patch) | |
| tree | 171a2b244a979e0943305f1460e466c6a1d2123b /src/Sema.zig | |
| parent | cc1475c91da6005d72192b426e8b9ec6db7a3f74 (diff) | |
| download | zig-70040778fbde5d7fcbbfc26dbabc700024c538d5.tar.gz zig-70040778fbde5d7fcbbfc26dbabc700024c538d5.zip | |
Compilation: fix reference trace behavior without `-freference-trace`
When `-freference-trace` is not passed, we want to show exactly one
reference trace. Previously, we set the reference trace root in `Sema`
iff there were no other failed analyses. However, this results in an
arbitrary error being the one with the reference trace after error
sorting. It is also incompatible with incremental compilation, where
some errors might be unreferenced. Instead, set the field on all
analysis errors, and decide in `Compilation.getAllErrorsAlloc` which
reference trace[s] to actually show.
Diffstat (limited to 'src/Sema.zig')
| -rw-r--r-- | src/Sema.zig | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index 8889b475fd..e13aba3349 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -191,7 +191,6 @@ const LowerZon = @import("Sema/LowerZon.zig"); const arith = @import("Sema/arith.zig"); pub const default_branch_quota = 1000; -pub const default_reference_trace_len = 2; pub const InferredErrorSet = struct { /// The function body from which this error set originates. @@ -2580,7 +2579,7 @@ pub fn failWithOwnedErrorMsg(sema: *Sema, block: ?*Block, err_msg: *Zcu.ErrorMsg if (build_options.enable_debug_extensions and zcu.comp.debug_compile_errors) { var wip_errors: std.zig.ErrorBundle.Wip = undefined; wip_errors.init(gpa) catch @panic("out of memory"); - Compilation.addModuleErrorMsg(zcu, &wip_errors, err_msg.*) catch @panic("out of memory"); + Compilation.addModuleErrorMsg(zcu, &wip_errors, err_msg.*, false) catch @panic("out of memory"); std.debug.print("compile error during Sema:\n", .{}); var error_bundle = wip_errors.toOwnedBundle("") catch @panic("out of memory"); error_bundle.renderToStdErr(.{ .ttyconf = .no_color }); @@ -2600,10 +2599,7 @@ pub fn failWithOwnedErrorMsg(sema: *Sema, block: ?*Block, err_msg: *Zcu.ErrorMsg } } - const use_ref_trace = if (zcu.comp.reference_trace) |n| n > 0 else zcu.failed_analysis.count() == 0; - if (use_ref_trace) { - err_msg.reference_trace_root = sema.owner.toOptional(); - } + err_msg.reference_trace_root = sema.owner.toOptional(); const gop = try zcu.failed_analysis.getOrPut(gpa, sema.owner); if (gop.found_existing) { |
