Skip to content

AstGen doesn't pass type to switch prong #11788

@Vexu

Description

@Vexu
test {
    var a: u32 = 0;
    var b: [2]u32 = undefined;
    b[0] = @as(u32, switch (a) {
        1 => 1,
        else => 0,
    });
}
a.zig:29:21: error: value with comptime only type 'comptime_int' depends on runtime control flow
    b[0] = @as(u32, switch (a) {
                    ^
a.zig:29:29: note: runtime control flow here
    b[0] = @as(u32, switch (a) {
                            ^

Related #11135

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions