| 1 | const std = @import("std"); |
| 2 | |
| 3 | const FileOpenError = error{ |
| 4 | AccessDenied, |
| 5 | OutOfMemory, |
| 6 | FileNotFound, |
| 7 | }; |
| 8 | |
| 9 | const AllocationError = error{ |
| 10 | OutOfMemory, |
| 11 | }; |
| 12 | |
| 13 | test "coerce subset to superset" { |
| 14 | const err = foo(AllocationError.OutOfMemory); |
| 15 | try std.testing.expectEqual(FileOpenError.OutOfMemory, err); |
| 16 | } |
| 17 | |
| 18 | fn foo(err: AllocationError) FileOpenError { |
| 19 | return err; |
| 20 | } |
| 21 | |
| 22 | // test |