| author | |
| committer | |
| log | 028ec0f2c3574fb465ffe18f3022a7fa16f25ef6 |
| tree | e410d1049af147ca64a15026703d3bb53900e736 |
| parent | aa9902b586ae5dacda9c10f4139cfceac00dcf22 |
closes #8202 files changed, 6 insertions(+), 1 deletions(-)
src/analyze.cpp+1-1| ... | @@ -2393,7 +2393,7 @@ static void resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type) { | ... | @@ -2393,7 +2393,7 @@ static void resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type) { |
| 2393 | } | 2393 | } |
| 2394 | 2394 | ||
| 2395 | enum_type->data.enumeration.zero_bits_loop_flag = false; | 2395 | enum_type->data.enumeration.zero_bits_loop_flag = false; |
| 2396 | enum_type->zero_bits = (field_count < 2); | 2396 | enum_type->zero_bits = !type_has_bits(tag_int_type); |
| 2397 | enum_type->data.enumeration.zero_bits_known = true; | 2397 | enum_type->data.enumeration.zero_bits_known = true; |
| 2398 | } | 2398 | } |
| 2399 | 2399 |
test/cases/enum.zig+5| ... | @@ -387,3 +387,8 @@ const EnumWithTagValues = enum(u4) { | ... | @@ -387,3 +387,8 @@ const EnumWithTagValues = enum(u4) { |
| 387 | test "enum with tag values don't require parens" { | 387 | test "enum with tag values don't require parens" { |
| 388 | assert(u4(EnumWithTagValues.C) == 0b0100); | 388 | assert(u4(EnumWithTagValues.C) == 0b0100); |
| 389 | } | 389 | } |
| 390 | |||
| 391 | test "enum with 1 field but explicit tag type should still have the tag type" { | ||
| 392 | const Enum = enum(u8) { B = 2 }; | ||
| 393 | comptime @import("std").debug.assert(@sizeOf(Enum) == @sizeOf(u8)); | ||
| 394 | } |