Skip to content

Thread.spawn does not accept !void functions #4756

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
leroycep opened this issue Mar 18, 2020 · 0 comments · Fixed by #4757
Closed

Thread.spawn does not accept !void functions #4756

leroycep opened this issue Mar 18, 2020 · 0 comments · Fixed by #4757
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase. standard library This issue involves writing Zig code for the standard library.
Milestone

Comments

@leroycep
Copy link
Contributor

const std = @import("std");

fn run(_arg: u8) !void {
    const x = try std.testing.allocator.create(u8);
    defer std.testing.allocator.destroy(x);
}

pub fn main() !void {
    const thread_handle = try std.Thread.spawn(@as(u8, 0), run);
    thread_handle.wait();
}

When compiled, results in the following error:

$ zig build-exe thread_test.zig
Semantic Analysis [492/778] /home/leroycep/sources/github.com/ziglang/zig/build/lib/zig/std/thread.zig:212:29: error: expected return type of startFn to be 'u8', 'noreturn', 'void', or '!void'
                    else => @compileError("expected return type of startFn to be 'u8', 'noreturn', 'void', or '!void'"),
                            ^
@daurnimator daurnimator added the standard library This issue involves writing Zig code for the standard library. label Mar 18, 2020
LemonBoy added a commit to LemonBoy/zig that referenced this issue Mar 18, 2020
@andrewrk andrewrk added this to the 0.6.0 milestone Mar 18, 2020
@andrewrk andrewrk added the enhancement Solving this issue will likely involve adding new logic or components to the codebase. label Mar 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase. standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants