zig/test/cases/merge_error_sets.zig
Jimmi Holst Christensen 378d3e4403
Solve the return type ambiguity (#1628)
Changed container and initializer syntax
* <container> { ... } -> <container> . { ... }
* <exrp> { ... } -> <expr> . { ...}
2018-10-15 09:51:15 -04:00

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