enums with 1 field and explicit tag type still get the tag type

closes #820
This commit is contained in:
Andrew Kelley 2018-03-08 15:22:42 -05:00
parent aa9902b586
commit 028ec0f2c3
2 changed files with 6 additions and 1 deletions

View File

@ -2393,7 +2393,7 @@ static void resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type) {
}
enum_type->data.enumeration.zero_bits_loop_flag = false;
enum_type->zero_bits = (field_count < 2);
enum_type->zero_bits = !type_has_bits(tag_int_type);
enum_type->data.enumeration.zero_bits_known = true;
}

View File

@ -387,3 +387,8 @@ const EnumWithTagValues = enum(u4) {
test "enum with tag values don't require parens" {
assert(u4(EnumWithTagValues.C) == 0b0100);
}
test "enum with 1 field but explicit tag type should still have the tag type" {
const Enum = enum(u8) { B = 2 };
comptime @import("std").debug.assert(@sizeOf(Enum) == @sizeOf(u8));
}