aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/switch_expression-missing_error_prong.zig
blob: 17980607fd084203e619aa58de08a1a6c3e85c9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const Error = error{
    One,
    Two,
    Three,
    Four,
};
fn f(n: Error!i32) i32 {
    if (n) |x| x else |e| switch (e) {
        error.One => 1,
        error.Two => 2,
        error.Three => 3,
    }
}
fn h(n: Error!i32) i32 {
    n catch |e| switch (e) {
        error.One => 1,
        error.Two => 2,
        error.Three => 3,
    };
}

export fn entry() usize {
    return @sizeOf(@TypeOf(&f)) + @sizeOf(@TypeOf(&h));
}

// error
//
// :8:27: error: switch must handle all possibilities
// :8:27: note: unhandled error value: 'error.Four'
// :15:17: error: switch must handle all possibilities
// :15:17: note: unhandled error value: 'error.Four'