From 54d0ba418375a4665cf1b4ee876d6c750bb9c079 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20M=20Rico?= Date: Wed, 6 Nov 2024 04:15:56 -0500 Subject: [PATCH] std: fix `Random.enumValueWithIndex` of single-variant enum --- lib/std/Random.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/std/Random.zig b/lib/std/Random.zig index 3de754c6de..74df589a67 100644 --- a/lib/std/Random.zig +++ b/lib/std/Random.zig @@ -86,7 +86,7 @@ pub fn enumValueWithIndex(r: Random, comptime EnumType: type, comptime Index: ty const values = comptime std.enums.values(EnumType); comptime assert(values.len > 0); // can't return anything comptime assert(maxInt(Index) >= values.len - 1); // can't access all values - comptime if (values.len == 1) return values[0]; + if (values.len == 1) return values[0]; const index = if (comptime values.len - 1 == maxInt(Index)) r.int(Index)