| ... | ... | @@ -797,3 +797,22 @@ test "inline switch range that includes the maximum value of the switched type" |
| 797 | 797 | } |
| 798 | 798 | } |
| 799 | 799 | } |
| 800 | |
| 801 | test "nested break ignores switch conditions and breaks instead" { |
| 802 | const S = struct { |
| 803 | fn register_to_address(ident: []const u8) !u8 { |
| 804 | const reg: u8 = if (std.mem.eql(u8, ident, "zero")) 0x00 else blk: { |
| 805 | break :blk switch (ident[0]) { |
| 806 | 0x61 => (try std.fmt.parseInt(u8, ident[1..], 0)) + 1, |
| 807 | 0x66 => (try std.fmt.parseInt(u8, ident[1..], 0)) + 1, |
| 808 | else => { |
| 809 | break :blk 0xFF; |
| 810 | }, |
| 811 | }; |
| 812 | }; |
| 813 | return reg; |
| 814 | } |
| 815 | }; |
| 816 | // Originally reported at https://github.com/ziglang/zig/issues/10196 |
| 817 | try expect(0x01 == try S.register_to_address("a0")); |
| 818 | } |