Skip to content

AstGen yet another switch result loc bug #11812

@Vexu

Description

@Vexu
test {
    const S = struct {
        fn foo() !u8 {
            return error.Foo;
        }
    };
    const value = S.foo() catch |err| switch (err) {
        error.Foo => 255,
    };
    try expect(value == 255);
}
a.zig:14:39: error: value with comptime only type 'comptime_int' depends on runtime control flow
    const value = S.foo() catch |err| switch (err) {
                                      ^
a.zig:14:47: note: runtime control flow here
    const value = S.foo() catch |err| switch (err) {
                                              ^

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

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions