Skip to content

Async recursion with comptime arguments causes compiler assertion failure #4096

@fengb

Description

@fengb

I'm not sure how to explain it but here's a minimal repro:

pub fn format(comptime fmt: []const u8, args: var) void {
    suspend; // commenting this out works
    inline for (fmt) |c| {
        switch (c) {
            'c' => formatType(args[0], "c"),
            else => formatType(args[0], ""),
        }
    }
}

pub fn formatType(value: var, comptime fmt: []const u8) void {
    if (fmt.len > 0 and fmt[0] == 'c') {
        // return formatType(value, ""); // replacing the bottom line with this works
        return format("}", .{value});
    }
}

test "kablamo" {
    // const value = 'a'; // replacing the bottom line with this works
    const value: u8 = 'a';
    _ = async format("c", .{value});
}
Assertion failed at ~/projects/zig/src/analyze.cpp:9037 in resolve_llvm_types. This is a bug in the Zig compiler.
Unable to dump stack trace: debug info stripped
Aborted

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorstage1The process of building from source via WebAssembly and the C backend.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions