@@ -834,7 +834,8 @@ pub fn resolveFieldAccess(analyser: *Analyser, lhs: Type, field_name: []const u8
834834pub fn resolveFieldAccessBinding (analyser : * Analyser , lhs_binding : Binding , field_name : []const u8 ) ! ? Binding {
835835 const lhs = lhs_binding .type ;
836836
837- if (try analyser .resolveUnionFieldBinding (lhs , field_name )) | b | return b ;
837+ if (try analyser .resolveUnionTagAccess (lhs , field_name )) | t |
838+ return .{ .type = t , .is_const = true };
838839
839840 // If we are accessing a pointer type, remove one pointerness level :)
840841 const left_type = (try analyser .resolveDerefType (lhs )) orelse lhs ;
@@ -995,7 +996,7 @@ pub fn resolveUnwrapErrorUnionType(analyser: *Analyser, ty: Type, side: ErrorUni
995996 };
996997}
997998
998- fn resolveUnionFieldBinding (analyser : * Analyser , ty : Type , symbol : []const u8 ) error {OutOfMemory }! ? Binding {
999+ fn resolveUnionTagAccess (analyser : * Analyser , ty : Type , symbol : []const u8 ) error {OutOfMemory }! ? Type {
9991000 if (! ty .is_type_val )
10001001 return null ;
10011002
@@ -1020,24 +1021,14 @@ fn resolveUnionFieldBinding(analyser: *Analyser, ty: Type, symbol: []const u8) e
10201021 return null ;
10211022
10221023 if (child .decl != .ast_node or ! child .handle .tree .nodeTag (child .decl .ast_node ).isContainerField ())
1023- return .{
1024- .type = try child .resolveType (analyser ) orelse return null ,
1025- .is_const = child .isConst (),
1026- };
1024+ return null ;
10271025
1028- if (container_decl .ast .enum_token != null ) {
1029- return .{
1030- .type = .{ .data = .{ .union_tag = try analyser .allocType (ty ) }, .is_type_val = false },
1031- .is_const = true ,
1032- };
1033- }
1026+ if (container_decl .ast .enum_token != null )
1027+ return .{ .data = .{ .union_tag = try analyser .allocType (ty ) }, .is_type_val = false };
10341028
10351029 if (container_decl .ast .arg .unwrap ()) | arg | {
10361030 const tag_type = (try analyser .resolveTypeOfNode (.of (arg , handle ))) orelse return null ;
1037- return .{
1038- .type = tag_type .instanceTypeVal (analyser ) orelse return null ,
1039- .is_const = true ,
1040- };
1031+ return tag_type .instanceTypeVal (analyser ) orelse return null ;
10411032 }
10421033
10431034 return null ;
@@ -3773,7 +3764,7 @@ pub const Type = struct {
37733764 }
37743765 try writer .print ("!{}" , .{info .payload .fmtTypeVal (analyser , ctx .options )});
37753766 },
3776- .union_tag = > | t | try writer .print ("@typeInfo({}).Union .tag_type.?" , .{t .fmtTypeVal (analyser , ctx .options )}),
3767+ .union_tag = > | t | try writer .print ("@typeInfo({}).@ \" union \" .tag_type.?" , .{t .fmtTypeVal (analyser , ctx .options )}),
37773768 .container = > | info | {
37783769 const scope_handle = info .scope_handle ;
37793770 const handle = scope_handle .handle ;
0 commit comments