mirror of
https://github.com/ziglang/zig.git
synced 2024-12-04 02:48:50 +00:00
4307436b99
And fix test cases to make them pass. This is in preparation for starting to pass behavior tests with self-hosted.
22 lines
390 B
Zig
22 lines
390 B
Zig
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 (foo()) {
|
|
@panic("unexpected");
|
|
} else |err| switch (err) {
|
|
error.OutOfMemory => @panic("unexpected"),
|
|
error.FileNotFound => @panic("unexpected"),
|
|
error.NotDir => {},
|
|
}
|
|
}
|