Error: async has not been implemented in the self-hosted compiler yet

Hello, I’m new around here and I’m working through the Ziglings exercises. I have zig installed through my nix-config on the latest version using the community overlay. The output of zig version:

0.16.0-dev.2040+c475f1fcd
$ zig build -Dn=19
test/tests.zig:51:26: error: no field or member function named 'addRemoveDirTree' in 'Build'
        const cleanup = b.addRemoveDirTree(.{ .src_path = .{ .owner = b, .sub_path = tmp_path } });
                        ~^~~~~~~~~~~~~~~~~
/nix/store/2vqv52nidfy84sp1qzl0sfsg683vki7c-zig-0.16.0-dev.2040+c475f1fcd/lib/std/Build.zig:1:1: note: struct declared here
const Build = @This();
^~~~~
test/tests.zig:51:26: note: method invocation only supports up to one level of implicit pointer dereferencing
test/tests.zig:51:26: note: use '.*' to dereference pointer
referenced by:
    build: build.zig:315:41
    runBuild__anon_31869: /nix/store/2vqv52nidfy84sp1qzl0sfsg683vki7c-zig-0.16.0-dev.2040+c475f1fcd/lib/std/Build.zig:2259:44
    6 reference(s) hidden; use '-freference-trace=8' to see all references

Unfortunately I haven’t been able to get zig build to work for any of the exercises yet, I’ve been using zig run … and manually checking my work.

I was able to get away with it up until exercise 84 where the suspend keyword gets introduced. When running this one, I get:

$ zig run ./exercises/084_async.zig
exercises/084_async.zig:56:5: error: async has not been implemented in the self-hosted compiler yet
    suspend {}
    ^~~~~~~~~~
referenced by:
    main: exercises/084_async.zig:51:12
    callMain [inlined]: /nix/store/2vqv52nidfy84sp1qzl0sfsg683vki7c-zig-0.16.0-dev.2040+c475f1fcd/lib/std/start.zig:675:59
    callMainWithArgs [inlined]: /nix/store/2vqv52nidfy84sp1qzl0sfsg683vki7c-zig-0.16.0-dev.2040+c475f1fcd/lib/std/start.zig:626:20
    posixCallMainAndExit: /nix/store/2vqv52nidfy84sp1qzl0sfsg683vki7c-zig-0.16.0-dev.2040+c475f1fcd/lib/std/start.zig:581:38
    2 reference(s) hidden; use '-freference-trace=6' to see all references

Any ideas for how to get this working on NixOS?

Update: zig build is working now. I updated zig to the latest version but forgot to fetch/rebase Ziglings. Now that I’m on the latest commit, I can use the build command:

$ zig build -Dn=19                 
         _       _ _
     ___(_) __ _| (_)_ __   __ _ ___
    |_  | |/ _' | | | '_ \ / _' / __|
     / /| | (_| | | | | | | (_| \__ \
    /___|_|\__, |_|_|_| |_|\__, |___/
           |___/           |___/

    "Look out! Broken programs below!"

Compiling: 019_functions2.zig
Checking: 019_functions2.zig
PASSED:
Powers of two: 2 4 8 16

and now it looks like exercise 84 may be marked as “Broken” I just couldn’t see it without the build command:

$ zig build -Dn=84
         _       _ _
     ___(_) __ _| (_)_ __   __ _ ___
    |_  | |/ _' | | | '_ \ / _' / __|
     / /| | (_| | | | | | | (_| \__ \
    /___|_|\__, |_|_|_| |_|\__, |___/
           |___/           |___/

    "Look out! Broken programs below!"

Skipping 084_async.zig

Problem solved

You saw a remnant of zig’s previous attempt at async, the keywords remained for a future implementation.

The async and await keywords were removed when the Io interface was chosen.

But the suspend and resume remain, as there is still potential for stack less coroutines to be added, as that is required for async on embedded or other limiting targets.

1 Like