| ... | ... | @@ -591,6 +591,7 @@ pub const DeclGen = struct { |
| 591 | 591 | }, |
| 592 | 592 | .Union => { |
| 593 | 593 | const union_obj = val.castTag(.@"union").?.data; |
| 594 | const union_ty = ty.cast(Type.Payload.Union).?.data; |
| 594 | 595 | const target = dg.module.getTarget(); |
| 595 | 596 | const layout = ty.unionGetLayout(target); |
| 596 | 597 | |
| ... | ... | @@ -607,11 +608,7 @@ pub const DeclGen = struct { |
| 607 | 608 | try writer.writeAll(".payload = {"); |
| 608 | 609 | } |
| 609 | 610 | |
| 610 | | const index = switch (ty.tag()) { |
| 611 | | .union_tagged => ty.castTag(.union_tagged).?.data.tag_ty.enumTagFieldIndex(union_obj.tag).?, |
| 612 | | .@"union" => ty.castTag(.@"union").?.data.tag_ty.enumTagFieldIndex(union_obj.tag).?, |
| 613 | | else => unreachable, |
| 614 | | }; |
| 611 | const index = union_ty.tag_ty.enumTagFieldIndex(union_obj.tag).?; |
| 615 | 612 | const field_ty = ty.unionFields().values()[index].ty; |
| 616 | 613 | const field_name = ty.unionFields().keys()[index]; |
| 617 | 614 | if (field_ty.hasCodeGenBits()) { |
| ... | ... | @@ -815,11 +812,8 @@ pub const DeclGen = struct { |
| 815 | 812 | } |
| 816 | 813 | |
| 817 | 814 | fn renderUnionTypedef(dg: *DeclGen, t: Type) error{ OutOfMemory, AnalysisFail }![]const u8 { |
| 818 | | const fqn = switch (t.tag()) { |
| 819 | | .@"union" => try t.castTag(.@"union").?.data.getFullyQualifiedName(dg.typedefs.allocator), |
| 820 | | .union_tagged => try t.castTag(.union_tagged).?.data.getFullyQualifiedName(dg.typedefs.allocator), |
| 821 | | else => unreachable, |
| 822 | | }; |
| 815 | const union_ty = t.cast(Type.Payload.Union).?.data; |
| 816 | const fqn = try union_ty.getFullyQualifiedName(dg.typedefs.allocator); |
| 823 | 817 | defer dg.typedefs.allocator.free(fqn); |
| 824 | 818 | |
| 825 | 819 | const target = dg.module.getTarget(); |