zig/test/cases/merge_error_sets.zig
Jimmi Holst Christensen 8139c5a516
New Zig formal grammar (#1685)
Reverted #1628 and changed the grammar+parser of the language to not allow certain expr where types are expected
2018-11-13 05:08:37 -08:00

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 => {},
}
}