| ... | ... | @@ -580,9 +580,15 @@ pub const Type = extern union { |
| 580 | 580 | return a.tag() == b.tag(); |
| 581 | 581 | }, |
| 582 | 582 | .ErrorUnion => { |
| 583 | | const a_data = a.castTag(.error_union).?.data; |
| 584 | | const b_data = b.castTag(.error_union).?.data; |
| 585 | | return a_data.error_set.eql(b_data.error_set) and a_data.payload.eql(b_data.payload); |
| 583 | const a_set = a.errorUnionSet(); |
| 584 | const b_set = b.errorUnionSet(); |
| 585 | if (!a_set.eql(b_set)) return false; |
| 586 | |
| 587 | const a_payload = a.errorUnionPayload(); |
| 588 | const b_payload = b.errorUnionPayload(); |
| 589 | if (!a_payload.eql(b_payload)) return false; |
| 590 | |
| 591 | return true; |
| 586 | 592 | }, |
| 587 | 593 | .ErrorSet => { |
| 588 | 594 | if (a.tag() == .anyerror and b.tag() == .anyerror) { |
| ... | ... | @@ -890,6 +896,77 @@ pub const Type = extern union { |
| 890 | 896 | return Type{ .ptr_otherwise = &new_payload.base }; |
| 891 | 897 | } |
| 892 | 898 | |
| 899 | pub fn renderFullyQualifiedName(ty: Type, writer: anytype) !void { |
| 900 | const t = ty.tag(); |
| 901 | switch (t) { |
| 902 | .u1, |
| 903 | .u8, |
| 904 | .i8, |
| 905 | .u16, |
| 906 | .i16, |
| 907 | .u32, |
| 908 | .i32, |
| 909 | .u64, |
| 910 | .i64, |
| 911 | .u128, |
| 912 | .i128, |
| 913 | .usize, |
| 914 | .isize, |
| 915 | .c_short, |
| 916 | .c_ushort, |
| 917 | .c_int, |
| 918 | .c_uint, |
| 919 | .c_long, |
| 920 | .c_ulong, |
| 921 | .c_longlong, |
| 922 | .c_ulonglong, |
| 923 | .c_longdouble, |
| 924 | .c_void, |
| 925 | .f16, |
| 926 | .f32, |
| 927 | .f64, |
| 928 | .f128, |
| 929 | .bool, |
| 930 | .void, |
| 931 | .type, |
| 932 | .anyerror, |
| 933 | .@"anyframe", |
| 934 | .comptime_int, |
| 935 | .comptime_float, |
| 936 | .noreturn, |
| 937 | .var_args_param, |
| 938 | .bound_fn, |
| 939 | => return writer.writeAll(@tagName(t)), |
| 940 | |
| 941 | .enum_literal => return writer.writeAll("@Type(.EnumLiteral)"), |
| 942 | .@"null" => return writer.writeAll("@Type(.Null)"), |
| 943 | .@"undefined" => return writer.writeAll("@Type(.Undefined)"), |
| 944 | |
| 945 | .@"struct" => { |
| 946 | const struct_obj = ty.castTag(.@"struct").?.data; |
| 947 | return struct_obj.owner_decl.renderFullyQualifiedName(writer); |
| 948 | }, |
| 949 | .@"union", .union_tagged => { |
| 950 | const union_obj = ty.cast(Payload.Union).?.data; |
| 951 | return union_obj.owner_decl.renderFullyQualifiedName(writer); |
| 952 | }, |
| 953 | .enum_full, .enum_nonexhaustive => { |
| 954 | const enum_full = ty.cast(Payload.EnumFull).?.data; |
| 955 | return enum_full.owner_decl.renderFullyQualifiedName(writer); |
| 956 | }, |
| 957 | .enum_simple => { |
| 958 | const enum_simple = ty.castTag(.enum_simple).?.data; |
| 959 | return enum_simple.owner_decl.renderFullyQualifiedName(writer); |
| 960 | }, |
| 961 | .enum_numbered => { |
| 962 | const enum_numbered = ty.castTag(.enum_numbered).?.data; |
| 963 | return enum_numbered.owner_decl.renderFullyQualifiedName(writer); |
| 964 | }, |
| 965 | .@"opaque" => @panic("TODO"), |
| 966 | else => unreachable, |
| 967 | } |
| 968 | } |
| 969 | |
| 893 | 970 | pub fn format( |
| 894 | 971 | start_type: Type, |
| 895 | 972 | comptime fmt: []const u8, |