| author | |
| committer | |
| log | 3267eb3a28f6c747772a40beedac14f5feae814f |
| tree | 7efb8be32c6a30a214087faca4c6c1012bbeff95 |
| parent | b77679039fd40aa1693781f99ac89f2dc705e5c2 |
2 files changed, 10 insertions(+), 1 deletions(-)
src/InternPool.zig+5-1| ... | @@ -448,7 +448,11 @@ pub const Key = union(enum) { | ... | @@ -448,7 +448,11 @@ pub const Key = union(enum) { |
| 448 | if (x >= self.names.len) return null; | 448 | if (x >= self.names.len) return null; |
| 449 | return @intCast(u32, x); | 449 | return @intCast(u32, x); |
| 450 | }, | 450 | }, |
| 451 | .i64, .big_int => return null, // out of range | 451 | .i64 => |x| { |
| 452 | if (x >= self.names.len or x < 0) return null; | ||
| 453 | return @intCast(u32, x); | ||
| 454 | }, | ||
| 455 | .big_int => return null, // out of range | ||
| 452 | .lazy_align, .lazy_size => unreachable, | 456 | .lazy_align, .lazy_size => unreachable, |
| 453 | } | 457 | } |
| 454 | } | 458 | } |
test/behavior/enum.zig+5| ... | @@ -812,6 +812,11 @@ test "signed integer as enum tag" { | ... | @@ -812,6 +812,11 @@ test "signed integer as enum tag" { |
| 812 | try expect(@intFromEnum(SignedEnum.A2) == 1); | 812 | try expect(@intFromEnum(SignedEnum.A2) == 1); |
| 813 | } | 813 | } |
| 814 | 814 | ||
| 815 | test "int to enum with signed tag type" { | ||
| 816 | const E = enum(i32) { a, b, c }; | ||
| 817 | try expect(@intToEnum(E, 0) == .a); | ||
| 818 | } | ||
| 819 | |||
| 815 | test "enum with one member and custom tag type" { | 820 | test "enum with one member and custom tag type" { |
| 816 | const E = enum(u2) { | 821 | const E = enum(u2) { |
| 817 | One, | 822 | One, |