From adba66435502f0ac7f9cafe610f82960a53997da Mon Sep 17 00:00:00 2001 From: xtex Date: Tue, 8 Sep 2026 21:01:31 +0800 Subject: [PATCH] test: add regression test for #36732 --- test/behavior/switch.zig | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/behavior/switch.zig b/test/behavior/switch.zig index 25eb5159357c06134f6b8e2f3fa5276528b7d4c4..1533d6d5693c7b6e283eab6653d8e018ea0c2d33 100644 --- a/test/behavior/switch.zig +++ b/test/behavior/switch.zig @@ -1568,3 +1568,16 @@ test "union field pointer capture preserves alignment in inline prong" { try comptime U.doTheTest(&.{ .a = 123 }); try comptime U.doTheTest(&.{ .b = 123 }); } + +test "switch on expression" { + var a: []const []const u8 = &.{ "b", "b", "A", "A", "b" }; + _ = &a; + var c: isize = 0; + for (a[1..]) |b| { + switch (b[0] % 2) { + 0 => c += 1, + else => c -= 1, + } + } + try expect(c == 0); +} -- 2.54.0