mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 09:02:32 +00:00
31 lines
470 B
Zig
31 lines
470 B
Zig
const A = error{
|
|
NotDir,
|
|
|
|
/// A doc comment
|
|
PathNotFound,
|
|
};
|
|
const B = error{
|
|
OutOfMemory,
|
|
|
|
/// B doc comment
|
|
PathNotFound,
|
|
};
|
|
|
|
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.PathNotFound => @panic("unexpected"),
|
|
error.NotDir => {},
|
|
}
|
|
}
|
|
|
|
// test
|