aboutsummaryrefslogtreecommitdiff
path: root/test/cases/safety/optional_empty_error_set.zig
blob: 60e6c5c3eb490955d9d18f198d7b0759bb76ed06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const std = @import("std");

pub fn panic(message: []const u8, stack_trace: ?*std.builtin.StackTrace, ra: ?usize) noreturn {
    _ = stack_trace;
    _ = ra;
    if (std.mem.eql(u8, message, "attempt to use null value")) {
        std.process.exit(0);
    }
    std.process.exit(1);
}

pub fn main() !void {
    foo() catch |err| switch (err) {};
    return error.TestFailed;
}
var x: ?error{} = null;
fn foo() !void {
    return x.?;
}
// run
// backend=selfhosted,llvm
// target=x86_64-linux,aarch64-linux