#zig build-obj {
--name test -fno-emit-bin
-Mroot=test.zig
#}

#write test.zig {
const E = enum { a, b };
export fn entry1() void {
    switch (E.a) {
        .a => {},
    }
}
export fn entry2() void {
    switch (E.a) {
        .a, .b => {},
        else => {},
    }
}

const T = union(E) { a: u32, b };
export fn entry3() void {
    switch (T{ .a = 0 }) {
        .a => {},
    }
}
export fn entry4() void {
    switch (T{ .a = 0 }) {
        .a, .b => {},
        else => {},
    }
}

const Error = error{ MyError, MyOtherError };
export fn entry5() void {
    switch (Error.MyError) {
        error.MyError => {},
    }
}
export fn entry6() void {
    switch (Error.MyError) {
        error.MyError, error.MyOtherError => {},
        else => {},
    }
}

const U = packed union { a: u1, b: i1 };
export fn entry7() void {
    switch (U{ .a = 0 }) {
        .{ .a = 0 } => {},
    }
}
export fn entry8() void {
    switch (U{ .a = 0 }) {
        .{ .a = 0 }, .{ .a = 1 } => {},
        else => {},
    }
}

const S = packed struct { a: u1 };
export fn entry9() void {
    switch (S{ .a = 0 }) {
        .{ .a = 0 } => {},
    }
}
export fn entry10() void {
    switch (S{ .a = 0 }) {
        .{ .a = 0 }, .{ .a = 1 } => {},
        else => {},
    }
}

export fn entry11() void {
    switch (@as(u1, 0)) {
        0 => {},
    }
}
export fn entry12() void {
    switch (@as(u1, 0)) {
        0, 1 => {},
        else => {},
    }
}

export fn entry13() void {
    switch (true) {
        true => {},
    }
}
export fn entry14() void {
    switch (true) {
        true, false => {},
        else => {},
    }
}

export fn entry15() void {
    switch ({}) {}
}
export fn entry16() void {
    switch ({}) {
        {} => {},
        else => {},
    }
}

export fn entry17() void {
    switch (123) {
        123 => {},
    }
}

export fn entry18() void {
    switch (.foo) {
        .foo => {},
    }
}

fn bar() void {}
export fn entry19() void {
    switch (bar) {
        bar => {},
    }
}

const baz: *u8 = @ptrFromInt(123);
export fn entry20() void {
    switch (baz) {
        baz => {},
    }
}

export fn entry21() void {
    switch (u32) {
        u32 => {},
    }
}

export fn entry22() void {
    switch (@as(anyerror, error.MyError)) {
        error.MyError => {},
    }
}
#}
#update
#check errors {
test.zig:3:5: error: switch must handle all possibilities
test.zig:1:21: note: unhandled enumeration value: 'b'
test.zig:1:11: note: enum 'test.E' declared here
test.zig:10:14: error: unreachable else prong; all cases already handled
test.zig:16:5: error: switch must handle all possibilities
test.zig:1:21: note: unhandled enumeration value: 'b'
test.zig:1:11: note: enum 'test.E' declared here
test.zig:23:14: error: unreachable else prong; all cases already handled
test.zig:29:5: error: switch must handle all possibilities
test.zig:29:5: note: unhandled error value: 'error.MyOtherError'
test.zig:36:14: error: unreachable else prong; all cases already handled
test.zig:42:5: error: switch must handle all possibilities
test.zig:49:14: error: unreachable else prong; all cases already handled
test.zig:55:5: error: switch must handle all possibilities
test.zig:62:14: error: unreachable else prong; all cases already handled
test.zig:67:5: error: switch must handle all possibilities
test.zig:74:14: error: unreachable else prong; all cases already handled
test.zig:79:5: error: switch must handle all possibilities
test.zig:86:14: error: unreachable else prong; all cases already handled
test.zig:91:5: error: switch must handle all possibilities
test.zig:96:14: error: unreachable else prong; all cases already handled
test.zig:101:5: error: else prong required when switching on type 'comptime_int'
test.zig:107:5: error: else prong required when switching on type '@EnumLiteral()'
test.zig:114:5: error: else prong required when switching on type 'fn () void'
test.zig:121:5: error: else prong required when switching on type '*u8'
test.zig:127:5: error: else prong required when switching on type 'type'
test.zig:133:5: error: else prong required when switching on type 'anyerror'
#}
