| ... | ... | @@ -717,6 +717,52 @@ pub fn addCases(ctx: *TestContext) !void { |
| 717 | 717 | ":4:5: note: unhandled enumeration value: 'b'", |
| 718 | 718 | ":1:11: note: enum 'E' declared here", |
| 719 | 719 | }); |
| 720 | |
| 721 | case.addError( |
| 722 | \\const E = enum { a, b, c }; |
| 723 | \\export fn foo() void { |
| 724 | \\ var x: E = .a; |
| 725 | \\ switch (x) { |
| 726 | \\ .a => {}, |
| 727 | \\ .b => {}, |
| 728 | \\ .b => {}, |
| 729 | \\ .c => {}, |
| 730 | \\ } |
| 731 | \\} |
| 732 | , &.{ |
| 733 | ":7:10: error: duplicate switch value", |
| 734 | ":6:10: note: previous value here", |
| 735 | }); |
| 736 | |
| 737 | case.addError( |
| 738 | \\const E = enum { a, b, c }; |
| 739 | \\export fn foo() void { |
| 740 | \\ var x: E = .a; |
| 741 | \\ switch (x) { |
| 742 | \\ .a => {}, |
| 743 | \\ .b => {}, |
| 744 | \\ .c => {}, |
| 745 | \\ else => {}, |
| 746 | \\ } |
| 747 | \\} |
| 748 | , &.{ |
| 749 | ":8:14: error: unreachable else prong; all cases already handled", |
| 750 | }); |
| 751 | |
| 752 | case.addError( |
| 753 | \\const E = enum { a, b, c }; |
| 754 | \\export fn foo() void { |
| 755 | \\ var x: E = .a; |
| 756 | \\ switch (x) { |
| 757 | \\ .a => {}, |
| 758 | \\ .b => {}, |
| 759 | \\ _ => {}, |
| 760 | \\ } |
| 761 | \\} |
| 762 | , &.{ |
| 763 | ":4:5: error: '_' prong only allowed when switching on non-exhaustive enums", |
| 764 | ":7:11: note: '_' prong here", |
| 765 | }); |
| 720 | 766 | } |
| 721 | 767 | |
| 722 | 768 | ctx.c("empty start function", linux_x64, |