Sema: improve behavior of comptime_int backed enums

This commit is contained in:
Veikka Tuominen
2022-09-02 16:08:20 +03:00
parent a9cdacff95
commit f281f3d10e
4 changed files with 23 additions and 4 deletions

View File

@@ -1175,3 +1175,10 @@ test "Non-exhaustive enum with nonstandard int size behaves correctly" {
const E = enum(u15) { _ };
try expect(@sizeOf(E) == @sizeOf(u15));
}
test "Non-exhaustive enum backed by comptime_int" {
const E = enum(comptime_int) { a, b, c, _ };
comptime var e: E = .a;
e = @intToEnum(E, 378089457309184723749);
try expect(@enumToInt(e) == 378089457309184723749);
}