aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/switch_expression-missing_error_prong.zig
blob: ee28057c4362bd67b01069e976d511ef2273dfd2 (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
32
33
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
// backend=stage2
// target=native
//
// :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'