2018-11-13 21:08:37 +08:00
|
|
|
const A = error{
|
2018-08-22 08:28:37 +08:00
|
|
|
FileNotFound,
|
2018-06-13 07:38:59 +08:00
|
|
|
NotDir,
|
|
|
|
};
|
2018-11-13 21:08:37 +08:00
|
|
|
const B = error{OutOfMemory};
|
2018-06-13 07:38:59 +08:00
|
|
|
|
|
|
|
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"),
|
2018-08-22 08:28:37 +08:00
|
|
|
error.FileNotFound => @panic("unexpected"),
|
2018-06-13 07:38:59 +08:00
|
|
|
error.NotDir => {},
|
|
|
|
}
|
|
|
|
}
|