| 1 | const builtin = @import("builtin"); |
| 2 | const A = error{ |
| 3 | FileNotFound, |
| 4 | NotDir, |
| 5 | }; |
| 6 | const B = error{OutOfMemory}; |
| 7 | |
| 8 | const C = A || B; |
| 9 | |
| 10 | fn foo() C!void { |
| 11 | return error.NotDir; |
| 12 | } |
| 13 | |
| 14 | test "merge error sets" { |
| 15 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 16 | |
| 17 | if (foo()) { |
| 18 | @panic("unexpected"); |
| 19 | } else |err| switch (err) { |
| 20 | error.OutOfMemory => @panic("unexpected"), |
| 21 | error.FileNotFound => @panic("unexpected"), |
| 22 | error.NotDir => {}, |
| 23 | } |
| 24 | } |