We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9d3363f commit 407d91fCopy full SHA for 407d91f
test/behavior/switch.zig
@@ -797,3 +797,22 @@ test "inline switch range that includes the maximum value of the switched type"
797
}
798
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
+}
0 commit comments