zig/test/behavior/merge_error_sets.zig
joachimschmidt557 d6e6162081
stage2 AArch64: unify callee-preserved regs on all targets
also enables many passing behavior tests
2022-12-27 21:17:52 +08:00

26 lines
582 B
Zig

const builtin = @import("builtin");
const A = error{
FileNotFound,
NotDir,
};
const B = error{OutOfMemory};
const C = A || B;
fn foo() C!void {
return error.NotDir;
}
test "merge error sets" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
if (foo()) {
@panic("unexpected");
} else |err| switch (err) {
error.OutOfMemory => @panic("unexpected"),
error.FileNotFound => @panic("unexpected"),
error.NotDir => {},
}
}