Zig / ziglings async => error: async has not been implemented in the self-hosted compiler yet

151 views Asked by At

So I am new to Zig and trying to learn it through Ziglings exercises. I am trying to come across the async exercise, however in each correction of the exercise that I see, I am doing the exact same thing, however, here is what the compiler has to say:

xercises/084_async.zig:51:18: error: async has not been implemented in the self-hosted compiler yet
    _ = async foo();
        ~~~~~~~~~^~
referenced by:
    callMain: /snap/zig/8241/lib/std/start.zig:564:17
    initEventLoopAndCallMain: /snap/zig/8241/lib/std/start.zig:508:34
    remaining reference traces hidden; use '-freference-trace' to see all reference traces

And here is my code, minus the comments:

const print = @import("std").debug.print;

pub fn main() void {
    // Additional Hint: you can assign things to '_' when you
    // don't intend to do anything with them.
    _ = async foo();
}

fn foo() void {
    print("foo() A\n", .{});
    suspend {}
    print("foo() B\n", .{});
}

What is wrong with what I have done ? Thanks.

1

There are 1 answers

0
deftclaw On

AFAICT ziglings meant to be used with a development build of zig , not stable: From the ziglings/exercises repo linked above:

Install a development build of the Zig compiler. (See the "master" section of the downloads page.)
Verify the installation and build number of zig like so:

$ zig version
0.12.0-dev.xxxx+xxxxxxxxx

Note: I'm also new to zig, working through these myself and haven't gotten to async yet, but I could not get exercises to compile correctly on stable. (0.11.0 at time of writing)