aboutsummaryrefslogtreecommitdiff
path: root/test/behavior
diff options
context:
space:
mode:
authorkcbanner <kcbanner@gmail.com>2023-06-23 16:35:44 -0400
committerAndrew Kelley <andrew@ziglang.org>2023-06-23 18:28:33 -0700
commit5fc5e4fbe04ccbe5ea37b07c1153a7c5bd2b4346 (patch)
tree1621f97c37307f64f7ef730384a209f8c52fbac5 /test/behavior
parent9d66481e3df35b54275373a685e765a4bcebd712 (diff)
downloadzig-5fc5e4fbe04ccbe5ea37b07c1153a7c5bd2b4346.tar.gz
zig-5fc5e4fbe04ccbe5ea37b07c1153a7c5bd2b4346.zip
sema: Fix overflow when analyzing an inline switch prong range that ends on the maximum value of the switched type
Diffstat (limited to 'test/behavior')
-rw-r--r--test/behavior/switch.zig12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/behavior/switch.zig b/test/behavior/switch.zig
index f9fb9c7659..bcbfc81ed4 100644
--- a/test/behavior/switch.zig
+++ b/test/behavior/switch.zig
@@ -785,3 +785,15 @@ test "switch pointer capture peer type resolution" {
try expectEqual(U{ .a = 111 }, ua);
try expectEqual(U{ .b = 222 }, ub);
}
+
+test "inline switch range that includes the maximum value of the switched type" {
+ if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
+
+ const inputs: [3]u8 = .{ 0, 254, 255 };
+ for (inputs) |input| {
+ switch (input) {
+ inline 254...255 => |val| try expectEqual(input, val),
+ else => |val| try expectEqual(input, val),
+ }
+ }
+}