ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
34.79k stars 2.54k forks source link

Assertion failed in get_struct_type when return type of frame struct member is error union #8654

Open Hadron67 opened 3 years ago

Hadron67 commented 3 years ago

The following top-level scope code

frame: @Frame(hkm),
fn hkm(_: void) !void {}

crashes the compiler with

Assertion failed at /home/vsts/work/1/s/src/stage1/analyze.cpp:2261 in get_struct_type. This is a bug in the Zig compiler.thread 29889 panic: 
Unable to dump stack trace: debug info stripped

This also occurs if a sub-frame returns error union. Frame functions taken from a submodule is also affected.

const H = struct {
    pub fn soor() void {
        const h: @Frame(rfnj) = undefined;
    }
    fn rfnj(_: void) !void {}
};

frame: @Frame(H.soor),

But if the frame is not a top-level member, the error doesn't occur:

const Hkm = struct {
    frame: @Frame(hkm),
    fn hkm(_: void) !void {}
};
comptime {
    _ = Hkm;
}

It's also fixed by removing all arguments of the frame function, or changing the return type to something other than an error union.

Using zig-linux-x86_64-0.8.0-dev.2064+da9da76e3.

RetroDev256 commented 1 month ago

Reproducing this bug requires async so it can't currently be tested on master (as of 0.14.0-dev.1510+fb0028a0d)