aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/enum.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-10-18 09:58:12 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-10-18 10:18:09 -0700
commit7c7d9e13d77de7b9321623c73b6566a3bcbe367c (patch)
treea909b0c8d1cdc166f48d95db40e2fd20cd76da3c /test/behavior/enum.zig
parentd0a5ad0e4c74d36982dbc823dd80dc62395fe2bd (diff)
downloadzig-7c7d9e13d77de7b9321623c73b6566a3bcbe367c.tar.gz
zig-7c7d9e13d77de7b9321623c73b6566a3bcbe367c.zip
Sema: fix runtime int to enum with one possible value
Diffstat (limited to 'test/behavior/enum.zig')
-rw-r--r--test/behavior/enum.zig8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/behavior/enum.zig b/test/behavior/enum.zig
index 5cb89ffa32..acd8d17302 100644
--- a/test/behavior/enum.zig
+++ b/test/behavior/enum.zig
@@ -1169,3 +1169,11 @@ test "Non-exhaustive enum with nonstandard int size behaves correctly" {
const E = enum(u15) { _ };
try expect(@sizeOf(E) == @sizeOf(u15));
}
+
+test "runtime int to enum with one possible value" {
+ const E = enum { one };
+ var runtime: usize = 0;
+ if (@intToEnum(E, runtime) != .one) {
+ @compileError("test failed");
+ }
+}