Io.Select: do not swallow error.Canceled of task

This commit is contained in:
Brandon Black 2026-01-14 18:15:18 -06:00
parent 46fcf22630
commit 376320a5e9

View file

@ -1269,10 +1269,13 @@ pub fn Select(comptime U: type) type {
args: @TypeOf(args),
fn start(type_erased_context: *const anyopaque) Cancelable!void {
const context: *const @This() = @ptrCast(@alignCast(type_erased_context));
const elem = @unionInit(U, @tagName(field), @call(.auto, function, context.args));
const raw_result = @call(.auto, function, context.args);
const elem = @unionInit(U, @tagName(field), raw_result);
context.select.queue.putOneUncancelable(context.select.io, elem) catch |err| switch (err) {
error.Closed => unreachable,
};
if (@typeInfo(@TypeOf(raw_result)) == .error_union)
raw_result catch |err| if (err == error.Canceled) return error.Canceled;
}
};
const context: Context = .{ .select = s, .args = args };