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);
    }

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