Skip to content

Commit 865b2e2

Browse files
squeek502andrewrk
authored andcommitted
Fix reportRetryableWin32ResourceError
Follow up to #17069. This TODO being left in was a complete oversight. Before, any 'retryable' error would hit: error: thread 2920 panic: access of union field 'success' while field 'failure_retryable' is active Now, it will be reported/handled properly: C:\Users\Ryan\Programming\Zig\zig\test\standalone\windows_resources\res\zig.rc:1:1: error: FileNotFound
1 parent ce919cc commit 865b2e2

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/Compilation.zig

+20-3
Original file line numberDiff line numberDiff line change
@@ -4056,9 +4056,26 @@ fn reportRetryableWin32ResourceError(
40564056
) error{OutOfMemory}!void {
40574057
win32_resource.status = .failure_retryable;
40584058

4059-
// TODO: something
4060-
_ = comp;
4061-
_ = @errorName(err);
4059+
var bundle: ErrorBundle.Wip = undefined;
4060+
try bundle.init(comp.gpa);
4061+
errdefer bundle.deinit();
4062+
try bundle.addRootErrorMessage(.{
4063+
.msg = try bundle.printString("{s}", .{@errorName(err)}),
4064+
.src_loc = try bundle.addSourceLocation(.{
4065+
.src_path = try bundle.addString(win32_resource.src.src_path),
4066+
.line = 0,
4067+
.column = 0,
4068+
.span_start = 0,
4069+
.span_main = 0,
4070+
.span_end = 0,
4071+
}),
4072+
});
4073+
const finished_bundle = try bundle.toOwnedBundle("");
4074+
{
4075+
comp.mutex.lock();
4076+
defer comp.mutex.unlock();
4077+
try comp.failed_win32_resources.putNoClobber(comp.gpa, win32_resource, finished_bundle);
4078+
}
40624079
}
40634080

40644081
fn reportRetryableAstGenError(

0 commit comments

Comments
 (0)