diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-08-11 13:43:44 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-08-11 13:43:44 -0400 |
| commit | b87686dfa094770e96da33fb23a7d011a168157c (patch) | |
| tree | aad9a7a04a0499d5ebf4782c943ae0f95736b85d | |
| parent | 1b83ee78a48a64bef28f12b7b2e263074f88b6b6 (diff) | |
| download | zig-b87686dfa094770e96da33fb23a7d011a168157c.tar.gz zig-b87686dfa094770e96da33fb23a7d011a168157c.zip | |
fix enum with one member and custom tag type
| -rw-r--r-- | src/ir.cpp | 1 | ||||
| -rw-r--r-- | test/stage1/behavior/enum.zig | 11 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 13348d28c4..fde2b972f8 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -11938,7 +11938,6 @@ static IrInstruction *ir_analyze_enum_to_int(IrAnalyze *ira, IrInstruction *sour if (enum_type->data.enumeration.layout == ContainerLayoutAuto && enum_type->data.enumeration.src_field_count == 1) { - assert(tag_type == ira->codegen->builtin_types.entry_num_lit_int); IrInstruction *result = ir_const(ira, source_instr, tag_type); init_const_bigint(&result->value, tag_type, &enum_type->data.enumeration.fields[0].value); diff --git a/test/stage1/behavior/enum.zig b/test/stage1/behavior/enum.zig index 51f4f0e196..d7d34aec88 100644 --- a/test/stage1/behavior/enum.zig +++ b/test/stage1/behavior/enum.zig @@ -982,3 +982,14 @@ test "enum literal casting to tagged union" { else => @panic("fail"), } } + +test "enum with one member and custom tag type" { + const E = enum(u2) { + One, + }; + expect(@enumToInt(E.One) == 0); + const E2 = enum(u2) { + One = 2, + }; + expect(@enumToInt(E2.One) == 2); +} |
