| author | |
| committer | |
| log | d0551db5cd29e4c7f361ef40a37486138a4e8b1e |
| tree | 9b591aa521477ec0bb3bd0ef046e50d140e51d67 |
| parent | 64dddd7afe14a683826b03bc36ab80fa93a84e2c |
| signature |
see #68316 files changed, 195 insertions(+), 3 deletions(-)
src-self-hosted/ir.zig+1| ... | @@ -1186,6 +1186,7 @@ pub const Builder = struct { | ... | @@ -1186,6 +1186,7 @@ pub const Builder = struct { |
| 1186 | ast.Node.Id.AsyncAttribute => return error.Unimplemented, | 1186 | ast.Node.Id.AsyncAttribute => return error.Unimplemented, |
| 1187 | ast.Node.Id.ParamDecl => return error.Unimplemented, | 1187 | ast.Node.Id.ParamDecl => return error.Unimplemented, |
| 1188 | ast.Node.Id.FieldInitializer => return error.Unimplemented, | 1188 | ast.Node.Id.FieldInitializer => return error.Unimplemented, |
| 1189 | ast.Node.Id.EnumLiteral => return error.Unimplemented, | ||
| 1189 | } | 1190 | } |
| 1190 | } | 1191 | } |
| 1191 | 1192 |
src-self-hosted/type.zig+18| ... | @@ -32,6 +32,7 @@ pub const Type = struct { | ... | @@ -32,6 +32,7 @@ pub const Type = struct { |
| 32 | Id.Array => @fieldParentPtr(Array, "base", base).destroy(comp), | 32 | Id.Array => @fieldParentPtr(Array, "base", base).destroy(comp), |
| 33 | Id.ComptimeFloat => @fieldParentPtr(ComptimeFloat, "base", base).destroy(comp), | 33 | Id.ComptimeFloat => @fieldParentPtr(ComptimeFloat, "base", base).destroy(comp), |
| 34 | Id.ComptimeInt => @fieldParentPtr(ComptimeInt, "base", base).destroy(comp), | 34 | Id.ComptimeInt => @fieldParentPtr(ComptimeInt, "base", base).destroy(comp), |
| 35 | Id.EnumLiteral => @fieldParentPtr(EnumLiteral, "base", base).destroy(comp), | ||
| 35 | Id.Undefined => @fieldParentPtr(Undefined, "base", base).destroy(comp), | 36 | Id.Undefined => @fieldParentPtr(Undefined, "base", base).destroy(comp), |
| 36 | Id.Null => @fieldParentPtr(Null, "base", base).destroy(comp), | 37 | Id.Null => @fieldParentPtr(Null, "base", base).destroy(comp), |
| 37 | Id.Optional => @fieldParentPtr(Optional, "base", base).destroy(comp), | 38 | Id.Optional => @fieldParentPtr(Optional, "base", base).destroy(comp), |
| ... | @@ -65,6 +66,7 @@ pub const Type = struct { | ... | @@ -65,6 +66,7 @@ pub const Type = struct { |
| 65 | Id.Array => return @fieldParentPtr(Array, "base", base).getLlvmType(allocator, llvm_context), | 66 | Id.Array => return @fieldParentPtr(Array, "base", base).getLlvmType(allocator, llvm_context), |
| 66 | Id.ComptimeFloat => unreachable, | 67 | Id.ComptimeFloat => unreachable, |
| 67 | Id.ComptimeInt => unreachable, | 68 | Id.ComptimeInt => unreachable, |
| 69 | Id.EnumLiteral => unreachable, | ||
| 68 | Id.Undefined => unreachable, | 70 | Id.Undefined => unreachable, |
| 69 | Id.Null => unreachable, | 71 | Id.Null => unreachable, |
| 70 | Id.Optional => return @fieldParentPtr(Optional, "base", base).getLlvmType(allocator, llvm_context), | 72 | Id.Optional => return @fieldParentPtr(Optional, "base", base).getLlvmType(allocator, llvm_context), |
| ... | @@ -85,6 +87,7 @@ pub const Type = struct { | ... | @@ -85,6 +87,7 @@ pub const Type = struct { |
| 85 | Id.Type, | 87 | Id.Type, |
| 86 | Id.ComptimeFloat, | 88 | Id.ComptimeFloat, |
| 87 | Id.ComptimeInt, | 89 | Id.ComptimeInt, |
| 90 | Id.EnumLiteral, | ||
| 88 | Id.Undefined, | 91 | Id.Undefined, |
| 89 | Id.Null, | 92 | Id.Null, |
| 90 | Id.BoundFn, | 93 | Id.BoundFn, |
| ... | @@ -118,6 +121,7 @@ pub const Type = struct { | ... | @@ -118,6 +121,7 @@ pub const Type = struct { |
| 118 | Id.Type, | 121 | Id.Type, |
| 119 | Id.ComptimeFloat, | 122 | Id.ComptimeFloat, |
| 120 | Id.ComptimeInt, | 123 | Id.ComptimeInt, |
| 124 | Id.EnumLiteral, | ||
| 121 | Id.Undefined, | 125 | Id.Undefined, |
| 122 | Id.Null, | 126 | Id.Null, |
| 123 | Id.BoundFn, | 127 | Id.BoundFn, |
| ... | @@ -940,6 +944,20 @@ pub const Type = struct { | ... | @@ -940,6 +944,20 @@ pub const Type = struct { |
| 940 | } | 944 | } |
| 941 | }; | 945 | }; |
| 942 | 946 | ||
| 947 | pub const EnumLiteral = struct { | ||
| 948 | base: Type, | ||
| 949 | |||
| 950 | /// Adds 1 reference to the resulting type | ||
| 951 | pub fn get(comp: *Compilation) *EnumLiteral { | ||
| 952 | comp.comptime_int_type.base.base.ref(); | ||
| 953 | return comp.comptime_int_type; | ||
| 954 | } | ||
| 955 | |||
| 956 | pub fn destroy(self: *EnumLiteral, comp: *Compilation) void { | ||
| 957 | comp.gpa().destroy(self); | ||
| 958 | } | ||
| 959 | }; | ||
| 960 | |||
| 943 | pub const Undefined = struct { | 961 | pub const Undefined = struct { |
| 944 | base: Type, | 962 | base: Type, |
| 945 | 963 |
src/all_types.hpp+10| ... | @@ -317,6 +317,7 @@ struct ConstExprValue { | ... | @@ -317,6 +317,7 @@ struct ConstExprValue { |
| 317 | ConstArrayValue x_array; | 317 | ConstArrayValue x_array; |
| 318 | ConstPtrValue x_ptr; | 318 | ConstPtrValue x_ptr; |
| 319 | ConstArgTuple x_arg_tuple; | 319 | ConstArgTuple x_arg_tuple; |
| 320 | Buf *x_enum_literal; | ||
| 320 | 321 | ||
| 321 | // populated if special == ConstValSpecialRuntime | 322 | // populated if special == ConstValSpecialRuntime |
| 322 | RuntimeHintErrorUnion rh_error_union; | 323 | RuntimeHintErrorUnion rh_error_union; |
| ... | @@ -468,6 +469,7 @@ enum NodeType { | ... | @@ -468,6 +469,7 @@ enum NodeType { |
| 468 | NodeTypeAwaitExpr, | 469 | NodeTypeAwaitExpr, |
| 469 | NodeTypeSuspend, | 470 | NodeTypeSuspend, |
| 470 | NodeTypePromiseType, | 471 | NodeTypePromiseType, |
| 472 | NodeTypeEnumLiteral, | ||
| 471 | }; | 473 | }; |
| 472 | 474 | ||
| 473 | enum CallingConvention { | 475 | enum CallingConvention { |
| ... | @@ -929,6 +931,11 @@ struct AstNodePromiseType { | ... | @@ -929,6 +931,11 @@ struct AstNodePromiseType { |
| 929 | AstNode *payload_type; // can be NULL | 931 | AstNode *payload_type; // can be NULL |
| 930 | }; | 932 | }; |
| 931 | 933 | ||
| 934 | struct AstNodeEnumLiteral { | ||
| 935 | Token *period; | ||
| 936 | Token *identifier; | ||
| 937 | }; | ||
| 938 | |||
| 932 | struct AstNode { | 939 | struct AstNode { |
| 933 | enum NodeType type; | 940 | enum NodeType type; |
| 934 | size_t line; | 941 | size_t line; |
| ... | @@ -989,6 +996,7 @@ struct AstNode { | ... | @@ -989,6 +996,7 @@ struct AstNode { |
| 989 | AstNodeAwaitExpr await_expr; | 996 | AstNodeAwaitExpr await_expr; |
| 990 | AstNodeSuspend suspend; | 997 | AstNodeSuspend suspend; |
| 991 | AstNodePromiseType promise_type; | 998 | AstNodePromiseType promise_type; |
| 999 | AstNodeEnumLiteral enum_literal; | ||
| 992 | } data; | 1000 | } data; |
| 993 | }; | 1001 | }; |
| 994 | 1002 | ||
| ... | @@ -1252,6 +1260,7 @@ enum ZigTypeId { | ... | @@ -1252,6 +1260,7 @@ enum ZigTypeId { |
| 1252 | ZigTypeIdOpaque, | 1260 | ZigTypeIdOpaque, |
| 1253 | ZigTypeIdPromise, | 1261 | ZigTypeIdPromise, |
| 1254 | ZigTypeIdVector, | 1262 | ZigTypeIdVector, |
| 1263 | ZigTypeIdEnumLiteral, | ||
| 1255 | }; | 1264 | }; |
| 1256 | 1265 | ||
| 1257 | enum OnePossibleValue { | 1266 | enum OnePossibleValue { |
| ... | @@ -1741,6 +1750,7 @@ struct CodeGen { | ... | @@ -1741,6 +1750,7 @@ struct CodeGen { |
| 1741 | ZigType *entry_global_error_set; | 1750 | ZigType *entry_global_error_set; |
| 1742 | ZigType *entry_arg_tuple; | 1751 | ZigType *entry_arg_tuple; |
| 1743 | ZigType *entry_promise; | 1752 | ZigType *entry_promise; |
| 1753 | ZigType *entry_enum_literal; | ||
| 1744 | } builtin_types; | 1754 | } builtin_types; |
| 1745 | ZigType *align_amt_type; | 1755 | ZigType *align_amt_type; |
| 1746 | ZigType *stack_trace_type; | 1756 | ZigType *stack_trace_type; |
src/analyze.cpp+31-1| ... | @@ -242,6 +242,7 @@ AstNode *type_decl_node(ZigType *type_entry) { | ... | @@ -242,6 +242,7 @@ AstNode *type_decl_node(ZigType *type_entry) { |
| 242 | case ZigTypeIdArray: | 242 | case ZigTypeIdArray: |
| 243 | case ZigTypeIdComptimeFloat: | 243 | case ZigTypeIdComptimeFloat: |
| 244 | case ZigTypeIdComptimeInt: | 244 | case ZigTypeIdComptimeInt: |
| 245 | case ZigTypeIdEnumLiteral: | ||
| 245 | case ZigTypeIdUndefined: | 246 | case ZigTypeIdUndefined: |
| 246 | case ZigTypeIdNull: | 247 | case ZigTypeIdNull: |
| 247 | case ZigTypeIdOptional: | 248 | case ZigTypeIdOptional: |
| ... | @@ -303,6 +304,7 @@ bool type_is_resolved(ZigType *type_entry, ResolveStatus status) { | ... | @@ -303,6 +304,7 @@ bool type_is_resolved(ZigType *type_entry, ResolveStatus status) { |
| 303 | case ZigTypeIdArray: | 304 | case ZigTypeIdArray: |
| 304 | case ZigTypeIdComptimeFloat: | 305 | case ZigTypeIdComptimeFloat: |
| 305 | case ZigTypeIdComptimeInt: | 306 | case ZigTypeIdComptimeInt: |
| 307 | case ZigTypeIdEnumLiteral: | ||
| 306 | case ZigTypeIdUndefined: | 308 | case ZigTypeIdUndefined: |
| 307 | case ZigTypeIdNull: | 309 | case ZigTypeIdNull: |
| 308 | case ZigTypeIdOptional: | 310 | case ZigTypeIdOptional: |
| ... | @@ -1463,6 +1465,7 @@ static Error emit_error_unless_type_allowed_in_packed_struct(CodeGen *g, ZigType | ... | @@ -1463,6 +1465,7 @@ static Error emit_error_unless_type_allowed_in_packed_struct(CodeGen *g, ZigType |
| 1463 | case ZigTypeIdUnreachable: | 1465 | case ZigTypeIdUnreachable: |
| 1464 | case ZigTypeIdComptimeFloat: | 1466 | case ZigTypeIdComptimeFloat: |
| 1465 | case ZigTypeIdComptimeInt: | 1467 | case ZigTypeIdComptimeInt: |
| 1468 | case ZigTypeIdEnumLiteral: | ||
| 1466 | case ZigTypeIdUndefined: | 1469 | case ZigTypeIdUndefined: |
| 1467 | case ZigTypeIdNull: | 1470 | case ZigTypeIdNull: |
| 1468 | case ZigTypeIdErrorUnion: | 1471 | case ZigTypeIdErrorUnion: |
| ... | @@ -1550,6 +1553,7 @@ bool type_allowed_in_extern(CodeGen *g, ZigType *type_entry) { | ... | @@ -1550,6 +1553,7 @@ bool type_allowed_in_extern(CodeGen *g, ZigType *type_entry) { |
| 1550 | case ZigTypeIdMetaType: | 1553 | case ZigTypeIdMetaType: |
| 1551 | case ZigTypeIdComptimeFloat: | 1554 | case ZigTypeIdComptimeFloat: |
| 1552 | case ZigTypeIdComptimeInt: | 1555 | case ZigTypeIdComptimeInt: |
| 1556 | case ZigTypeIdEnumLiteral: | ||
| 1553 | case ZigTypeIdUndefined: | 1557 | case ZigTypeIdUndefined: |
| 1554 | case ZigTypeIdNull: | 1558 | case ZigTypeIdNull: |
| 1555 | case ZigTypeIdErrorUnion: | 1559 | case ZigTypeIdErrorUnion: |
| ... | @@ -1712,6 +1716,7 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc | ... | @@ -1712,6 +1716,7 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc |
| 1712 | return g->builtin_types.entry_invalid; | 1716 | return g->builtin_types.entry_invalid; |
| 1713 | case ZigTypeIdComptimeFloat: | 1717 | case ZigTypeIdComptimeFloat: |
| 1714 | case ZigTypeIdComptimeInt: | 1718 | case ZigTypeIdComptimeInt: |
| 1719 | case ZigTypeIdEnumLiteral: | ||
| 1715 | case ZigTypeIdBoundFn: | 1720 | case ZigTypeIdBoundFn: |
| 1716 | case ZigTypeIdMetaType: | 1721 | case ZigTypeIdMetaType: |
| 1717 | case ZigTypeIdVoid: | 1722 | case ZigTypeIdVoid: |
| ... | @@ -1806,6 +1811,7 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc | ... | @@ -1806,6 +1811,7 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc |
| 1806 | 1811 | ||
| 1807 | case ZigTypeIdComptimeFloat: | 1812 | case ZigTypeIdComptimeFloat: |
| 1808 | case ZigTypeIdComptimeInt: | 1813 | case ZigTypeIdComptimeInt: |
| 1814 | case ZigTypeIdEnumLiteral: | ||
| 1809 | case ZigTypeIdBoundFn: | 1815 | case ZigTypeIdBoundFn: |
| 1810 | case ZigTypeIdMetaType: | 1816 | case ZigTypeIdMetaType: |
| 1811 | case ZigTypeIdUnreachable: | 1817 | case ZigTypeIdUnreachable: |
| ... | @@ -3621,6 +3627,7 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) { | ... | @@ -3621,6 +3627,7 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) { |
| 3621 | case NodeTypeAwaitExpr: | 3627 | case NodeTypeAwaitExpr: |
| 3622 | case NodeTypeSuspend: | 3628 | case NodeTypeSuspend: |
| 3623 | case NodeTypePromiseType: | 3629 | case NodeTypePromiseType: |
| 3630 | case NodeTypeEnumLiteral: | ||
| 3624 | zig_unreachable(); | 3631 | zig_unreachable(); |
| 3625 | } | 3632 | } |
| 3626 | } | 3633 | } |
| ... | @@ -3658,6 +3665,7 @@ ZigType *validate_var_type(CodeGen *g, AstNode *source_node, ZigType *type_entry | ... | @@ -3658,6 +3665,7 @@ ZigType *validate_var_type(CodeGen *g, AstNode *source_node, ZigType *type_entry |
| 3658 | return g->builtin_types.entry_invalid; | 3665 | return g->builtin_types.entry_invalid; |
| 3659 | case ZigTypeIdComptimeFloat: | 3666 | case ZigTypeIdComptimeFloat: |
| 3660 | case ZigTypeIdComptimeInt: | 3667 | case ZigTypeIdComptimeInt: |
| 3668 | case ZigTypeIdEnumLiteral: | ||
| 3661 | case ZigTypeIdMetaType: | 3669 | case ZigTypeIdMetaType: |
| 3662 | case ZigTypeIdVoid: | 3670 | case ZigTypeIdVoid: |
| 3663 | case ZigTypeIdBool: | 3671 | case ZigTypeIdBool: |
| ... | @@ -3807,7 +3815,8 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var) { | ... | @@ -3807,7 +3815,8 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var) { |
| 3807 | implicit_type = g->builtin_types.entry_invalid; | 3815 | implicit_type = g->builtin_types.entry_invalid; |
| 3808 | } else if ((!is_const || linkage == VarLinkageExternal) && | 3816 | } else if ((!is_const || linkage == VarLinkageExternal) && |
| 3809 | (implicit_type->id == ZigTypeIdComptimeFloat || | 3817 | (implicit_type->id == ZigTypeIdComptimeFloat || |
| 3810 | implicit_type->id == ZigTypeIdComptimeInt)) | 3818 | implicit_type->id == ZigTypeIdComptimeInt || |
| 3819 | implicit_type->id == ZigTypeIdEnumLiteral)) | ||
| 3811 | { | 3820 | { |
| 3812 | add_node_error(g, source_node, buf_sprintf("unable to infer variable type")); | 3821 | add_node_error(g, source_node, buf_sprintf("unable to infer variable type")); |
| 3813 | implicit_type = g->builtin_types.entry_invalid; | 3822 | implicit_type = g->builtin_types.entry_invalid; |
| ... | @@ -4051,6 +4060,7 @@ static bool is_container(ZigType *type_entry) { | ... | @@ -4051,6 +4060,7 @@ static bool is_container(ZigType *type_entry) { |
| 4051 | case ZigTypeIdArray: | 4060 | case ZigTypeIdArray: |
| 4052 | case ZigTypeIdComptimeFloat: | 4061 | case ZigTypeIdComptimeFloat: |
| 4053 | case ZigTypeIdComptimeInt: | 4062 | case ZigTypeIdComptimeInt: |
| 4063 | case ZigTypeIdEnumLiteral: | ||
| 4054 | case ZigTypeIdUndefined: | 4064 | case ZigTypeIdUndefined: |
| 4055 | case ZigTypeIdNull: | 4065 | case ZigTypeIdNull: |
| 4056 | case ZigTypeIdOptional: | 4066 | case ZigTypeIdOptional: |
| ... | @@ -4109,6 +4119,7 @@ void resolve_container_type(CodeGen *g, ZigType *type_entry) { | ... | @@ -4109,6 +4119,7 @@ void resolve_container_type(CodeGen *g, ZigType *type_entry) { |
| 4109 | case ZigTypeIdArray: | 4119 | case ZigTypeIdArray: |
| 4110 | case ZigTypeIdComptimeFloat: | 4120 | case ZigTypeIdComptimeFloat: |
| 4111 | case ZigTypeIdComptimeInt: | 4121 | case ZigTypeIdComptimeInt: |
| 4122 | case ZigTypeIdEnumLiteral: | ||
| 4112 | case ZigTypeIdUndefined: | 4123 | case ZigTypeIdUndefined: |
| 4113 | case ZigTypeIdNull: | 4124 | case ZigTypeIdNull: |
| 4114 | case ZigTypeIdOptional: | 4125 | case ZigTypeIdOptional: |
| ... | @@ -4647,6 +4658,7 @@ bool handle_is_ptr(ZigType *type_entry) { | ... | @@ -4647,6 +4658,7 @@ bool handle_is_ptr(ZigType *type_entry) { |
| 4647 | case ZigTypeIdMetaType: | 4658 | case ZigTypeIdMetaType: |
| 4648 | case ZigTypeIdComptimeFloat: | 4659 | case ZigTypeIdComptimeFloat: |
| 4649 | case ZigTypeIdComptimeInt: | 4660 | case ZigTypeIdComptimeInt: |
| 4661 | case ZigTypeIdEnumLiteral: | ||
| 4650 | case ZigTypeIdUndefined: | 4662 | case ZigTypeIdUndefined: |
| 4651 | case ZigTypeIdNull: | 4663 | case ZigTypeIdNull: |
| 4652 | case ZigTypeIdBoundFn: | 4664 | case ZigTypeIdBoundFn: |
| ... | @@ -4827,6 +4839,8 @@ static uint32_t hash_const_val(ConstExprValue *const_val) { | ... | @@ -4827,6 +4839,8 @@ static uint32_t hash_const_val(ConstExprValue *const_val) { |
| 4827 | } | 4839 | } |
| 4828 | return result; | 4840 | return result; |
| 4829 | } | 4841 | } |
| 4842 | case ZigTypeIdEnumLiteral: | ||
| 4843 | return buf_hash(const_val->data.x_enum_literal) * 2691276464; | ||
| 4830 | case ZigTypeIdEnum: | 4844 | case ZigTypeIdEnum: |
| 4831 | { | 4845 | { |
| 4832 | uint32_t result = 31643936; | 4846 | uint32_t result = 31643936; |
| ... | @@ -4974,6 +4988,7 @@ static bool can_mutate_comptime_var_state(ConstExprValue *value) { | ... | @@ -4974,6 +4988,7 @@ static bool can_mutate_comptime_var_state(ConstExprValue *value) { |
| 4974 | case ZigTypeIdFloat: | 4988 | case ZigTypeIdFloat: |
| 4975 | case ZigTypeIdComptimeFloat: | 4989 | case ZigTypeIdComptimeFloat: |
| 4976 | case ZigTypeIdComptimeInt: | 4990 | case ZigTypeIdComptimeInt: |
| 4991 | case ZigTypeIdEnumLiteral: | ||
| 4977 | case ZigTypeIdUndefined: | 4992 | case ZigTypeIdUndefined: |
| 4978 | case ZigTypeIdNull: | 4993 | case ZigTypeIdNull: |
| 4979 | case ZigTypeIdBoundFn: | 4994 | case ZigTypeIdBoundFn: |
| ... | @@ -5043,6 +5058,7 @@ static bool return_type_is_cacheable(ZigType *return_type) { | ... | @@ -5043,6 +5058,7 @@ static bool return_type_is_cacheable(ZigType *return_type) { |
| 5043 | case ZigTypeIdFloat: | 5058 | case ZigTypeIdFloat: |
| 5044 | case ZigTypeIdComptimeFloat: | 5059 | case ZigTypeIdComptimeFloat: |
| 5045 | case ZigTypeIdComptimeInt: | 5060 | case ZigTypeIdComptimeInt: |
| 5061 | case ZigTypeIdEnumLiteral: | ||
| 5046 | case ZigTypeIdUndefined: | 5062 | case ZigTypeIdUndefined: |
| 5047 | case ZigTypeIdNull: | 5063 | case ZigTypeIdNull: |
| 5048 | case ZigTypeIdBoundFn: | 5064 | case ZigTypeIdBoundFn: |
| ... | @@ -5173,6 +5189,7 @@ OnePossibleValue type_has_one_possible_value(CodeGen *g, ZigType *type_entry) { | ... | @@ -5173,6 +5189,7 @@ OnePossibleValue type_has_one_possible_value(CodeGen *g, ZigType *type_entry) { |
| 5173 | case ZigTypeIdOpaque: | 5189 | case ZigTypeIdOpaque: |
| 5174 | case ZigTypeIdComptimeFloat: | 5190 | case ZigTypeIdComptimeFloat: |
| 5175 | case ZigTypeIdComptimeInt: | 5191 | case ZigTypeIdComptimeInt: |
| 5192 | case ZigTypeIdEnumLiteral: | ||
| 5176 | case ZigTypeIdMetaType: | 5193 | case ZigTypeIdMetaType: |
| 5177 | case ZigTypeIdBoundFn: | 5194 | case ZigTypeIdBoundFn: |
| 5178 | case ZigTypeIdArgTuple: | 5195 | case ZigTypeIdArgTuple: |
| ... | @@ -5236,6 +5253,7 @@ ReqCompTime type_requires_comptime(CodeGen *g, ZigType *type_entry) { | ... | @@ -5236,6 +5253,7 @@ ReqCompTime type_requires_comptime(CodeGen *g, ZigType *type_entry) { |
| 5236 | zig_unreachable(); | 5253 | zig_unreachable(); |
| 5237 | case ZigTypeIdComptimeFloat: | 5254 | case ZigTypeIdComptimeFloat: |
| 5238 | case ZigTypeIdComptimeInt: | 5255 | case ZigTypeIdComptimeInt: |
| 5256 | case ZigTypeIdEnumLiteral: | ||
| 5239 | case ZigTypeIdUndefined: | 5257 | case ZigTypeIdUndefined: |
| 5240 | case ZigTypeIdNull: | 5258 | case ZigTypeIdNull: |
| 5241 | case ZigTypeIdMetaType: | 5259 | case ZigTypeIdMetaType: |
| ... | @@ -5794,6 +5812,8 @@ bool const_values_equal(CodeGen *g, ConstExprValue *a, ConstExprValue *b) { | ... | @@ -5794,6 +5812,8 @@ bool const_values_equal(CodeGen *g, ConstExprValue *a, ConstExprValue *b) { |
| 5794 | case ZigTypeIdInt: | 5812 | case ZigTypeIdInt: |
| 5795 | case ZigTypeIdComptimeInt: | 5813 | case ZigTypeIdComptimeInt: |
| 5796 | return bigint_cmp(&a->data.x_bigint, &b->data.x_bigint) == CmpEQ; | 5814 | return bigint_cmp(&a->data.x_bigint, &b->data.x_bigint) == CmpEQ; |
| 5815 | case ZigTypeIdEnumLiteral: | ||
| 5816 | return buf_eql_buf(a->data.x_enum_literal, b->data.x_enum_literal); | ||
| 5797 | case ZigTypeIdPointer: | 5817 | case ZigTypeIdPointer: |
| 5798 | case ZigTypeIdFn: | 5818 | case ZigTypeIdFn: |
| 5799 | return const_values_equal_ptr(a, b); | 5819 | return const_values_equal_ptr(a, b); |
| ... | @@ -6044,6 +6064,9 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) { | ... | @@ -6044,6 +6064,9 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) { |
| 6044 | case ZigTypeIdInt: | 6064 | case ZigTypeIdInt: |
| 6045 | bigint_append_buf(buf, &const_val->data.x_bigint, 10); | 6065 | bigint_append_buf(buf, &const_val->data.x_bigint, 10); |
| 6046 | return; | 6066 | return; |
| 6067 | case ZigTypeIdEnumLiteral: | ||
| 6068 | buf_append_buf(buf, const_val->data.x_enum_literal); | ||
| 6069 | return; | ||
| 6047 | case ZigTypeIdMetaType: | 6070 | case ZigTypeIdMetaType: |
| 6048 | buf_appendf(buf, "%s", buf_ptr(&const_val->data.x_type->name)); | 6071 | buf_appendf(buf, "%s", buf_ptr(&const_val->data.x_type->name)); |
| 6049 | return; | 6072 | return; |
| ... | @@ -6213,6 +6236,7 @@ uint32_t type_id_hash(TypeId x) { | ... | @@ -6213,6 +6236,7 @@ uint32_t type_id_hash(TypeId x) { |
| 6213 | case ZigTypeIdStruct: | 6236 | case ZigTypeIdStruct: |
| 6214 | case ZigTypeIdComptimeFloat: | 6237 | case ZigTypeIdComptimeFloat: |
| 6215 | case ZigTypeIdComptimeInt: | 6238 | case ZigTypeIdComptimeInt: |
| 6239 | case ZigTypeIdEnumLiteral: | ||
| 6216 | case ZigTypeIdUndefined: | 6240 | case ZigTypeIdUndefined: |
| 6217 | case ZigTypeIdNull: | 6241 | case ZigTypeIdNull: |
| 6218 | case ZigTypeIdOptional: | 6242 | case ZigTypeIdOptional: |
| ... | @@ -6260,6 +6284,7 @@ bool type_id_eql(TypeId a, TypeId b) { | ... | @@ -6260,6 +6284,7 @@ bool type_id_eql(TypeId a, TypeId b) { |
| 6260 | case ZigTypeIdStruct: | 6284 | case ZigTypeIdStruct: |
| 6261 | case ZigTypeIdComptimeFloat: | 6285 | case ZigTypeIdComptimeFloat: |
| 6262 | case ZigTypeIdComptimeInt: | 6286 | case ZigTypeIdComptimeInt: |
| 6287 | case ZigTypeIdEnumLiteral: | ||
| 6263 | case ZigTypeIdUndefined: | 6288 | case ZigTypeIdUndefined: |
| 6264 | case ZigTypeIdNull: | 6289 | case ZigTypeIdNull: |
| 6265 | case ZigTypeIdOptional: | 6290 | case ZigTypeIdOptional: |
| ... | @@ -6439,6 +6464,7 @@ static const ZigTypeId all_type_ids[] = { | ... | @@ -6439,6 +6464,7 @@ static const ZigTypeId all_type_ids[] = { |
| 6439 | ZigTypeIdOpaque, | 6464 | ZigTypeIdOpaque, |
| 6440 | ZigTypeIdPromise, | 6465 | ZigTypeIdPromise, |
| 6441 | ZigTypeIdVector, | 6466 | ZigTypeIdVector, |
| 6467 | ZigTypeIdEnumLiteral, | ||
| 6442 | }; | 6468 | }; |
| 6443 | 6469 | ||
| 6444 | ZigTypeId type_id_at_index(size_t index) { | 6470 | ZigTypeId type_id_at_index(size_t index) { |
| ... | @@ -6504,6 +6530,8 @@ size_t type_id_index(ZigType *entry) { | ... | @@ -6504,6 +6530,8 @@ size_t type_id_index(ZigType *entry) { |
| 6504 | return 22; | 6530 | return 22; |
| 6505 | case ZigTypeIdVector: | 6531 | case ZigTypeIdVector: |
| 6506 | return 23; | 6532 | return 23; |
| 6533 | case ZigTypeIdEnumLiteral: | ||
| 6534 | return 24; | ||
| 6507 | } | 6535 | } |
| 6508 | zig_unreachable(); | 6536 | zig_unreachable(); |
| 6509 | } | 6537 | } |
| ... | @@ -6534,6 +6562,8 @@ const char *type_id_name(ZigTypeId id) { | ... | @@ -6534,6 +6562,8 @@ const char *type_id_name(ZigTypeId id) { |
| 6534 | return "ComptimeFloat"; | 6562 | return "ComptimeFloat"; |
| 6535 | case ZigTypeIdComptimeInt: | 6563 | case ZigTypeIdComptimeInt: |
| 6536 | return "ComptimeInt"; | 6564 | return "ComptimeInt"; |
| 6565 | case ZigTypeIdEnumLiteral: | ||
| 6566 | return "EnumLiteral"; | ||
| 6537 | case ZigTypeIdUndefined: | 6567 | case ZigTypeIdUndefined: |
| 6538 | return "Undefined"; | 6568 | return "Undefined"; |
| 6539 | case ZigTypeIdNull: | 6569 | case ZigTypeIdNull: |
src/ast_render.cpp+7| ... | @@ -259,6 +259,8 @@ static const char *node_type_str(NodeType node_type) { | ... | @@ -259,6 +259,8 @@ static const char *node_type_str(NodeType node_type) { |
| 259 | return "PromiseType"; | 259 | return "PromiseType"; |
| 260 | case NodeTypePointerType: | 260 | case NodeTypePointerType: |
| 261 | return "PointerType"; | 261 | return "PointerType"; |
| 262 | case NodeTypeEnumLiteral: | ||
| 263 | return "EnumLiteral"; | ||
| 262 | } | 264 | } |
| 263 | zig_unreachable(); | 265 | zig_unreachable(); |
| 264 | } | 266 | } |
| ... | @@ -1154,6 +1156,11 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) { | ... | @@ -1154,6 +1156,11 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) { |
| 1154 | } | 1156 | } |
| 1155 | break; | 1157 | break; |
| 1156 | } | 1158 | } |
| 1159 | case NodeTypeEnumLiteral: | ||
| 1160 | { | ||
| 1161 | fprintf(ar->f, ".%s", buf_ptr(&node->data.enum_literal.identifier->data.str_lit.str)); | ||
| 1162 | break; | ||
| 1163 | } | ||
| 1157 | case NodeTypeParamDecl: | 1164 | case NodeTypeParamDecl: |
| 1158 | case NodeTypeTestDecl: | 1165 | case NodeTypeTestDecl: |
| 1159 | case NodeTypeStructField: | 1166 | case NodeTypeStructField: |
src/codegen.cpp+12-1| ... | @@ -5818,6 +5818,7 @@ static LLVMValueRef pack_const_int(CodeGen *g, LLVMTypeRef big_int_type_ref, Con | ... | @@ -5818,6 +5818,7 @@ static LLVMValueRef pack_const_int(CodeGen *g, LLVMTypeRef big_int_type_ref, Con |
| 5818 | case ZigTypeIdUnreachable: | 5818 | case ZigTypeIdUnreachable: |
| 5819 | case ZigTypeIdComptimeFloat: | 5819 | case ZigTypeIdComptimeFloat: |
| 5820 | case ZigTypeIdComptimeInt: | 5820 | case ZigTypeIdComptimeInt: |
| 5821 | case ZigTypeIdEnumLiteral: | ||
| 5821 | case ZigTypeIdUndefined: | 5822 | case ZigTypeIdUndefined: |
| 5822 | case ZigTypeIdNull: | 5823 | case ZigTypeIdNull: |
| 5823 | case ZigTypeIdErrorUnion: | 5824 | case ZigTypeIdErrorUnion: |
| ... | @@ -6419,6 +6420,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const c | ... | @@ -6419,6 +6420,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const c |
| 6419 | case ZigTypeIdUnreachable: | 6420 | case ZigTypeIdUnreachable: |
| 6420 | case ZigTypeIdComptimeFloat: | 6421 | case ZigTypeIdComptimeFloat: |
| 6421 | case ZigTypeIdComptimeInt: | 6422 | case ZigTypeIdComptimeInt: |
| 6423 | case ZigTypeIdEnumLiteral: | ||
| 6422 | case ZigTypeIdUndefined: | 6424 | case ZigTypeIdUndefined: |
| 6423 | case ZigTypeIdNull: | 6425 | case ZigTypeIdNull: |
| 6424 | case ZigTypeIdBoundFn: | 6426 | case ZigTypeIdBoundFn: |
| ... | @@ -7005,6 +7007,12 @@ static void define_builtin_types(CodeGen *g) { | ... | @@ -7005,6 +7007,12 @@ static void define_builtin_types(CodeGen *g) { |
| 7005 | g->builtin_types.entry_num_lit_int = entry; | 7007 | g->builtin_types.entry_num_lit_int = entry; |
| 7006 | g->primitive_type_table.put(&entry->name, entry); | 7008 | g->primitive_type_table.put(&entry->name, entry); |
| 7007 | } | 7009 | } |
| 7010 | { | ||
| 7011 | ZigType *entry = new_type_table_entry(ZigTypeIdEnumLiteral); | ||
| 7012 | buf_init_from_str(&entry->name, "(enum literal)"); | ||
| 7013 | entry->zero_bits = true; | ||
| 7014 | g->builtin_types.entry_enum_literal = entry; | ||
| 7015 | } | ||
| 7008 | { | 7016 | { |
| 7009 | ZigType *entry = new_type_table_entry(ZigTypeIdUndefined); | 7017 | ZigType *entry = new_type_table_entry(ZigTypeIdUndefined); |
| 7010 | buf_init_from_str(&entry->name, "(undefined)"); | 7018 | buf_init_from_str(&entry->name, "(undefined)"); |
| ... | @@ -7175,7 +7183,6 @@ static void define_builtin_types(CodeGen *g) { | ... | @@ -7175,7 +7183,6 @@ static void define_builtin_types(CodeGen *g) { |
| 7175 | ZigType *entry = get_promise_type(g, nullptr); | 7183 | ZigType *entry = get_promise_type(g, nullptr); |
| 7176 | g->primitive_type_table.put(&entry->name, entry); | 7184 | g->primitive_type_table.put(&entry->name, entry); |
| 7177 | } | 7185 | } |
| 7178 | |||
| 7179 | } | 7186 | } |
| 7180 | 7187 | ||
| 7181 | 7188 | ||
| ... | @@ -7527,6 +7534,7 @@ Buf *codegen_generate_builtin_source(CodeGen *g) { | ... | @@ -7527,6 +7534,7 @@ Buf *codegen_generate_builtin_source(CodeGen *g) { |
| 7527 | " Opaque: void,\n" | 7534 | " Opaque: void,\n" |
| 7528 | " Promise: Promise,\n" | 7535 | " Promise: Promise,\n" |
| 7529 | " Vector: Vector,\n" | 7536 | " Vector: Vector,\n" |
| 7537 | " EnumLiteral: void,\n" | ||
| 7530 | "\n\n" | 7538 | "\n\n" |
| 7531 | " pub const Int = struct {\n" | 7539 | " pub const Int = struct {\n" |
| 7532 | " is_signed: bool,\n" | 7540 | " is_signed: bool,\n" |
| ... | @@ -8626,6 +8634,7 @@ static void prepend_c_type_to_decl_list(CodeGen *g, GenH *gen_h, ZigType *type_e | ... | @@ -8626,6 +8634,7 @@ static void prepend_c_type_to_decl_list(CodeGen *g, GenH *gen_h, ZigType *type_e |
| 8626 | case ZigTypeIdMetaType: | 8634 | case ZigTypeIdMetaType: |
| 8627 | case ZigTypeIdComptimeFloat: | 8635 | case ZigTypeIdComptimeFloat: |
| 8628 | case ZigTypeIdComptimeInt: | 8636 | case ZigTypeIdComptimeInt: |
| 8637 | case ZigTypeIdEnumLiteral: | ||
| 8629 | case ZigTypeIdUndefined: | 8638 | case ZigTypeIdUndefined: |
| 8630 | case ZigTypeIdNull: | 8639 | case ZigTypeIdNull: |
| 8631 | case ZigTypeIdBoundFn: | 8640 | case ZigTypeIdBoundFn: |
| ... | @@ -8812,6 +8821,7 @@ static void get_c_type(CodeGen *g, GenH *gen_h, ZigType *type_entry, Buf *out_bu | ... | @@ -8812,6 +8821,7 @@ static void get_c_type(CodeGen *g, GenH *gen_h, ZigType *type_entry, Buf *out_bu |
| 8812 | case ZigTypeIdBoundFn: | 8821 | case ZigTypeIdBoundFn: |
| 8813 | case ZigTypeIdComptimeFloat: | 8822 | case ZigTypeIdComptimeFloat: |
| 8814 | case ZigTypeIdComptimeInt: | 8823 | case ZigTypeIdComptimeInt: |
| 8824 | case ZigTypeIdEnumLiteral: | ||
| 8815 | case ZigTypeIdUndefined: | 8825 | case ZigTypeIdUndefined: |
| 8816 | case ZigTypeIdNull: | 8826 | case ZigTypeIdNull: |
| 8817 | case ZigTypeIdArgTuple: | 8827 | case ZigTypeIdArgTuple: |
| ... | @@ -8965,6 +8975,7 @@ static void gen_h_file(CodeGen *g) { | ... | @@ -8965,6 +8975,7 @@ static void gen_h_file(CodeGen *g) { |
| 8965 | case ZigTypeIdPointer: | 8975 | case ZigTypeIdPointer: |
| 8966 | case ZigTypeIdComptimeFloat: | 8976 | case ZigTypeIdComptimeFloat: |
| 8967 | case ZigTypeIdComptimeInt: | 8977 | case ZigTypeIdComptimeInt: |
| 8978 | case ZigTypeIdEnumLiteral: | ||
| 8968 | case ZigTypeIdArray: | 8979 | case ZigTypeIdArray: |
| 8969 | case ZigTypeIdUndefined: | 8980 | case ZigTypeIdUndefined: |
| 8970 | case ZigTypeIdNull: | 8981 | case ZigTypeIdNull: |
src/ir.cpp+30| ... | @@ -257,6 +257,7 @@ static bool types_have_same_zig_comptime_repr(ZigType *a, ZigType *b) { | ... | @@ -257,6 +257,7 @@ static bool types_have_same_zig_comptime_repr(ZigType *a, ZigType *b) { |
| 257 | case ZigTypeIdBool: | 257 | case ZigTypeIdBool: |
| 258 | case ZigTypeIdComptimeFloat: | 258 | case ZigTypeIdComptimeFloat: |
| 259 | case ZigTypeIdComptimeInt: | 259 | case ZigTypeIdComptimeInt: |
| 260 | case ZigTypeIdEnumLiteral: | ||
| 260 | case ZigTypeIdPointer: | 261 | case ZigTypeIdPointer: |
| 261 | case ZigTypeIdUndefined: | 262 | case ZigTypeIdUndefined: |
| 262 | case ZigTypeIdNull: | 263 | case ZigTypeIdNull: |
| ... | @@ -1144,6 +1145,14 @@ static IrInstruction *ir_build_const_bool(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -1144,6 +1145,14 @@ static IrInstruction *ir_build_const_bool(IrBuilder *irb, Scope *scope, AstNode |
| 1144 | return &const_instruction->base; | 1145 | return &const_instruction->base; |
| 1145 | } | 1146 | } |
| 1146 | 1147 | ||
| 1148 | static IrInstruction *ir_build_const_enum_literal(IrBuilder *irb, Scope *scope, AstNode *source_node, Buf *name) { | ||
| 1149 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); | ||
| 1150 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_enum_literal; | ||
| 1151 | const_instruction->base.value.special = ConstValSpecialStatic; | ||
| 1152 | const_instruction->base.value.data.x_enum_literal = name; | ||
| 1153 | return &const_instruction->base; | ||
| 1154 | } | ||
| 1155 | |||
| 1147 | static IrInstruction *ir_build_const_bound_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, | 1156 | static IrInstruction *ir_build_const_bound_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, |
| 1148 | ZigFn *fn_entry, IrInstruction *first_arg) | 1157 | ZigFn *fn_entry, IrInstruction *first_arg) |
| 1149 | { | 1158 | { |
| ... | @@ -5794,6 +5803,12 @@ static IrInstruction *ir_gen_bool_literal(IrBuilder *irb, Scope *scope, AstNode | ... | @@ -5794,6 +5803,12 @@ static IrInstruction *ir_gen_bool_literal(IrBuilder *irb, Scope *scope, AstNode |
| 5794 | return ir_build_const_bool(irb, scope, node, node->data.bool_literal.value); | 5803 | return ir_build_const_bool(irb, scope, node, node->data.bool_literal.value); |
| 5795 | } | 5804 | } |
| 5796 | 5805 | ||
| 5806 | static IrInstruction *ir_gen_enum_literal(IrBuilder *irb, Scope *scope, AstNode *node) { | ||
| 5807 | assert(node->type == NodeTypeEnumLiteral); | ||
| 5808 | Buf *name = &node->data.enum_literal.identifier->data.str_lit.str; | ||
| 5809 | return ir_build_const_enum_literal(irb, scope, node, name); | ||
| 5810 | } | ||
| 5811 | |||
| 5797 | static IrInstruction *ir_gen_string_literal(IrBuilder *irb, Scope *scope, AstNode *node) { | 5812 | static IrInstruction *ir_gen_string_literal(IrBuilder *irb, Scope *scope, AstNode *node) { |
| 5798 | assert(node->type == NodeTypeStringLiteral); | 5813 | assert(node->type == NodeTypeStringLiteral); |
| 5799 | 5814 | ||
| ... | @@ -7564,6 +7579,8 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop | ... | @@ -7564,6 +7579,8 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop |
| 7564 | return ir_lval_wrap(irb, scope, ir_gen_await_expr(irb, scope, node), lval); | 7579 | return ir_lval_wrap(irb, scope, ir_gen_await_expr(irb, scope, node), lval); |
| 7565 | case NodeTypeSuspend: | 7580 | case NodeTypeSuspend: |
| 7566 | return ir_lval_wrap(irb, scope, ir_gen_suspend(irb, scope, node), lval); | 7581 | return ir_lval_wrap(irb, scope, ir_gen_suspend(irb, scope, node), lval); |
| 7582 | case NodeTypeEnumLiteral: | ||
| 7583 | return ir_lval_wrap(irb, scope, ir_gen_enum_literal(irb, scope, node), lval); | ||
| 7567 | } | 7584 | } |
| 7568 | zig_unreachable(); | 7585 | zig_unreachable(); |
| 7569 | } | 7586 | } |
| ... | @@ -12264,6 +12281,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -12264,6 +12281,7 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 12264 | case ZigTypeIdArgTuple: | 12281 | case ZigTypeIdArgTuple: |
| 12265 | case ZigTypeIdPromise: | 12282 | case ZigTypeIdPromise: |
| 12266 | case ZigTypeIdEnum: | 12283 | case ZigTypeIdEnum: |
| 12284 | case ZigTypeIdEnumLiteral: | ||
| 12267 | operator_allowed = is_equality_cmp; | 12285 | operator_allowed = is_equality_cmp; |
| 12268 | break; | 12286 | break; |
| 12269 | 12287 | ||
| ... | @@ -13596,6 +13614,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -13596,6 +13614,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 13596 | case ZigTypeIdUnreachable: | 13614 | case ZigTypeIdUnreachable: |
| 13597 | case ZigTypeIdComptimeFloat: | 13615 | case ZigTypeIdComptimeFloat: |
| 13598 | case ZigTypeIdComptimeInt: | 13616 | case ZigTypeIdComptimeInt: |
| 13617 | case ZigTypeIdEnumLiteral: | ||
| 13599 | case ZigTypeIdUndefined: | 13618 | case ZigTypeIdUndefined: |
| 13600 | case ZigTypeIdNull: | 13619 | case ZigTypeIdNull: |
| 13601 | case ZigTypeIdOptional: | 13620 | case ZigTypeIdOptional: |
| ... | @@ -13629,6 +13648,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -13629,6 +13648,7 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 13629 | case ZigTypeIdArgTuple: | 13648 | case ZigTypeIdArgTuple: |
| 13630 | case ZigTypeIdOpaque: | 13649 | case ZigTypeIdOpaque: |
| 13631 | case ZigTypeIdPromise: | 13650 | case ZigTypeIdPromise: |
| 13651 | case ZigTypeIdEnumLiteral: | ||
| 13632 | ir_add_error(ira, target, | 13652 | ir_add_error(ira, target, |
| 13633 | buf_sprintf("invalid export target type '%s'", buf_ptr(&target->value.type->name))); | 13653 | buf_sprintf("invalid export target type '%s'", buf_ptr(&target->value.type->name))); |
| 13634 | break; | 13654 | break; |
| ... | @@ -14805,6 +14825,7 @@ static IrInstruction *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op_ | ... | @@ -14805,6 +14825,7 @@ static IrInstruction *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op_ |
| 14805 | case ZigTypeIdStruct: | 14825 | case ZigTypeIdStruct: |
| 14806 | case ZigTypeIdComptimeFloat: | 14826 | case ZigTypeIdComptimeFloat: |
| 14807 | case ZigTypeIdComptimeInt: | 14827 | case ZigTypeIdComptimeInt: |
| 14828 | case ZigTypeIdEnumLiteral: | ||
| 14808 | case ZigTypeIdUndefined: | 14829 | case ZigTypeIdUndefined: |
| 14809 | case ZigTypeIdNull: | 14830 | case ZigTypeIdNull: |
| 14810 | case ZigTypeIdOptional: | 14831 | case ZigTypeIdOptional: |
| ... | @@ -16448,6 +16469,7 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira, | ... | @@ -16448,6 +16469,7 @@ static IrInstruction *ir_analyze_instruction_slice_type(IrAnalyze *ira, |
| 16448 | case ZigTypeIdStruct: | 16469 | case ZigTypeIdStruct: |
| 16449 | case ZigTypeIdComptimeFloat: | 16470 | case ZigTypeIdComptimeFloat: |
| 16450 | case ZigTypeIdComptimeInt: | 16471 | case ZigTypeIdComptimeInt: |
| 16472 | case ZigTypeIdEnumLiteral: | ||
| 16451 | case ZigTypeIdOptional: | 16473 | case ZigTypeIdOptional: |
| 16452 | case ZigTypeIdErrorUnion: | 16474 | case ZigTypeIdErrorUnion: |
| 16453 | case ZigTypeIdErrorSet: | 16475 | case ZigTypeIdErrorSet: |
| ... | @@ -16560,6 +16582,7 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira, | ... | @@ -16560,6 +16582,7 @@ static IrInstruction *ir_analyze_instruction_array_type(IrAnalyze *ira, |
| 16560 | case ZigTypeIdStruct: | 16582 | case ZigTypeIdStruct: |
| 16561 | case ZigTypeIdComptimeFloat: | 16583 | case ZigTypeIdComptimeFloat: |
| 16562 | case ZigTypeIdComptimeInt: | 16584 | case ZigTypeIdComptimeInt: |
| 16585 | case ZigTypeIdEnumLiteral: | ||
| 16563 | case ZigTypeIdOptional: | 16586 | case ZigTypeIdOptional: |
| 16564 | case ZigTypeIdErrorUnion: | 16587 | case ZigTypeIdErrorUnion: |
| 16565 | case ZigTypeIdErrorSet: | 16588 | case ZigTypeIdErrorSet: |
| ... | @@ -16613,6 +16636,7 @@ static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira, | ... | @@ -16613,6 +16636,7 @@ static IrInstruction *ir_analyze_instruction_size_of(IrAnalyze *ira, |
| 16613 | case ZigTypeIdNull: | 16636 | case ZigTypeIdNull: |
| 16614 | case ZigTypeIdComptimeFloat: | 16637 | case ZigTypeIdComptimeFloat: |
| 16615 | case ZigTypeIdComptimeInt: | 16638 | case ZigTypeIdComptimeInt: |
| 16639 | case ZigTypeIdEnumLiteral: | ||
| 16616 | case ZigTypeIdBoundFn: | 16640 | case ZigTypeIdBoundFn: |
| 16617 | case ZigTypeIdMetaType: | 16641 | case ZigTypeIdMetaType: |
| 16618 | case ZigTypeIdArgTuple: | 16642 | case ZigTypeIdArgTuple: |
| ... | @@ -17019,6 +17043,7 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, | ... | @@ -17019,6 +17043,7 @@ static IrInstruction *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 17019 | case ZigTypeIdFloat: | 17043 | case ZigTypeIdFloat: |
| 17020 | case ZigTypeIdComptimeFloat: | 17044 | case ZigTypeIdComptimeFloat: |
| 17021 | case ZigTypeIdComptimeInt: | 17045 | case ZigTypeIdComptimeInt: |
| 17046 | case ZigTypeIdEnumLiteral: | ||
| 17022 | case ZigTypeIdPointer: | 17047 | case ZigTypeIdPointer: |
| 17023 | case ZigTypeIdPromise: | 17048 | case ZigTypeIdPromise: |
| 17024 | case ZigTypeIdFn: | 17049 | case ZigTypeIdFn: |
| ... | @@ -18237,6 +18262,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -18237,6 +18262,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 18237 | case ZigTypeIdUnreachable: | 18262 | case ZigTypeIdUnreachable: |
| 18238 | case ZigTypeIdComptimeFloat: | 18263 | case ZigTypeIdComptimeFloat: |
| 18239 | case ZigTypeIdComptimeInt: | 18264 | case ZigTypeIdComptimeInt: |
| 18265 | case ZigTypeIdEnumLiteral: | ||
| 18240 | case ZigTypeIdUndefined: | 18266 | case ZigTypeIdUndefined: |
| 18241 | case ZigTypeIdNull: | 18267 | case ZigTypeIdNull: |
| 18242 | case ZigTypeIdArgTuple: | 18268 | case ZigTypeIdArgTuple: |
| ... | @@ -20443,6 +20469,7 @@ static IrInstruction *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruct | ... | @@ -20443,6 +20469,7 @@ static IrInstruction *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstruct |
| 20443 | case ZigTypeIdUnreachable: | 20469 | case ZigTypeIdUnreachable: |
| 20444 | case ZigTypeIdComptimeFloat: | 20470 | case ZigTypeIdComptimeFloat: |
| 20445 | case ZigTypeIdComptimeInt: | 20471 | case ZigTypeIdComptimeInt: |
| 20472 | case ZigTypeIdEnumLiteral: | ||
| 20446 | case ZigTypeIdUndefined: | 20473 | case ZigTypeIdUndefined: |
| 20447 | case ZigTypeIdNull: | 20474 | case ZigTypeIdNull: |
| 20448 | case ZigTypeIdBoundFn: | 20475 | case ZigTypeIdBoundFn: |
| ... | @@ -21293,6 +21320,7 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue | ... | @@ -21293,6 +21320,7 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue |
| 21293 | case ZigTypeIdUnreachable: | 21320 | case ZigTypeIdUnreachable: |
| 21294 | case ZigTypeIdComptimeFloat: | 21321 | case ZigTypeIdComptimeFloat: |
| 21295 | case ZigTypeIdComptimeInt: | 21322 | case ZigTypeIdComptimeInt: |
| 21323 | case ZigTypeIdEnumLiteral: | ||
| 21296 | case ZigTypeIdUndefined: | 21324 | case ZigTypeIdUndefined: |
| 21297 | case ZigTypeIdNull: | 21325 | case ZigTypeIdNull: |
| 21298 | case ZigTypeIdPromise: | 21326 | case ZigTypeIdPromise: |
| ... | @@ -21452,6 +21480,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou | ... | @@ -21452,6 +21480,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou |
| 21452 | case ZigTypeIdUnreachable: | 21480 | case ZigTypeIdUnreachable: |
| 21453 | case ZigTypeIdComptimeFloat: | 21481 | case ZigTypeIdComptimeFloat: |
| 21454 | case ZigTypeIdComptimeInt: | 21482 | case ZigTypeIdComptimeInt: |
| 21483 | case ZigTypeIdEnumLiteral: | ||
| 21455 | case ZigTypeIdUndefined: | 21484 | case ZigTypeIdUndefined: |
| 21456 | case ZigTypeIdNull: | 21485 | case ZigTypeIdNull: |
| 21457 | case ZigTypeIdPromise: | 21486 | case ZigTypeIdPromise: |
| ... | @@ -21609,6 +21638,7 @@ static bool type_can_bit_cast(ZigType *t) { | ... | @@ -21609,6 +21638,7 @@ static bool type_can_bit_cast(ZigType *t) { |
| 21609 | case ZigTypeIdUnreachable: | 21638 | case ZigTypeIdUnreachable: |
| 21610 | case ZigTypeIdComptimeFloat: | 21639 | case ZigTypeIdComptimeFloat: |
| 21611 | case ZigTypeIdComptimeInt: | 21640 | case ZigTypeIdComptimeInt: |
| 21641 | case ZigTypeIdEnumLiteral: | ||
| 21612 | case ZigTypeIdUndefined: | 21642 | case ZigTypeIdUndefined: |
| 21613 | case ZigTypeIdNull: | 21643 | case ZigTypeIdNull: |
| 21614 | case ZigTypeIdPointer: | 21644 | case ZigTypeIdPointer: |
src/parser.cpp+19| ... | @@ -81,6 +81,7 @@ static AstNode *ast_parse_for_type_expr(ParseContext *pc); | ... | @@ -81,6 +81,7 @@ static AstNode *ast_parse_for_type_expr(ParseContext *pc); |
| 81 | static AstNode *ast_parse_while_type_expr(ParseContext *pc); | 81 | static AstNode *ast_parse_while_type_expr(ParseContext *pc); |
| 82 | static AstNode *ast_parse_switch_expr(ParseContext *pc); | 82 | static AstNode *ast_parse_switch_expr(ParseContext *pc); |
| 83 | static AstNode *ast_parse_asm_expr(ParseContext *pc); | 83 | static AstNode *ast_parse_asm_expr(ParseContext *pc); |
| 84 | static AstNode *ast_parse_enum_lit(ParseContext *pc); | ||
| 84 | static AstNode *ast_parse_asm_output(ParseContext *pc); | 85 | static AstNode *ast_parse_asm_output(ParseContext *pc); |
| 85 | static AsmOutput *ast_parse_asm_output_item(ParseContext *pc); | 86 | static AsmOutput *ast_parse_asm_output_item(ParseContext *pc); |
| 86 | static AstNode *ast_parse_asm_input(ParseContext *pc); | 87 | static AstNode *ast_parse_asm_input(ParseContext *pc); |
| ... | @@ -1161,6 +1162,10 @@ static AstNode *ast_parse_prefix_expr(ParseContext *pc) { | ... | @@ -1161,6 +1162,10 @@ static AstNode *ast_parse_prefix_expr(ParseContext *pc) { |
| 1161 | // / Block | 1162 | // / Block |
| 1162 | // / CurlySuffixExpr | 1163 | // / CurlySuffixExpr |
| 1163 | static AstNode *ast_parse_primary_expr(ParseContext *pc) { | 1164 | static AstNode *ast_parse_primary_expr(ParseContext *pc) { |
| 1165 | AstNode *enum_lit = ast_parse_enum_lit(pc); | ||
| 1166 | if (enum_lit != nullptr) | ||
| 1167 | return enum_lit; | ||
| 1168 | |||
| 1164 | AstNode *asm_expr = ast_parse_asm_expr(pc); | 1169 | AstNode *asm_expr = ast_parse_asm_expr(pc); |
| 1165 | if (asm_expr != nullptr) | 1170 | if (asm_expr != nullptr) |
| 1166 | return asm_expr; | 1171 | return asm_expr; |
| ... | @@ -1831,6 +1836,18 @@ static AstNode *ast_parse_asm_expr(ParseContext *pc) { | ... | @@ -1831,6 +1836,18 @@ static AstNode *ast_parse_asm_expr(ParseContext *pc) { |
| 1831 | return res; | 1836 | return res; |
| 1832 | } | 1837 | } |
| 1833 | 1838 | ||
| 1839 | static AstNode *ast_parse_enum_lit(ParseContext *pc) { | ||
| 1840 | Token *period = eat_token_if(pc, TokenIdDot); | ||
| 1841 | if (period == nullptr) | ||
| 1842 | return nullptr; | ||
| 1843 | |||
| 1844 | Token *identifier = expect_token(pc, TokenIdSymbol); | ||
| 1845 | AstNode *res = ast_create_node(pc, NodeTypeEnumLiteral, period); | ||
| 1846 | res->data.enum_literal.period = period; | ||
| 1847 | res->data.enum_literal.identifier = identifier; | ||
| 1848 | return res; | ||
| 1849 | } | ||
| 1850 | |||
| 1834 | // AsmOutput <- COLON AsmOutputList AsmInput? | 1851 | // AsmOutput <- COLON AsmOutputList AsmInput? |
| 1835 | static AstNode *ast_parse_asm_output(ParseContext *pc) { | 1852 | static AstNode *ast_parse_asm_output(ParseContext *pc) { |
| 1836 | if (eat_token_if(pc, TokenIdColon) == nullptr) | 1853 | if (eat_token_if(pc, TokenIdColon) == nullptr) |
| ... | @@ -3000,5 +3017,7 @@ void ast_visit_node_children(AstNode *node, void (*visit)(AstNode **, void *cont | ... | @@ -3000,5 +3017,7 @@ void ast_visit_node_children(AstNode *node, void (*visit)(AstNode **, void *cont |
| 3000 | case NodeTypeSuspend: | 3017 | case NodeTypeSuspend: |
| 3001 | visit_field(&node->data.suspend.block, visit, context); | 3018 | visit_field(&node->data.suspend.block, visit, context); |
| 3002 | break; | 3019 | break; |
| 3020 | case NodeTypeEnumLiteral: | ||
| 3021 | break; | ||
| 3003 | } | 3022 | } |
| 3004 | } | 3023 | } |
std/hash_map.zig+2| ... | @@ -490,6 +490,7 @@ pub fn autoHash(key: var, comptime rng: *std.rand.Random, comptime HashInt: type | ... | @@ -490,6 +490,7 @@ pub fn autoHash(key: var, comptime rng: *std.rand.Random, comptime HashInt: type |
| 490 | builtin.TypeId.ComptimeFloat, | 490 | builtin.TypeId.ComptimeFloat, |
| 491 | builtin.TypeId.ComptimeInt, | 491 | builtin.TypeId.ComptimeInt, |
| 492 | builtin.TypeId.Type, | 492 | builtin.TypeId.Type, |
| 493 | builtin.TypeId.EnumLiteral, | ||
| 493 | => return 0, | 494 | => return 0, |
| 494 | 495 | ||
| 495 | builtin.TypeId.Pointer => |info| switch (info.size) { | 496 | builtin.TypeId.Pointer => |info| switch (info.size) { |
| ... | @@ -531,6 +532,7 @@ pub fn autoEql(a: var, b: @typeOf(a)) bool { | ... | @@ -531,6 +532,7 @@ pub fn autoEql(a: var, b: @typeOf(a)) bool { |
| 531 | builtin.TypeId.Float, | 532 | builtin.TypeId.Float, |
| 532 | builtin.TypeId.ComptimeFloat, | 533 | builtin.TypeId.ComptimeFloat, |
| 533 | builtin.TypeId.ComptimeInt, | 534 | builtin.TypeId.ComptimeInt, |
| 535 | builtin.TypeId.EnumLiteral, | ||
| 534 | builtin.TypeId.Promise, | 536 | builtin.TypeId.Promise, |
| 535 | builtin.TypeId.Enum, | 537 | builtin.TypeId.Enum, |
| 536 | builtin.TypeId.BoundFn, | 538 | builtin.TypeId.BoundFn, |
std/testing.zig+1| ... | @@ -42,6 +42,7 @@ pub fn expectEqual(expected: var, actual: @typeOf(expected)) void { | ... | @@ -42,6 +42,7 @@ pub fn expectEqual(expected: var, actual: @typeOf(expected)) void { |
| 42 | TypeId.Float, | 42 | TypeId.Float, |
| 43 | TypeId.ComptimeFloat, | 43 | TypeId.ComptimeFloat, |
| 44 | TypeId.ComptimeInt, | 44 | TypeId.ComptimeInt, |
| 45 | TypeId.EnumLiteral, | ||
| 45 | TypeId.Enum, | 46 | TypeId.Enum, |
| 46 | TypeId.Fn, | 47 | TypeId.Fn, |
| 47 | TypeId.Promise, | 48 | TypeId.Promise, |
std/zig/ast.zig+19| ... | @@ -296,6 +296,7 @@ pub const Node = struct { | ... | @@ -296,6 +296,7 @@ pub const Node = struct { |
| 296 | // Primary expressions | 296 | // Primary expressions |
| 297 | IntegerLiteral, | 297 | IntegerLiteral, |
| 298 | FloatLiteral, | 298 | FloatLiteral, |
| 299 | EnumLiteral, | ||
| 299 | StringLiteral, | 300 | StringLiteral, |
| 300 | MultilineStringLiteral, | 301 | MultilineStringLiteral, |
| 301 | CharLiteral, | 302 | CharLiteral, |
| ... | @@ -1849,6 +1850,24 @@ pub const Node = struct { | ... | @@ -1849,6 +1850,24 @@ pub const Node = struct { |
| 1849 | } | 1850 | } |
| 1850 | }; | 1851 | }; |
| 1851 | 1852 | ||
| 1853 | pub const EnumLiteral = struct { | ||
| 1854 | base: Node, | ||
| 1855 | dot: TokenIndex, | ||
| 1856 | name: TokenIndex, | ||
| 1857 | |||
| 1858 | pub fn iterate(self: *EnumLiteral, index: usize) ?*Node { | ||
| 1859 | return null; | ||
| 1860 | } | ||
| 1861 | |||
| 1862 | pub fn firstToken(self: *const EnumLiteral) TokenIndex { | ||
| 1863 | return self.dot; | ||
| 1864 | } | ||
| 1865 | |||
| 1866 | pub fn lastToken(self: *const EnumLiteral) TokenIndex { | ||
| 1867 | return self.name; | ||
| 1868 | } | ||
| 1869 | }; | ||
| 1870 | |||
| 1852 | pub const FloatLiteral = struct { | 1871 | pub const FloatLiteral = struct { |
| 1853 | base: Node, | 1872 | base: Node, |
| 1854 | token: TokenIndex, | 1873 | token: TokenIndex, |
std/zig/parse.zig+21| ... | @@ -2543,6 +2543,27 @@ pub fn parse(allocator: *mem.Allocator, source: []const u8) !ast.Tree { | ... | @@ -2543,6 +2543,27 @@ pub fn parse(allocator: *mem.Allocator, source: []const u8) !ast.Tree { |
| 2543 | _ = try createToCtxLiteral(arena, opt_ctx, ast.Node.IntegerLiteral, token.index); | 2543 | _ = try createToCtxLiteral(arena, opt_ctx, ast.Node.IntegerLiteral, token.index); |
| 2544 | continue; | 2544 | continue; |
| 2545 | }, | 2545 | }, |
| 2546 | Token.Id.Period => { | ||
| 2547 | const name_token = nextToken(&tok_it, &tree); | ||
| 2548 | if (name_token.ptr.id != Token.Id.Identifier) { | ||
| 2549 | ((try tree.errors.addOne())).* = Error{ | ||
| 2550 | .ExpectedToken = Error.ExpectedToken{ | ||
| 2551 | .token = name_token.index, | ||
| 2552 | .expected_id = Token.Id.Identifier, | ||
| 2553 | }, | ||
| 2554 | }; | ||
| 2555 | return tree; | ||
| 2556 | } | ||
| 2557 | |||
| 2558 | const node = try arena.create(ast.Node.EnumLiteral); | ||
| 2559 | node.* = ast.Node.EnumLiteral{ | ||
| 2560 | .base = ast.Node{ .id = ast.Node.Id.EnumLiteral }, | ||
| 2561 | .dot = token.index, | ||
| 2562 | .name = name_token.index, | ||
| 2563 | }; | ||
| 2564 | opt_ctx.store(&node.base); | ||
| 2565 | continue; | ||
| 2566 | }, | ||
| 2546 | Token.Id.FloatLiteral => { | 2567 | Token.Id.FloatLiteral => { |
| 2547 | _ = try createToCtxLiteral(arena, opt_ctx, ast.Node.FloatLiteral, token.index); | 2568 | _ = try createToCtxLiteral(arena, opt_ctx, ast.Node.FloatLiteral, token.index); |
| 2548 | continue; | 2569 | continue; |
std/zig/parser_test.zig+7| ... | @@ -1,3 +1,10 @@ | ... | @@ -1,3 +1,10 @@ |
| 1 | test "zig fmt: enum literal" { | ||
| 2 | try testCanonical( | ||
| 3 | \\const x = .hi; | ||
| 4 | \\ | ||
| 5 | ); | ||
| 6 | } | ||
| 7 | |||
| 1 | test "zig fmt: character literal larger than u8" { | 8 | test "zig fmt: character literal larger than u8" { |
| 2 | try testCanonical( | 9 | try testCanonical( |
| 3 | \\const x = '\U01f4a9'; | 10 | \\const x = '\U01f4a9'; |
std/zig/render.zig+7| ... | @@ -1667,6 +1667,13 @@ fn renderExpression( | ... | @@ -1667,6 +1667,13 @@ fn renderExpression( |
| 1667 | return renderToken(tree, stream, asm_output.lastToken(), indent, start_col, space); // ) | 1667 | return renderToken(tree, stream, asm_output.lastToken(), indent, start_col, space); // ) |
| 1668 | }, | 1668 | }, |
| 1669 | 1669 | ||
| 1670 | ast.Node.Id.EnumLiteral => { | ||
| 1671 | const enum_literal = @fieldParentPtr(ast.Node.EnumLiteral, "base", base); | ||
| 1672 | |||
| 1673 | try renderToken(tree, stream, enum_literal.dot, indent, start_col, Space.None); // . | ||
| 1674 | return renderToken(tree, stream, enum_literal.name, indent, start_col, space); // name | ||
| 1675 | }, | ||
| 1676 | |||
| 1670 | ast.Node.Id.StructField, | 1677 | ast.Node.Id.StructField, |
| 1671 | ast.Node.Id.UnionTag, | 1678 | ast.Node.Id.UnionTag, |
| 1672 | ast.Node.Id.EnumTag, | 1679 | ast.Node.Id.EnumTag, |
test/stage1/behavior/enum.zig+9| ... | @@ -892,3 +892,12 @@ test "tag name with assigned enum values" { | ... | @@ -892,3 +892,12 @@ test "tag name with assigned enum values" { |
| 892 | var b = LocalFoo.B; | 892 | var b = LocalFoo.B; |
| 893 | expect(mem.eql(u8, @tagName(b), "B")); | 893 | expect(mem.eql(u8, @tagName(b), "B")); |
| 894 | } | 894 | } |
| 895 | |||
| 896 | test "enum literal equality" { | ||
| 897 | const x = .hi; | ||
| 898 | const y = .ok; | ||
| 899 | const z = .hi; | ||
| 900 | |||
| 901 | expect(x != y); | ||
| 902 | expect(x == z); | ||
| 903 | } |
test/stage1/behavior/type_info.zig+1-1| ... | @@ -190,7 +190,7 @@ fn testUnion() void { | ... | @@ -190,7 +190,7 @@ fn testUnion() void { |
| 190 | expect(TypeId(typeinfo_info) == TypeId.Union); | 190 | expect(TypeId(typeinfo_info) == TypeId.Union); |
| 191 | expect(typeinfo_info.Union.layout == TypeInfo.ContainerLayout.Auto); | 191 | expect(typeinfo_info.Union.layout == TypeInfo.ContainerLayout.Auto); |
| 192 | expect(typeinfo_info.Union.tag_type.? == TypeId); | 192 | expect(typeinfo_info.Union.tag_type.? == TypeId); |
| 193 | expect(typeinfo_info.Union.fields.len == 24); | 193 | expect(typeinfo_info.Union.fields.len == 25); |
| 194 | expect(typeinfo_info.Union.fields[4].enum_field != null); | 194 | expect(typeinfo_info.Union.fields[4].enum_field != null); |
| 195 | expect(typeinfo_info.Union.fields[4].enum_field.?.value == 4); | 195 | expect(typeinfo_info.Union.fields[4].enum_field.?.value == 4); |
| 196 | expect(typeinfo_info.Union.fields[4].field_type == @typeOf(@typeInfo(u8).Int)); | 196 | expect(typeinfo_info.Union.fields[4].field_type == @typeOf(@typeInfo(u8).Int)); |