Skip to content

std.Io compile error: group.async #25995

Description

@YannickFricke

Zig Version

0.16.0-dev.1399+7b325e08c

Steps to Reproduce and Observed Behavior

/home/yfr/.local/share/mise/installs/zig/master/lib/std/Io.zig:1041:17: error: error union is ignored
                @call(.auto, function, args_casted.*);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/yfr/.local/share/mise/installs/zig/master/lib/std/Io.zig:1041:17: note: consider using 'try', 'catch', or 'if'

The line which the error refers to:

@call(.auto, function, args_casted.*);

Expected Behavior

zig should be able to compile the standard library

Simple fix

When the error union should be given back to the caller then this would be a possible fix:

pub fn async(g: *Group, io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(function))) !void {
        const Args = @TypeOf(args);
        const TypeErased = struct {
            fn start(group: *Group, context: *const anyopaque) void {
                _ = group;
                const args_casted: *const Args = @ptrCast(@alignCast(context));
                try @call(.auto, function, args_casted.*);
            }
        };
        io.vtable.groupAsync(io.userdata, g, @ptrCast(&args), .of(Args), TypeErased.start);
    }

Activity

  1. added
    bugObserved behavior contradicts documented or intended behavior
    on Nov 21, 2025
  2. floatdrop commented on Nov 21, 2025

    @floatdrop

    You need also change fn start signature in std.Io.VTable to return !void, so you actually could use try inside. But that raises question about groupAsync comment, that says:

    This mode does not support results, await, or cancel.

    Yet, groupCancel exists.

  3. YannickFricke commented on Nov 21, 2025

    @YannickFricke
    Author

    I checked on this with @kristoff-it it totally makes sense that std.Io.Group.async/3 should be given a function which does not return an error union (which resolves the compile error).

    Maybe we could improve the error message in this case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions