aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/invalid_error_capture_discard.zig
blob: 1669c5d37164da13d36802e173501bac00643375 (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
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
//
// :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