| author | |
| committer | |
| log | 3d38feded93cb2ccecf5ecb538c8957a965a891e |
| tree | 280a01fb2c02360887e83b43e4a78c1feca0cac9 |
| parent | 1e03cf1739c9c7407c4b3a56ee5f2705805c6a83 |
| signature |
closes #13223 files changed, 21 insertions(+), 1 deletions(-)
src/codegen.cpp+1-1| ... | ... | @@ -4715,7 +4715,6 @@ static LLVMValueRef ir_render_err_wrap_payload(CodeGen *g, IrExecutable *executa |
| 4715 | 4715 | |
| 4716 | 4716 | static LLVMValueRef ir_render_union_tag(CodeGen *g, IrExecutable *executable, IrInstructionUnionTag *instruction) { |
| 4717 | 4717 | ZigType *union_type = instruction->value->value.type; |
| 4718 | assert(union_type->data.unionation.gen_tag_index != SIZE_MAX); | |
| 4719 | 4718 | |
| 4720 | 4719 | ZigType *tag_type = union_type->data.unionation.tag_type; |
| 4721 | 4720 | if (!type_has_bits(tag_type)) |
| ... | ... | @@ -4725,6 +4724,7 @@ static LLVMValueRef ir_render_union_tag(CodeGen *g, IrExecutable *executable, Ir |
| 4725 | 4724 | if (union_type->data.unionation.gen_field_count == 0) |
| 4726 | 4725 | return union_val; |
| 4727 | 4726 | |
| 4727 | assert(union_type->data.unionation.gen_tag_index != SIZE_MAX); | |
| 4728 | 4728 | LLVMValueRef tag_field_ptr = LLVMBuildStructGEP(g->builder, union_val, |
| 4729 | 4729 | union_type->data.unionation.gen_tag_index, ""); |
| 4730 | 4730 | ZigType *ptr_type = get_pointer_to_type(g, tag_type, false); |
test/behavior.zig+1| ... | ... | @@ -10,6 +10,7 @@ comptime { |
| 10 | 10 | _ = @import("cases/bool.zig"); |
| 11 | 11 | _ = @import("cases/bugs/1111.zig"); |
| 12 | 12 | _ = @import("cases/bugs/1277.zig"); |
| 13 | _ = @import("cases/bugs/1322.zig"); | |
| 13 | 14 | _ = @import("cases/bugs/1381.zig"); |
| 14 | 15 | _ = @import("cases/bugs/1421.zig"); |
| 15 | 16 | _ = @import("cases/bugs/1442.zig"); |
test/cases/bugs/1322.zig created+19| ... | ... | @@ -0,0 +1,19 @@ |
| 1 | const std = @import("std"); | |
| 2 | ||
| 3 | const B = union(enum) { | |
| 4 | c: C, | |
| 5 | None, | |
| 6 | }; | |
| 7 | ||
| 8 | const A = struct { | |
| 9 | b: B, | |
| 10 | }; | |
| 11 | ||
| 12 | const C = struct {}; | |
| 13 | ||
| 14 | test "tagged union with all void fields but a meaningful tag" { | |
| 15 | var a: A = A{ .b = B{ .c = C{} } }; | |
| 16 | std.debug.assert(@TagType(B)(a.b) == @TagType(B).c); | |
| 17 | a = A{ .b = B.None }; | |
| 18 | std.debug.assert(@TagType(B)(a.b) == @TagType(B).None); | |
| 19 | } |