| 1 | const E = enum(u8) { |
| 2 | a, |
| 3 | b, |
| 4 | _, |
| 5 | }; |
| 6 | const U = union(E) { |
| 7 | a: i32, |
| 8 | b: u32, |
| 9 | }; |
| 10 | pub export fn entry1() void { |
| 11 | const e: E = .b; |
| 12 | switch (e) { // error: switch not handling the tag `b` |
| 13 | .a, _ => {}, |
| 14 | } |
| 15 | } |
| 16 | pub export fn entry2() void { |
| 17 | const u = U{ .a = 2 }; |
| 18 | switch (u) { // error: `_` prong not allowed when switching on tagged union |
| 19 | .a => {}, |
| 20 | .b, _ => {}, |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | // error |
| 25 | // |
| 26 | // :12:5: error: switch must handle all possibilities |
| 27 | // :3:5: note: unhandled enumeration value: 'b' |
| 28 | // :1:11: note: enum 'tmp.E' declared here |
| 29 | // :18:5: error: '_' prong only allowed when switching on non-exhaustive enums |
| 30 | // :20:13: note: '_' prong here |
| 31 | // :18:5: note: consider using 'else' |