| author | |
| committer | |
| log | b87686dfa094770e96da33fb23a7d011a168157c |
| tree | aad9a7a04a0499d5ebf4782c943ae0f95736b85d |
| parent | 1b83ee78a48a64bef28f12b7b2e263074f88b6b6 |
| signature |
2 files changed, 11 insertions(+), 1 deletions(-)
src/ir.cpp-1| ... | ... | @@ -11938,7 +11938,6 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour |
| 11938 | 11938 | if (enum_type->data.enumeration.layout == ContainerLayoutAuto && |
| 11939 | 11939 | enum_type->data.enumeration.src_field_count == 1) |
| 11940 | 11940 | { |
| 11941 | assert(tag_type == ira->codegen->builtin_types.entry_num_lit_int); | |
| 11942 | 11941 | IrInstruction *result = ir_const(ira, source_instr, tag_type); |
| 11943 | 11942 | init_const_bigint(&result->value, tag_type, |
| 11944 | 11943 | &enum_type->data.enumeration.fields[0].value); |
test/stage1/behavior/enum.zig+11| ... | ... | @@ -982,3 +982,14 @@ test "enum literal casting to tagged union" { |
| 982 | 982 | else => @panic("fail"), |
| 983 | 983 | } |
| 984 | 984 | } |
| 985 | ||
| 986 | test "enum with one member and custom tag type" { | |
| 987 | const E = enum(u2) { | |
| 988 | One, | |
| 989 | }; | |
| 990 | expect(@enumToInt(E.One) == 0); | |
| 991 | const E2 = enum(u2) { | |
| 992 | One = 2, | |
| 993 | }; | |
| 994 | expect(@enumToInt(E2.One) == 2); | |
| 995 | } |