Skip to content

Commit

Permalink
allow noreturn in Pool.zig
Browse files Browse the repository at this point in the history
  • Loading branch information
ippsav committed Nov 11, 2024
1 parent cd204ed commit 5385460
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions lib/std/Thread/Pool.zig
Original file line number Diff line number Diff line change
Expand Up @@ -323,23 +323,26 @@ pub fn getIdCount(pool: *Pool) usize {
}

inline fn callFn(comptime f: anytype, args: anytype) void {
const bad_fn_ret = "expected return type of runFn to be 'void', or '!void'";
const bad_fn_ret = "expected return type of runFn to be 'void', '!void', noreturn, or !noreturn";

switch (@typeInfo(@typeInfo(@TypeOf(f)).@"fn".return_type.?)) {
.void => {
.void, .noreturn => {
@call(.auto, f, args);
},
.error_union => |info| {
if (info.payload != void) {
@compileError(bad_fn_ret);
switch (info.payload) {
void, noreturn => {
@call(.auto, f, args) catch |err| {
std.debug.print("error: {s}\n", .{@errorName(err)});
if (@errorReturnTrace()) |trace| {
std.debug.dumpStackTrace(trace.*);
}
};
},
else => {
@compileError(bad_fn_ret);
},
}

@call(.auto, f, args) catch |err| {
std.debug.print("error: {s}\n", .{@errorName(err)});
if (@errorReturnTrace()) |trace| {
std.debug.dumpStackTrace(trace.*);
}
};
},
else => {
@compileError(bad_fn_ret);
Expand Down

0 comments on commit 5385460

Please sign in to comment.