| author | |
| committer | |
| log | ffb3b1576b1c02942bce89ef05eaf05fe2f026ac |
| tree | f2dc8e6f831f0bafab2f27d475d2d29e6a557fb1 |
| parent | c87a576cb5afaf54e68bae10119305af71aaa3a1 |
| signature |
closes #14782 files changed, 14 insertions(+), 1 deletions(-)
src/codegen.cpp+1-1| ... | ... | @@ -5490,7 +5490,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const c |
| 5490 | 5490 | LLVMTypeRef union_type_ref = type_entry->data.unionation.union_type_ref; |
| 5491 | 5491 | |
| 5492 | 5492 | if (type_entry->data.unionation.gen_field_count == 0) { |
| 5493 | if (type_entry->data.unionation.gen_tag_index == SIZE_MAX) { | |
| 5493 | if (type_entry->data.unionation.tag_type == nullptr) { | |
| 5494 | 5494 | return nullptr; |
| 5495 | 5495 | } else { |
| 5496 | 5496 | return bigint_to_llvm_const(type_entry->data.unionation.tag_type->type_ref, |
test/cases/union.zig+13| ... | ... | @@ -311,3 +311,16 @@ fn testTaggedUnionInit(x: var) bool { |
| 311 | 311 | const y = TaggedUnionWithAVoid{ .A = x }; |
| 312 | 312 | return @TagType(TaggedUnionWithAVoid)(y) == TaggedUnionWithAVoid.A; |
| 313 | 313 | } |
| 314 | ||
| 315 | pub const UnionEnumNoPayloads = union(enum) { | |
| 316 | A, | |
| 317 | B, | |
| 318 | }; | |
| 319 | ||
| 320 | test "tagged union with no payloads" { | |
| 321 | const a = UnionEnumNoPayloads{ .B = {} }; | |
| 322 | switch (a) { | |
| 323 | @TagType(UnionEnumNoPayloads).A => @panic("wrong"), | |
| 324 | @TagType(UnionEnumNoPayloads).B => {}, | |
| 325 | } | |
| 326 | } |