aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/invalid_error_capture_discard.zig
blob: e86fa0a73aaf82c5c194c5c21318d58e5ff61517 (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
export fn a() void {
    errdefer |_| {
        @"_";
    }
}
export fn b() void {
    const x: error{}!void = {};
    x catch |_| {
        @"_";
    };
}
export fn c() void {
    const x: error{}!void = {};
    x catch |_| switch (_) {};
}
export fn d() void {
    const x: error{}!u32 = 0;
    if (x) |v| v else |_| switch (_) {}
}

// error
// backend=stage2
// target=native
//
// :2:15: error: discard of error capture; omit it instead
// :3:9: error: use of undeclared identifier '_'
// :8:14: error: discard of error capture; omit it instead
// :9:9: error: use of undeclared identifier '_'
// :14:14: error: discard of error capture; omit it instead
// :18:24: error: discard of error capture; omit it instead