aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/enum.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2023-01-05 21:37:30 +0200
committerVeikka Tuominen <git@vexu.eu>2023-01-05 22:03:32 +0200
commitf2faa303a541f5adddbba26d04dc2749991e0075 (patch)
tree5761621aa62e2a36551a33138c4f90a38f3795c0 /test/behavior/enum.zig
parent8c4727f9ab61e4c99ab2a00f5751f9b11d274fbe (diff)
downloadzig-f2faa303a541f5adddbba26d04dc2749991e0075.tar.gz
zig-f2faa303a541f5adddbba26d04dc2749991e0075.zip
Sema: handle enum expressions referencing local variables
Closes #12272
Diffstat (limited to 'test/behavior/enum.zig')
-rw-r--r--test/behavior/enum.zig10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/behavior/enum.zig b/test/behavior/enum.zig
index a398d5ec22..095f3b740b 100644
--- a/test/behavior/enum.zig
+++ b/test/behavior/enum.zig
@@ -1185,3 +1185,13 @@ test "runtime int to enum with one possible value" {
@compileError("test failed");
}
}
+
+test "enum tag from a local variable" {
+ const S = struct {
+ fn Int(comptime Inner: type) type {
+ return enum(Inner) { _ };
+ }
+ };
+ const i = @intToEnum(S.Int(u32), 0);
+ try std.testing.expect(@enumToInt(i) == 0);
+}