const expect = @import("std").testing.expect; const FileOpenError = error { AccessDenied, OutOfMemory, FileNotFound }; const AllocationError = error { OutOfMemory }; fn foo(err: AllocationError) FileOpenError { return err; } test "coerce subset to superset" { const err = foo(AllocationError.OutOfMemory); expect(err == FileOpenError.OutOfMemory); expect(err == AllocationError.OutOfMemory); expect(err == error.OutOfMemory); } fn bar(err: FileOpenError) AllocationError { return err; } test "coerce superset to subset" { bar(FileOpenError.OutOfMemory) catch {}; }