Skip to content

unions with fields of function body type cause compiler crash with self-hosted backends #25180

@silversquirl

Description

@silversquirl

Zig Version

0.16.0-dev.195+ac42eaaad

Steps to Reproduce and Observed Behavior

cat <<EOF >test.zig
export fn foo() void {
    const U = union { f: fn () void };
    var x: U = undefined;
    _ = &x;
}
EOF
zig build-obj test.zig -fno-llvm
#> Segmentation fault (core dumped)

Expected Behavior

The following compile error: test.zig:3:12: error: variable of type 'test.foo.U' must be const or comptime

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorfrontendTokenization, parsing, AstGen, Sema, and Liveness.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions