ea1b21dbdb
* error.BadFd is not a valid error code. it would always be a bug to get this error code. * merge error.Io with existing error.InputOutput * merge error.PathNotFound with existing error.FileNotFound. Not all OS's support both. * add os.File.openReadC * add error.BadPathName for windows file operations with invalid characters * add os.toPosixPath to help stack allocate a null terminating byte * add some TODOs for other functions to investigate removing the allocator requirement * optimize some implementations to use the alternate functions when a null byte is already available * add a missing error.SkipZigTest * os.selfExePath uses a non-allocating API * os.selfExeDirPath uses a non-allocating API * os.path.real uses a non-allocating API * add os.path.realAlloc and os.path.realC * convert many windows syscalls to use the W versions (See #534)
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 => {},
|
|
}
|
|
}
|