| author | |
| committer | |
| log | c06a61e9bf93810174255474598cfeae785cfbd6 |
| tree | 27d8f4262d8cd8c72c75e348e63e6c7d6a6ec0d4 |
| parent | 7c3636aaa38e8efa77b73ba94362802517ea739e |
| signature |
closes #128355 files changed, 97 insertions(+), 266 deletions(-)
doc/langref.html.in+2-11| ... | ... | @@ -478,13 +478,9 @@ pub fn main() void { |
| 478 | 478 | <td><code>undefined</code></td> |
| 479 | 479 | <td>used to leave a value unspecified</td> |
| 480 | 480 | </tr> |
| 481 | <tr> | |
| 482 | <td><code>this</code></td> | |
| 483 | <td>refers to the thing in immediate scope</td> | |
| 484 | </tr> | |
| 485 | 481 | </table> |
| 486 | 482 | </div> |
| 487 | {#see_also|Optionals|this#} | |
| 483 | {#see_also|Optionals#} | |
| 488 | 484 | {#header_close#} |
| 489 | 485 | {#header_open|String Literals#} |
| 490 | 486 | {#code_begin|test#} |
| ... | ... | @@ -4186,11 +4182,6 @@ fn foo() void {} |
| 4186 | 4182 | {#code_end#} |
| 4187 | 4183 | {#header_close#} |
| 4188 | 4184 | |
| 4189 | {#header_open|this#} | |
| 4190 | <p>TODO: example of this referring to Self struct</p> | |
| 4191 | <p>TODO: example of this referring to recursion function</p> | |
| 4192 | <p>TODO: example of this referring to basic block for @setRuntimeSafety</p> | |
| 4193 | {#header_close#} | |
| 4194 | 4185 | {#header_open|comptime#} |
| 4195 | 4186 | <p> |
| 4196 | 4187 | Zig places importance on the concept of whether an expression is known at compile-time. |
| ... | ... | @@ -7744,7 +7735,7 @@ ArrayType : "[" option(Expression) "]" option("align" "(" Expression option(":" |
| 7744 | 7735 | |
| 7745 | 7736 | GroupedExpression = "(" Expression ")" |
| 7746 | 7737 | |
| 7747 | KeywordLiteral = "true" | "false" | "null" | "undefined" | "error" | "this" | "unreachable" | "suspend" | |
| 7738 | KeywordLiteral = "true" | "false" | "null" | "undefined" | "error" | "unreachable" | "suspend" | |
| 7748 | 7739 | |
| 7749 | 7740 | ErrorSetDecl = "error" "{" list(Symbol, ",") "}" |
| 7750 | 7741 |
src-self-hosted/type.zig-12| ... | ... | @@ -40,7 +40,6 @@ pub const Type = struct { |
| 40 | 40 | Id.Enum => @fieldParentPtr(Enum, "base", base).destroy(comp), |
| 41 | 41 | Id.Union => @fieldParentPtr(Union, "base", base).destroy(comp), |
| 42 | 42 | Id.Namespace => @fieldParentPtr(Namespace, "base", base).destroy(comp), |
| 43 | Id.Block => @fieldParentPtr(Block, "base", base).destroy(comp), | |
| 44 | 43 | Id.BoundFn => @fieldParentPtr(BoundFn, "base", base).destroy(comp), |
| 45 | 44 | Id.ArgTuple => @fieldParentPtr(ArgTuple, "base", base).destroy(comp), |
| 46 | 45 | Id.Opaque => @fieldParentPtr(Opaque, "base", base).destroy(comp), |
| ... | ... | @@ -74,7 +73,6 @@ pub const Type = struct { |
| 74 | 73 | Id.Enum => return @fieldParentPtr(Enum, "base", base).getLlvmType(allocator, llvm_context), |
| 75 | 74 | Id.Union => return @fieldParentPtr(Union, "base", base).getLlvmType(allocator, llvm_context), |
| 76 | 75 | Id.Namespace => unreachable, |
| 77 | Id.Block => unreachable, | |
| 78 | 76 | Id.BoundFn => return @fieldParentPtr(BoundFn, "base", base).getLlvmType(allocator, llvm_context), |
| 79 | 77 | Id.ArgTuple => unreachable, |
| 80 | 78 | Id.Opaque => return @fieldParentPtr(Opaque, "base", base).getLlvmType(allocator, llvm_context), |
| ... | ... | @@ -90,7 +88,6 @@ pub const Type = struct { |
| 90 | 88 | Id.Undefined, |
| 91 | 89 | Id.Null, |
| 92 | 90 | Id.Namespace, |
| 93 | Id.Block, | |
| 94 | 91 | Id.BoundFn, |
| 95 | 92 | Id.ArgTuple, |
| 96 | 93 | Id.Opaque, |
| ... | ... | @@ -124,7 +121,6 @@ pub const Type = struct { |
| 124 | 121 | Id.Undefined, |
| 125 | 122 | Id.Null, |
| 126 | 123 | Id.Namespace, |
| 127 | Id.Block, | |
| 128 | 124 | Id.BoundFn, |
| 129 | 125 | Id.ArgTuple, |
| 130 | 126 | Id.Opaque, |
| ... | ... | @@ -1012,14 +1008,6 @@ pub const Type = struct { |
| 1012 | 1008 | } |
| 1013 | 1009 | }; |
| 1014 | 1010 | |
| 1015 | pub const Block = struct { | |
| 1016 | base: Type, | |
| 1017 | ||
| 1018 | pub fn destroy(self: *Block, comp: *Compilation) void { | |
| 1019 | comp.gpa().destroy(self); | |
| 1020 | } | |
| 1021 | }; | |
| 1022 | ||
| 1023 | 1011 | pub const BoundFn = struct { |
| 1024 | 1012 | base: Type, |
| 1025 | 1013 |
src/all_types.hpp+1-3| ... | ... | @@ -283,7 +283,6 @@ struct ConstExprValue { |
| 283 | 283 | ConstArrayValue x_array; |
| 284 | 284 | ConstPtrValue x_ptr; |
| 285 | 285 | ImportTableEntry *x_import; |
| 286 | Scope *x_block; | |
| 287 | 286 | ConstArgTuple x_arg_tuple; |
| 288 | 287 | |
| 289 | 288 | // populated if special == ConstValSpecialRuntime |
| ... | ... | @@ -413,7 +412,6 @@ enum NodeType { |
| 413 | 412 | NodeTypeBoolLiteral, |
| 414 | 413 | NodeTypeNullLiteral, |
| 415 | 414 | NodeTypeUndefinedLiteral, |
| 416 | NodeTypeThisLiteral, | |
| 417 | 415 | NodeTypeUnreachable, |
| 418 | 416 | NodeTypeIfBoolExpr, |
| 419 | 417 | NodeTypeWhileExpr, |
| ... | ... | @@ -1205,7 +1203,6 @@ enum ZigTypeId { |
| 1205 | 1203 | ZigTypeIdUnion, |
| 1206 | 1204 | ZigTypeIdFn, |
| 1207 | 1205 | ZigTypeIdNamespace, |
| 1208 | ZigTypeIdBlock, | |
| 1209 | 1206 | ZigTypeIdBoundFn, |
| 1210 | 1207 | ZigTypeIdArgTuple, |
| 1211 | 1208 | ZigTypeIdOpaque, |
| ... | ... | @@ -1413,6 +1410,7 @@ enum BuiltinFnId { |
| 1413 | 1410 | BuiltinFnIdSetEvalBranchQuota, |
| 1414 | 1411 | BuiltinFnIdAlignCast, |
| 1415 | 1412 | BuiltinFnIdOpaqueType, |
| 1413 | BuiltinFnIdThis, | |
| 1416 | 1414 | BuiltinFnIdSetAlignStack, |
| 1417 | 1415 | BuiltinFnIdArgType, |
| 1418 | 1416 | BuiltinFnIdExport, |
src/analyze.cpp+4-64| ... | ... | @@ -246,7 +246,6 @@ AstNode *type_decl_node(ZigType *type_entry) { |
| 246 | 246 | case ZigTypeIdErrorSet: |
| 247 | 247 | case ZigTypeIdFn: |
| 248 | 248 | case ZigTypeIdNamespace: |
| 249 | case ZigTypeIdBlock: | |
| 250 | 249 | case ZigTypeIdBoundFn: |
| 251 | 250 | case ZigTypeIdArgTuple: |
| 252 | 251 | case ZigTypeIdPromise: |
| ... | ... | @@ -284,7 +283,6 @@ bool type_is_complete(ZigType *type_entry) { |
| 284 | 283 | case ZigTypeIdErrorSet: |
| 285 | 284 | case ZigTypeIdFn: |
| 286 | 285 | case ZigTypeIdNamespace: |
| 287 | case ZigTypeIdBlock: | |
| 288 | 286 | case ZigTypeIdBoundFn: |
| 289 | 287 | case ZigTypeIdArgTuple: |
| 290 | 288 | case ZigTypeIdPromise: |
| ... | ... | @@ -320,7 +318,6 @@ bool type_has_zero_bits_known(ZigType *type_entry) { |
| 320 | 318 | case ZigTypeIdErrorSet: |
| 321 | 319 | case ZigTypeIdFn: |
| 322 | 320 | case ZigTypeIdNamespace: |
| 323 | case ZigTypeIdBlock: | |
| 324 | 321 | case ZigTypeIdBoundFn: |
| 325 | 322 | case ZigTypeIdArgTuple: |
| 326 | 323 | case ZigTypeIdOpaque: |
| ... | ... | @@ -1414,7 +1411,6 @@ static bool type_allowed_in_packed_struct(ZigType *type_entry) { |
| 1414 | 1411 | case ZigTypeIdErrorUnion: |
| 1415 | 1412 | case ZigTypeIdErrorSet: |
| 1416 | 1413 | case ZigTypeIdNamespace: |
| 1417 | case ZigTypeIdBlock: | |
| 1418 | 1414 | case ZigTypeIdBoundFn: |
| 1419 | 1415 | case ZigTypeIdArgTuple: |
| 1420 | 1416 | case ZigTypeIdOpaque: |
| ... | ... | @@ -1455,7 +1451,6 @@ static bool type_allowed_in_extern(CodeGen *g, ZigType *type_entry) { |
| 1455 | 1451 | case ZigTypeIdErrorUnion: |
| 1456 | 1452 | case ZigTypeIdErrorSet: |
| 1457 | 1453 | case ZigTypeIdNamespace: |
| 1458 | case ZigTypeIdBlock: | |
| 1459 | 1454 | case ZigTypeIdBoundFn: |
| 1460 | 1455 | case ZigTypeIdArgTuple: |
| 1461 | 1456 | case ZigTypeIdPromise: |
| ... | ... | @@ -1613,7 +1608,6 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc |
| 1613 | 1608 | case ZigTypeIdComptimeFloat: |
| 1614 | 1609 | case ZigTypeIdComptimeInt: |
| 1615 | 1610 | case ZigTypeIdNamespace: |
| 1616 | case ZigTypeIdBlock: | |
| 1617 | 1611 | case ZigTypeIdBoundFn: |
| 1618 | 1612 | case ZigTypeIdMetaType: |
| 1619 | 1613 | case ZigTypeIdVoid: |
| ... | ... | @@ -1703,7 +1697,6 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc |
| 1703 | 1697 | case ZigTypeIdComptimeFloat: |
| 1704 | 1698 | case ZigTypeIdComptimeInt: |
| 1705 | 1699 | case ZigTypeIdNamespace: |
| 1706 | case ZigTypeIdBlock: | |
| 1707 | 1700 | case ZigTypeIdBoundFn: |
| 1708 | 1701 | case ZigTypeIdMetaType: |
| 1709 | 1702 | case ZigTypeIdUnreachable: |
| ... | ... | @@ -3437,7 +3430,6 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) { |
| 3437 | 3430 | case NodeTypeBoolLiteral: |
| 3438 | 3431 | case NodeTypeNullLiteral: |
| 3439 | 3432 | case NodeTypeUndefinedLiteral: |
| 3440 | case NodeTypeThisLiteral: | |
| 3441 | 3433 | case NodeTypeSymbol: |
| 3442 | 3434 | case NodeTypePrefixOpExpr: |
| 3443 | 3435 | case NodeTypePointerType: |
| ... | ... | @@ -3497,7 +3489,6 @@ ZigType *validate_var_type(CodeGen *g, AstNode *source_node, ZigType *type_entry |
| 3497 | 3489 | case ZigTypeIdUnreachable: |
| 3498 | 3490 | case ZigTypeIdUndefined: |
| 3499 | 3491 | case ZigTypeIdNull: |
| 3500 | case ZigTypeIdBlock: | |
| 3501 | 3492 | case ZigTypeIdArgTuple: |
| 3502 | 3493 | case ZigTypeIdOpaque: |
| 3503 | 3494 | add_node_error(g, source_node, buf_sprintf("variable of type '%s' not allowed", |
| ... | ... | @@ -3798,34 +3789,6 @@ ZigFn *scope_fn_entry(Scope *scope) { |
| 3798 | 3789 | return nullptr; |
| 3799 | 3790 | } |
| 3800 | 3791 | |
| 3801 | ZigFn *scope_get_fn_if_root(Scope *scope) { | |
| 3802 | assert(scope); | |
| 3803 | scope = scope->parent; | |
| 3804 | while (scope) { | |
| 3805 | switch (scope->id) { | |
| 3806 | case ScopeIdBlock: | |
| 3807 | return nullptr; | |
| 3808 | case ScopeIdDecls: | |
| 3809 | case ScopeIdDefer: | |
| 3810 | case ScopeIdDeferExpr: | |
| 3811 | case ScopeIdVarDecl: | |
| 3812 | case ScopeIdCImport: | |
| 3813 | case ScopeIdLoop: | |
| 3814 | case ScopeIdSuspend: | |
| 3815 | case ScopeIdCompTime: | |
| 3816 | case ScopeIdCoroPrelude: | |
| 3817 | case ScopeIdRuntime: | |
| 3818 | scope = scope->parent; | |
| 3819 | continue; | |
| 3820 | case ScopeIdFnDef: | |
| 3821 | ScopeFnDef *fn_scope = (ScopeFnDef *)scope; | |
| 3822 | return fn_scope->fn_entry; | |
| 3823 | } | |
| 3824 | zig_unreachable(); | |
| 3825 | } | |
| 3826 | return nullptr; | |
| 3827 | } | |
| 3828 | ||
| 3829 | 3792 | TypeEnumField *find_enum_type_field(ZigType *enum_type, Buf *name) { |
| 3830 | 3793 | assert(enum_type->id == ZigTypeIdEnum); |
| 3831 | 3794 | if (enum_type->data.enumeration.src_field_count == 0) |
| ... | ... | @@ -3907,7 +3870,6 @@ static bool is_container(ZigType *type_entry) { |
| 3907 | 3870 | case ZigTypeIdErrorSet: |
| 3908 | 3871 | case ZigTypeIdFn: |
| 3909 | 3872 | case ZigTypeIdNamespace: |
| 3910 | case ZigTypeIdBlock: | |
| 3911 | 3873 | case ZigTypeIdBoundFn: |
| 3912 | 3874 | case ZigTypeIdArgTuple: |
| 3913 | 3875 | case ZigTypeIdOpaque: |
| ... | ... | @@ -3966,7 +3928,6 @@ void resolve_container_type(CodeGen *g, ZigType *type_entry) { |
| 3966 | 3928 | case ZigTypeIdErrorSet: |
| 3967 | 3929 | case ZigTypeIdFn: |
| 3968 | 3930 | case ZigTypeIdNamespace: |
| 3969 | case ZigTypeIdBlock: | |
| 3970 | 3931 | case ZigTypeIdBoundFn: |
| 3971 | 3932 | case ZigTypeIdInvalid: |
| 3972 | 3933 | case ZigTypeIdArgTuple: |
| ... | ... | @@ -4427,7 +4388,6 @@ bool handle_is_ptr(ZigType *type_entry) { |
| 4427 | 4388 | case ZigTypeIdUndefined: |
| 4428 | 4389 | case ZigTypeIdNull: |
| 4429 | 4390 | case ZigTypeIdNamespace: |
| 4430 | case ZigTypeIdBlock: | |
| 4431 | 4391 | case ZigTypeIdBoundFn: |
| 4432 | 4392 | case ZigTypeIdArgTuple: |
| 4433 | 4393 | case ZigTypeIdOpaque: |
| ... | ... | @@ -4842,8 +4802,6 @@ static uint32_t hash_const_val(ConstExprValue *const_val) { |
| 4842 | 4802 | return const_val->data.x_err_set->value ^ 2630160122; |
| 4843 | 4803 | case ZigTypeIdNamespace: |
| 4844 | 4804 | return hash_ptr(const_val->data.x_import); |
| 4845 | case ZigTypeIdBlock: | |
| 4846 | return hash_ptr(const_val->data.x_block); | |
| 4847 | 4805 | case ZigTypeIdBoundFn: |
| 4848 | 4806 | case ZigTypeIdInvalid: |
| 4849 | 4807 | case ZigTypeIdUnreachable: |
| ... | ... | @@ -4904,7 +4862,6 @@ static bool can_mutate_comptime_var_state(ConstExprValue *value) { |
| 4904 | 4862 | case ZigTypeIdNamespace: |
| 4905 | 4863 | case ZigTypeIdBoundFn: |
| 4906 | 4864 | case ZigTypeIdFn: |
| 4907 | case ZigTypeIdBlock: | |
| 4908 | 4865 | case ZigTypeIdOpaque: |
| 4909 | 4866 | case ZigTypeIdPromise: |
| 4910 | 4867 | case ZigTypeIdErrorSet: |
| ... | ... | @@ -4971,7 +4928,6 @@ static bool return_type_is_cacheable(ZigType *return_type) { |
| 4971 | 4928 | case ZigTypeIdNamespace: |
| 4972 | 4929 | case ZigTypeIdBoundFn: |
| 4973 | 4930 | case ZigTypeIdFn: |
| 4974 | case ZigTypeIdBlock: | |
| 4975 | 4931 | case ZigTypeIdOpaque: |
| 4976 | 4932 | case ZigTypeIdPromise: |
| 4977 | 4933 | case ZigTypeIdErrorSet: |
| ... | ... | @@ -5083,7 +5039,6 @@ bool type_requires_comptime(ZigType *type_entry) { |
| 5083 | 5039 | case ZigTypeIdNull: |
| 5084 | 5040 | case ZigTypeIdMetaType: |
| 5085 | 5041 | case ZigTypeIdNamespace: |
| 5086 | case ZigTypeIdBlock: | |
| 5087 | 5042 | case ZigTypeIdBoundFn: |
| 5088 | 5043 | case ZigTypeIdArgTuple: |
| 5089 | 5044 | return true; |
| ... | ... | @@ -5615,8 +5570,6 @@ bool const_values_equal(ConstExprValue *a, ConstExprValue *b) { |
| 5615 | 5570 | zig_panic("TODO"); |
| 5616 | 5571 | case ZigTypeIdNamespace: |
| 5617 | 5572 | return a->data.x_import == b->data.x_import; |
| 5618 | case ZigTypeIdBlock: | |
| 5619 | return a->data.x_block == b->data.x_block; | |
| 5620 | 5573 | case ZigTypeIdArgTuple: |
| 5621 | 5574 | return a->data.x_arg_tuple.start_index == b->data.x_arg_tuple.start_index && |
| 5622 | 5575 | a->data.x_arg_tuple.end_index == b->data.x_arg_tuple.end_index; |
| ... | ... | @@ -5795,12 +5748,6 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) { |
| 5795 | 5748 | } |
| 5796 | 5749 | case ZigTypeIdPointer: |
| 5797 | 5750 | return render_const_val_ptr(g, buf, const_val, type_entry); |
| 5798 | case ZigTypeIdBlock: | |
| 5799 | { | |
| 5800 | AstNode *node = const_val->data.x_block->source_node; | |
| 5801 | buf_appendf(buf, "(scope:%" ZIG_PRI_usize ":%" ZIG_PRI_usize ")", node->line + 1, node->column + 1); | |
| 5802 | return; | |
| 5803 | } | |
| 5804 | 5751 | case ZigTypeIdArray: |
| 5805 | 5752 | { |
| 5806 | 5753 | ZigType *child_type = type_entry->data.array.child_type; |
| ... | ... | @@ -5980,7 +5927,6 @@ uint32_t type_id_hash(TypeId x) { |
| 5980 | 5927 | case ZigTypeIdUnion: |
| 5981 | 5928 | case ZigTypeIdFn: |
| 5982 | 5929 | case ZigTypeIdNamespace: |
| 5983 | case ZigTypeIdBlock: | |
| 5984 | 5930 | case ZigTypeIdBoundFn: |
| 5985 | 5931 | case ZigTypeIdArgTuple: |
| 5986 | 5932 | case ZigTypeIdPromise: |
| ... | ... | @@ -6027,7 +5973,6 @@ bool type_id_eql(TypeId a, TypeId b) { |
| 6027 | 5973 | case ZigTypeIdUnion: |
| 6028 | 5974 | case ZigTypeIdFn: |
| 6029 | 5975 | case ZigTypeIdNamespace: |
| 6030 | case ZigTypeIdBlock: | |
| 6031 | 5976 | case ZigTypeIdBoundFn: |
| 6032 | 5977 | case ZigTypeIdArgTuple: |
| 6033 | 5978 | case ZigTypeIdOpaque: |
| ... | ... | @@ -6153,7 +6098,6 @@ static const ZigTypeId all_type_ids[] = { |
| 6153 | 6098 | ZigTypeIdUnion, |
| 6154 | 6099 | ZigTypeIdFn, |
| 6155 | 6100 | ZigTypeIdNamespace, |
| 6156 | ZigTypeIdBlock, | |
| 6157 | 6101 | ZigTypeIdBoundFn, |
| 6158 | 6102 | ZigTypeIdArgTuple, |
| 6159 | 6103 | ZigTypeIdOpaque, |
| ... | ... | @@ -6215,16 +6159,14 @@ size_t type_id_index(ZigType *entry) { |
| 6215 | 6159 | return 18; |
| 6216 | 6160 | case ZigTypeIdNamespace: |
| 6217 | 6161 | return 19; |
| 6218 | case ZigTypeIdBlock: | |
| 6219 | return 20; | |
| 6220 | 6162 | case ZigTypeIdBoundFn: |
| 6221 | return 21; | |
| 6163 | return 20; | |
| 6222 | 6164 | case ZigTypeIdArgTuple: |
| 6223 | return 22; | |
| 6165 | return 21; | |
| 6224 | 6166 | case ZigTypeIdOpaque: |
| 6225 | return 23; | |
| 6167 | return 22; | |
| 6226 | 6168 | case ZigTypeIdPromise: |
| 6227 | return 24; | |
| 6169 | return 23; | |
| 6228 | 6170 | } |
| 6229 | 6171 | zig_unreachable(); |
| 6230 | 6172 | } |
| ... | ... | @@ -6273,8 +6215,6 @@ const char *type_id_name(ZigTypeId id) { |
| 6273 | 6215 | return "Fn"; |
| 6274 | 6216 | case ZigTypeIdNamespace: |
| 6275 | 6217 | return "Namespace"; |
| 6276 | case ZigTypeIdBlock: | |
| 6277 | return "Block"; | |
| 6278 | 6218 | case ZigTypeIdBoundFn: |
| 6279 | 6219 | return "BoundFn"; |
| 6280 | 6220 | case ZigTypeIdArgTuple: |
src/analyze.hpp-1| ... | ... | @@ -87,7 +87,6 @@ ZigFn *create_fn(AstNode *proto_node); |
| 87 | 87 | ZigFn *create_fn_raw(FnInline inline_value, GlobalLinkageId linkage); |
| 88 | 88 | void init_fn_type_id(FnTypeId *fn_type_id, AstNode *proto_node, size_t param_count_alloc); |
| 89 | 89 | AstNode *get_param_decl_node(ZigFn *fn_entry, size_t index); |
| 90 | ZigFn *scope_get_fn_if_root(Scope *scope); | |
| 91 | 90 | bool type_requires_comptime(ZigType *type_entry); |
| 92 | 91 | Error ATTRIBUTE_MUST_USE ensure_complete_type(CodeGen *g, ZigType *type_entry); |
| 93 | 92 | Error ATTRIBUTE_MUST_USE type_ensure_zero_bits_known(CodeGen *g, ZigType *type_entry); |
src/ast_render.cpp-7| ... | ... | @@ -193,8 +193,6 @@ static const char *node_type_str(NodeType node_type) { |
| 193 | 193 | return "NullLiteral"; |
| 194 | 194 | case NodeTypeUndefinedLiteral: |
| 195 | 195 | return "UndefinedLiteral"; |
| 196 | case NodeTypeThisLiteral: | |
| 197 | return "ThisLiteral"; | |
| 198 | 196 | case NodeTypeIfBoolExpr: |
| 199 | 197 | return "IfBoolExpr"; |
| 200 | 198 | case NodeTypeWhileExpr: |
| ... | ... | @@ -897,11 +895,6 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) { |
| 897 | 895 | } |
| 898 | 896 | break; |
| 899 | 897 | } |
| 900 | case NodeTypeThisLiteral: | |
| 901 | { | |
| 902 | fprintf(ar->f, "this"); | |
| 903 | break; | |
| 904 | } | |
| 905 | 898 | case NodeTypeBoolLiteral: |
| 906 | 899 | { |
| 907 | 900 | const char *bool_str = node->data.bool_literal.value ? "true" : "false"; |
src/codegen.cpp+1-12| ... | ... | @@ -5479,7 +5479,6 @@ static LLVMValueRef pack_const_int(CodeGen *g, LLVMTypeRef big_int_type_ref, Con |
| 5479 | 5479 | case ZigTypeIdErrorUnion: |
| 5480 | 5480 | case ZigTypeIdErrorSet: |
| 5481 | 5481 | case ZigTypeIdNamespace: |
| 5482 | case ZigTypeIdBlock: | |
| 5483 | 5482 | case ZigTypeIdBoundFn: |
| 5484 | 5483 | case ZigTypeIdArgTuple: |
| 5485 | 5484 | case ZigTypeIdVoid: |
| ... | ... | @@ -5954,7 +5953,6 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val, const c |
| 5954 | 5953 | case ZigTypeIdUndefined: |
| 5955 | 5954 | case ZigTypeIdNull: |
| 5956 | 5955 | case ZigTypeIdNamespace: |
| 5957 | case ZigTypeIdBlock: | |
| 5958 | 5956 | case ZigTypeIdBoundFn: |
| 5959 | 5957 | case ZigTypeIdArgTuple: |
| 5960 | 5958 | case ZigTypeIdOpaque: |
| ... | ... | @@ -6477,12 +6475,6 @@ static void define_builtin_types(CodeGen *g) { |
| 6477 | 6475 | entry->zero_bits = true; |
| 6478 | 6476 | g->builtin_types.entry_namespace = entry; |
| 6479 | 6477 | } |
| 6480 | { | |
| 6481 | ZigType *entry = new_type_table_entry(ZigTypeIdBlock); | |
| 6482 | buf_init_from_str(&entry->name, "(block)"); | |
| 6483 | entry->zero_bits = true; | |
| 6484 | g->builtin_types.entry_block = entry; | |
| 6485 | } | |
| 6486 | 6478 | { |
| 6487 | 6479 | ZigType *entry = new_type_table_entry(ZigTypeIdComptimeFloat); |
| 6488 | 6480 | buf_init_from_str(&entry->name, "comptime_float"); |
| ... | ... | @@ -6763,6 +6755,7 @@ static void define_builtin_fns(CodeGen *g) { |
| 6763 | 6755 | create_builtin_fn(g, BuiltinFnIdErrSetCast, "errSetCast", 2); |
| 6764 | 6756 | create_builtin_fn(g, BuiltinFnIdToBytes, "sliceToBytes", 1); |
| 6765 | 6757 | create_builtin_fn(g, BuiltinFnIdFromBytes, "bytesToSlice", 2); |
| 6758 | create_builtin_fn(g, BuiltinFnIdThis, "This", 0); | |
| 6766 | 6759 | } |
| 6767 | 6760 | |
| 6768 | 6761 | static const char *bool_to_str(bool b) { |
| ... | ... | @@ -6944,7 +6937,6 @@ Buf *codegen_generate_builtin_source(CodeGen *g) { |
| 6944 | 6937 | " Union: Union,\n" |
| 6945 | 6938 | " Fn: Fn,\n" |
| 6946 | 6939 | " Namespace: void,\n" |
| 6947 | " Block: void,\n" | |
| 6948 | 6940 | " BoundFn: Fn,\n" |
| 6949 | 6941 | " ArgTuple: void,\n" |
| 6950 | 6942 | " Opaque: void,\n" |
| ... | ... | @@ -7589,7 +7581,6 @@ static void prepend_c_type_to_decl_list(CodeGen *g, GenH *gen_h, ZigType *type_e |
| 7589 | 7581 | case ZigTypeIdUndefined: |
| 7590 | 7582 | case ZigTypeIdNull: |
| 7591 | 7583 | case ZigTypeIdNamespace: |
| 7592 | case ZigTypeIdBlock: | |
| 7593 | 7584 | case ZigTypeIdBoundFn: |
| 7594 | 7585 | case ZigTypeIdArgTuple: |
| 7595 | 7586 | case ZigTypeIdErrorUnion: |
| ... | ... | @@ -7768,7 +7759,6 @@ static void get_c_type(CodeGen *g, GenH *gen_h, ZigType *type_entry, Buf *out_bu |
| 7768 | 7759 | case ZigTypeIdMetaType: |
| 7769 | 7760 | case ZigTypeIdBoundFn: |
| 7770 | 7761 | case ZigTypeIdNamespace: |
| 7771 | case ZigTypeIdBlock: | |
| 7772 | 7762 | case ZigTypeIdComptimeFloat: |
| 7773 | 7763 | case ZigTypeIdComptimeInt: |
| 7774 | 7764 | case ZigTypeIdUndefined: |
| ... | ... | @@ -7921,7 +7911,6 @@ static void gen_h_file(CodeGen *g) { |
| 7921 | 7911 | case ZigTypeIdErrorUnion: |
| 7922 | 7912 | case ZigTypeIdErrorSet: |
| 7923 | 7913 | case ZigTypeIdNamespace: |
| 7924 | case ZigTypeIdBlock: | |
| 7925 | 7914 | case ZigTypeIdBoundFn: |
| 7926 | 7915 | case ZigTypeIdArgTuple: |
| 7927 | 7916 | case ZigTypeIdOptional: |
src/ir.cpp+20-61| ... | ... | @@ -1029,12 +1029,6 @@ static IrInstruction *ir_create_const_fn(IrBuilder *irb, Scope *scope, AstNode * |
| 1029 | 1029 | return &const_instruction->base; |
| 1030 | 1030 | } |
| 1031 | 1031 | |
| 1032 | static IrInstruction *ir_build_const_fn(IrBuilder *irb, Scope *scope, AstNode *source_node, ZigFn *fn_entry) { | |
| 1033 | IrInstruction *instruction = ir_create_const_fn(irb, scope, source_node, fn_entry); | |
| 1034 | ir_instruction_append(irb->current_basic_block, instruction); | |
| 1035 | return instruction; | |
| 1036 | } | |
| 1037 | ||
| 1038 | 1032 | static IrInstruction *ir_build_const_import(IrBuilder *irb, Scope *scope, AstNode *source_node, ImportTableEntry *import) { |
| 1039 | 1033 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); |
| 1040 | 1034 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_namespace; |
| ... | ... | @@ -1043,16 +1037,6 @@ static IrInstruction *ir_build_const_import(IrBuilder *irb, Scope *scope, AstNod |
| 1043 | 1037 | return &const_instruction->base; |
| 1044 | 1038 | } |
| 1045 | 1039 | |
| 1046 | static IrInstruction *ir_build_const_scope(IrBuilder *irb, Scope *parent_scope, AstNode *source_node, | |
| 1047 | Scope *target_scope) | |
| 1048 | { | |
| 1049 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, parent_scope, source_node); | |
| 1050 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_block; | |
| 1051 | const_instruction->base.value.special = ConstValSpecialStatic; | |
| 1052 | const_instruction->base.value.data.x_block = target_scope; | |
| 1053 | return &const_instruction->base; | |
| 1054 | } | |
| 1055 | ||
| 1056 | 1040 | static IrInstruction *ir_build_const_bool(IrBuilder *irb, Scope *scope, AstNode *source_node, bool value) { |
| 1057 | 1041 | IrInstructionConst *const_instruction = ir_build_instruction<IrInstructionConst>(irb, scope, source_node); |
| 1058 | 1042 | const_instruction->base.value.type = irb->codegen->builtin_types.entry_bool; |
| ... | ... | @@ -3892,6 +3876,21 @@ static IrInstruction *ir_gen_overflow_op(IrBuilder *irb, Scope *scope, AstNode * |
| 3892 | 3876 | return ir_build_overflow_op(irb, scope, node, op, type_value, op1, op2, result_ptr, nullptr); |
| 3893 | 3877 | } |
| 3894 | 3878 | |
| 3879 | static IrInstruction *ir_gen_this(IrBuilder *irb, Scope *orig_scope, AstNode *node) { | |
| 3880 | for (Scope *it_scope = orig_scope; it_scope != nullptr; it_scope = it_scope->parent) { | |
| 3881 | if (it_scope->id == ScopeIdDecls) { | |
| 3882 | ScopeDecls *decls_scope = (ScopeDecls *)it_scope; | |
| 3883 | ZigType *container_type = decls_scope->container_type; | |
| 3884 | if (container_type != nullptr) { | |
| 3885 | return ir_build_const_type(irb, orig_scope, node, container_type); | |
| 3886 | } else { | |
| 3887 | return ir_build_const_import(irb, orig_scope, node, decls_scope->import); | |
| 3888 | } | |
| 3889 | } | |
| 3890 | } | |
| 3891 | zig_unreachable(); | |
| 3892 | } | |
| 3893 | ||
| 3895 | 3894 | static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNode *node, LVal lval) { |
| 3896 | 3895 | assert(node->type == NodeTypeFnCallExpr); |
| 3897 | 3896 | |
| ... | ... | @@ -4830,6 +4829,11 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 4830 | 4829 | IrInstruction *opaque_type = ir_build_opaque_type(irb, scope, node); |
| 4831 | 4830 | return ir_lval_wrap(irb, scope, opaque_type, lval); |
| 4832 | 4831 | } |
| 4832 | case BuiltinFnIdThis: | |
| 4833 | { | |
| 4834 | IrInstruction *this_inst = ir_gen_this(irb, scope, node); | |
| 4835 | return ir_lval_wrap(irb, scope, this_inst, lval); | |
| 4836 | } | |
| 4833 | 4837 | case BuiltinFnIdSetAlignStack: |
| 4834 | 4838 | { |
| 4835 | 4839 | AstNode *arg0_node = node->data.fn_call_expr.params.at(0); |
| ... | ... | @@ -5681,33 +5685,6 @@ static IrInstruction *ir_gen_for_expr(IrBuilder *irb, Scope *parent_scope, AstNo |
| 5681 | 5685 | return ir_build_phi(irb, parent_scope, node, incoming_blocks.length, incoming_blocks.items, incoming_values.items); |
| 5682 | 5686 | } |
| 5683 | 5687 | |
| 5684 | static IrInstruction *ir_gen_this_literal(IrBuilder *irb, Scope *scope, AstNode *node) { | |
| 5685 | assert(node->type == NodeTypeThisLiteral); | |
| 5686 | ||
| 5687 | if (!scope->parent) | |
| 5688 | return ir_build_const_import(irb, scope, node, node->owner); | |
| 5689 | ||
| 5690 | ZigFn *fn_entry = scope_get_fn_if_root(scope); | |
| 5691 | if (fn_entry) | |
| 5692 | return ir_build_const_fn(irb, scope, node, fn_entry); | |
| 5693 | ||
| 5694 | while (scope->id != ScopeIdBlock && scope->id != ScopeIdDecls) { | |
| 5695 | scope = scope->parent; | |
| 5696 | } | |
| 5697 | ||
| 5698 | if (scope->id == ScopeIdDecls) { | |
| 5699 | ScopeDecls *decls_scope = (ScopeDecls *)scope; | |
| 5700 | ZigType *container_type = decls_scope->container_type; | |
| 5701 | assert(container_type); | |
| 5702 | return ir_build_const_type(irb, scope, node, container_type); | |
| 5703 | } | |
| 5704 | ||
| 5705 | if (scope->id == ScopeIdBlock) | |
| 5706 | return ir_build_const_scope(irb, scope, node, scope); | |
| 5707 | ||
| 5708 | zig_unreachable(); | |
| 5709 | } | |
| 5710 | ||
| 5711 | 5688 | static IrInstruction *ir_gen_bool_literal(IrBuilder *irb, Scope *scope, AstNode *node) { |
| 5712 | 5689 | assert(node->type == NodeTypeBoolLiteral); |
| 5713 | 5690 | return ir_build_const_bool(irb, scope, node, node->data.bool_literal.value); |
| ... | ... | @@ -7285,8 +7262,6 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop |
| 7285 | 7262 | |
| 7286 | 7263 | return ir_build_load_ptr(irb, scope, node, unwrapped_ptr); |
| 7287 | 7264 | } |
| 7288 | case NodeTypeThisLiteral: | |
| 7289 | return ir_lval_wrap(irb, scope, ir_gen_this_literal(irb, scope, node), lval); | |
| 7290 | 7265 | case NodeTypeBoolLiteral: |
| 7291 | 7266 | return ir_lval_wrap(irb, scope, ir_gen_bool_literal(irb, scope, node), lval); |
| 7292 | 7267 | case NodeTypeArrayType: |
| ... | ... | @@ -11621,7 +11596,6 @@ static ZigType *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp *bin_op |
| 11621 | 11596 | case ZigTypeIdFn: |
| 11622 | 11597 | case ZigTypeIdOpaque: |
| 11623 | 11598 | case ZigTypeIdNamespace: |
| 11624 | case ZigTypeIdBlock: | |
| 11625 | 11599 | case ZigTypeIdBoundFn: |
| 11626 | 11600 | case ZigTypeIdArgTuple: |
| 11627 | 11601 | case ZigTypeIdPromise: |
| ... | ... | @@ -12822,7 +12796,6 @@ static ZigType *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExpor |
| 12822 | 12796 | case ZigTypeIdErrorUnion: |
| 12823 | 12797 | case ZigTypeIdErrorSet: |
| 12824 | 12798 | case ZigTypeIdNamespace: |
| 12825 | case ZigTypeIdBlock: | |
| 12826 | 12799 | case ZigTypeIdBoundFn: |
| 12827 | 12800 | case ZigTypeIdArgTuple: |
| 12828 | 12801 | case ZigTypeIdOpaque: |
| ... | ... | @@ -12847,7 +12820,6 @@ static ZigType *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructionExpor |
| 12847 | 12820 | case ZigTypeIdErrorSet: |
| 12848 | 12821 | zig_panic("TODO export const value of type %s", buf_ptr(&target->value.type->name)); |
| 12849 | 12822 | case ZigTypeIdNamespace: |
| 12850 | case ZigTypeIdBlock: | |
| 12851 | 12823 | case ZigTypeIdBoundFn: |
| 12852 | 12824 | case ZigTypeIdArgTuple: |
| 12853 | 12825 | case ZigTypeIdOpaque: |
| ... | ... | @@ -13905,7 +13877,6 @@ static ZigType *ir_analyze_maybe(IrAnalyze *ira, IrInstructionUnOp *un_op_instru |
| 13905 | 13877 | case ZigTypeIdUnion: |
| 13906 | 13878 | case ZigTypeIdFn: |
| 13907 | 13879 | case ZigTypeIdNamespace: |
| 13908 | case ZigTypeIdBlock: | |
| 13909 | 13880 | case ZigTypeIdBoundFn: |
| 13910 | 13881 | case ZigTypeIdArgTuple: |
| 13911 | 13882 | case ZigTypeIdPromise: |
| ... | ... | @@ -15263,7 +15234,6 @@ static ZigType *ir_analyze_instruction_typeof(IrAnalyze *ira, IrInstructionTypeO |
| 15263 | 15234 | case ZigTypeIdUndefined: |
| 15264 | 15235 | case ZigTypeIdNull: |
| 15265 | 15236 | case ZigTypeIdNamespace: |
| 15266 | case ZigTypeIdBlock: | |
| 15267 | 15237 | case ZigTypeIdBoundFn: |
| 15268 | 15238 | case ZigTypeIdMetaType: |
| 15269 | 15239 | case ZigTypeIdVoid: |
| ... | ... | @@ -15516,7 +15486,6 @@ static ZigType *ir_analyze_instruction_slice_type(IrAnalyze *ira, |
| 15516 | 15486 | case ZigTypeIdUnreachable: |
| 15517 | 15487 | case ZigTypeIdUndefined: |
| 15518 | 15488 | case ZigTypeIdNull: |
| 15519 | case ZigTypeIdBlock: | |
| 15520 | 15489 | case ZigTypeIdArgTuple: |
| 15521 | 15490 | case ZigTypeIdOpaque: |
| 15522 | 15491 | ir_add_error_node(ira, slice_type_instruction->base.source_node, |
| ... | ... | @@ -15627,7 +15596,6 @@ static ZigType *ir_analyze_instruction_array_type(IrAnalyze *ira, |
| 15627 | 15596 | case ZigTypeIdUnreachable: |
| 15628 | 15597 | case ZigTypeIdUndefined: |
| 15629 | 15598 | case ZigTypeIdNull: |
| 15630 | case ZigTypeIdBlock: | |
| 15631 | 15599 | case ZigTypeIdArgTuple: |
| 15632 | 15600 | case ZigTypeIdOpaque: |
| 15633 | 15601 | ir_add_error_node(ira, array_type_instruction->base.source_node, |
| ... | ... | @@ -15698,7 +15666,6 @@ static ZigType *ir_analyze_instruction_size_of(IrAnalyze *ira, |
| 15698 | 15666 | case ZigTypeIdUnreachable: |
| 15699 | 15667 | case ZigTypeIdUndefined: |
| 15700 | 15668 | case ZigTypeIdNull: |
| 15701 | case ZigTypeIdBlock: | |
| 15702 | 15669 | case ZigTypeIdComptimeFloat: |
| 15703 | 15670 | case ZigTypeIdComptimeInt: |
| 15704 | 15671 | case ZigTypeIdBoundFn: |
| ... | ... | @@ -16184,7 +16151,6 @@ static ZigType *ir_analyze_instruction_switch_target(IrAnalyze *ira, |
| 16184 | 16151 | case ZigTypeIdUndefined: |
| 16185 | 16152 | case ZigTypeIdNull: |
| 16186 | 16153 | case ZigTypeIdOptional: |
| 16187 | case ZigTypeIdBlock: | |
| 16188 | 16154 | case ZigTypeIdBoundFn: |
| 16189 | 16155 | case ZigTypeIdArgTuple: |
| 16190 | 16156 | case ZigTypeIdOpaque: |
| ... | ... | @@ -16705,7 +16671,6 @@ static ZigType *ir_analyze_min_max(IrAnalyze *ira, IrInstruction *source_instruc |
| 16705 | 16671 | case ZigTypeIdUnion: |
| 16706 | 16672 | case ZigTypeIdFn: |
| 16707 | 16673 | case ZigTypeIdNamespace: |
| 16708 | case ZigTypeIdBlock: | |
| 16709 | 16674 | case ZigTypeIdBoundFn: |
| 16710 | 16675 | case ZigTypeIdArgTuple: |
| 16711 | 16676 | case ZigTypeIdOpaque: |
| ... | ... | @@ -17368,7 +17333,6 @@ static Error ir_make_type_info_value(IrAnalyze *ira, ZigType *type_entry, ConstE |
| 17368 | 17333 | case ZigTypeIdUndefined: |
| 17369 | 17334 | case ZigTypeIdNull: |
| 17370 | 17335 | case ZigTypeIdNamespace: |
| 17371 | case ZigTypeIdBlock: | |
| 17372 | 17336 | case ZigTypeIdArgTuple: |
| 17373 | 17337 | case ZigTypeIdOpaque: |
| 17374 | 17338 | *out = nullptr; |
| ... | ... | @@ -19341,7 +19305,6 @@ static ZigType *ir_analyze_instruction_align_of(IrAnalyze *ira, IrInstructionAli |
| 19341 | 19305 | case ZigTypeIdUndefined: |
| 19342 | 19306 | case ZigTypeIdNull: |
| 19343 | 19307 | case ZigTypeIdNamespace: |
| 19344 | case ZigTypeIdBlock: | |
| 19345 | 19308 | case ZigTypeIdBoundFn: |
| 19346 | 19309 | case ZigTypeIdArgTuple: |
| 19347 | 19310 | case ZigTypeIdVoid: |
| ... | ... | @@ -20102,7 +20065,6 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue |
| 20102 | 20065 | case ZigTypeIdBoundFn: |
| 20103 | 20066 | case ZigTypeIdArgTuple: |
| 20104 | 20067 | case ZigTypeIdNamespace: |
| 20105 | case ZigTypeIdBlock: | |
| 20106 | 20068 | case ZigTypeIdUnreachable: |
| 20107 | 20069 | case ZigTypeIdComptimeFloat: |
| 20108 | 20070 | case ZigTypeIdComptimeInt: |
| ... | ... | @@ -20169,7 +20131,6 @@ static void buf_read_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue |
| 20169 | 20131 | case ZigTypeIdBoundFn: |
| 20170 | 20132 | case ZigTypeIdArgTuple: |
| 20171 | 20133 | case ZigTypeIdNamespace: |
| 20172 | case ZigTypeIdBlock: | |
| 20173 | 20134 | case ZigTypeIdUnreachable: |
| 20174 | 20135 | case ZigTypeIdComptimeFloat: |
| 20175 | 20136 | case ZigTypeIdComptimeInt: |
| ... | ... | @@ -20249,7 +20210,6 @@ static ZigType *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstructionBit |
| 20249 | 20210 | case ZigTypeIdBoundFn: |
| 20250 | 20211 | case ZigTypeIdArgTuple: |
| 20251 | 20212 | case ZigTypeIdNamespace: |
| 20252 | case ZigTypeIdBlock: | |
| 20253 | 20213 | case ZigTypeIdUnreachable: |
| 20254 | 20214 | case ZigTypeIdComptimeFloat: |
| 20255 | 20215 | case ZigTypeIdComptimeInt: |
| ... | ... | @@ -20275,7 +20235,6 @@ static ZigType *ir_analyze_instruction_bit_cast(IrAnalyze *ira, IrInstructionBit |
| 20275 | 20235 | case ZigTypeIdBoundFn: |
| 20276 | 20236 | case ZigTypeIdArgTuple: |
| 20277 | 20237 | case ZigTypeIdNamespace: |
| 20278 | case ZigTypeIdBlock: | |
| 20279 | 20238 | case ZigTypeIdUnreachable: |
| 20280 | 20239 | case ZigTypeIdComptimeFloat: |
| 20281 | 20240 | case ZigTypeIdComptimeInt: |
src/parser.cpp+1-8| ... | ... | @@ -700,7 +700,7 @@ static AstNode *ast_parse_comptime_expr(ParseContext *pc, size_t *token_index, b |
| 700 | 700 | |
| 701 | 701 | /* |
| 702 | 702 | PrimaryExpression = Integer | Float | String | CharLiteral | KeywordLiteral | GroupedExpression | BlockExpression(BlockOrExpression) | Symbol | ("@" Symbol FnCallExpression) | ArrayType | FnProto | AsmExpression | ContainerDecl | ("continue" option(":" Symbol)) | ErrorSetDecl | PromiseType |
| 703 | KeywordLiteral = "true" | "false" | "null" | "undefined" | "error" | "this" | "unreachable" | "suspend" | |
| 703 | KeywordLiteral = "true" | "false" | "null" | "undefined" | "error" | "unreachable" | "suspend" | |
| 704 | 704 | ErrorSetDecl = "error" "{" list(Symbol, ",") "}" |
| 705 | 705 | */ |
| 706 | 706 | static AstNode *ast_parse_primary_expr(ParseContext *pc, size_t *token_index, bool mandatory) { |
| ... | ... | @@ -756,10 +756,6 @@ static AstNode *ast_parse_primary_expr(ParseContext *pc, size_t *token_index, bo |
| 756 | 756 | AstNode *node = ast_create_node(pc, NodeTypeUndefinedLiteral, token); |
| 757 | 757 | *token_index += 1; |
| 758 | 758 | return node; |
| 759 | } else if (token->id == TokenIdKeywordThis) { | |
| 760 | AstNode *node = ast_create_node(pc, NodeTypeThisLiteral, token); | |
| 761 | *token_index += 1; | |
| 762 | return node; | |
| 763 | 759 | } else if (token->id == TokenIdKeywordUnreachable) { |
| 764 | 760 | AstNode *node = ast_create_node(pc, NodeTypeUnreachable, token); |
| 765 | 761 | *token_index += 1; |
| ... | ... | @@ -3021,9 +3017,6 @@ void ast_visit_node_children(AstNode *node, void (*visit)(AstNode **, void *cont |
| 3021 | 3017 | case NodeTypeUndefinedLiteral: |
| 3022 | 3018 | // none |
| 3023 | 3019 | break; |
| 3024 | case NodeTypeThisLiteral: | |
| 3025 | // none | |
| 3026 | break; | |
| 3027 | 3020 | case NodeTypeIfBoolExpr: |
| 3028 | 3021 | visit_field(&node->data.if_bool_expr.condition, visit, context); |
| 3029 | 3022 | visit_field(&node->data.if_bool_expr.then_block, visit, context); |
src/tokenizer.cpp-2| ... | ... | @@ -146,7 +146,6 @@ static const struct ZigKeyword zig_keywords[] = { |
| 146 | 146 | {"suspend", TokenIdKeywordSuspend}, |
| 147 | 147 | {"switch", TokenIdKeywordSwitch}, |
| 148 | 148 | {"test", TokenIdKeywordTest}, |
| 149 | {"this", TokenIdKeywordThis}, | |
| 150 | 149 | {"true", TokenIdKeywordTrue}, |
| 151 | 150 | {"try", TokenIdKeywordTry}, |
| 152 | 151 | {"undefined", TokenIdKeywordUndefined}, |
| ... | ... | @@ -1588,7 +1587,6 @@ const char * token_name(TokenId id) { |
| 1588 | 1587 | case TokenIdKeywordStruct: return "struct"; |
| 1589 | 1588 | case TokenIdKeywordSwitch: return "switch"; |
| 1590 | 1589 | case TokenIdKeywordTest: return "test"; |
| 1591 | case TokenIdKeywordThis: return "this"; | |
| 1592 | 1590 | case TokenIdKeywordTrue: return "true"; |
| 1593 | 1591 | case TokenIdKeywordTry: return "try"; |
| 1594 | 1592 | case TokenIdKeywordUndefined: return "undefined"; |
src/tokenizer.hpp-1| ... | ... | @@ -87,7 +87,6 @@ enum TokenId { |
| 87 | 87 | TokenIdKeywordSuspend, |
| 88 | 88 | TokenIdKeywordSwitch, |
| 89 | 89 | TokenIdKeywordTest, |
| 90 | TokenIdKeywordThis, | |
| 91 | 90 | TokenIdKeywordTrue, |
| 92 | 91 | TokenIdKeywordTry, |
| 93 | 92 | TokenIdKeywordUndefined, |
std/array_list.zig+1-1| ... | ... | @@ -11,7 +11,7 @@ pub fn ArrayList(comptime T: type) type { |
| 11 | 11 | |
| 12 | 12 | pub fn AlignedArrayList(comptime T: type, comptime A: u29) type { |
| 13 | 13 | return struct { |
| 14 | const Self = this; | |
| 14 | const Self = @This(); | |
| 15 | 15 | |
| 16 | 16 | /// Use toSlice instead of slicing this directly, because if you don't |
| 17 | 17 | /// specify the end position of the slice, this will potentially give |
std/atomic/int.zig+1-1| ... | ... | @@ -6,7 +6,7 @@ pub fn Int(comptime T: type) type { |
| 6 | 6 | return struct { |
| 7 | 7 | unprotected_value: T, |
| 8 | 8 | |
| 9 | pub const Self = this; | |
| 9 | pub const Self = @This(); | |
| 10 | 10 | |
| 11 | 11 | pub fn init(init_val: T) Self { |
| 12 | 12 | return Self{ .unprotected_value = init_val }; |
std/atomic/queue.zig+1-1| ... | ... | @@ -12,7 +12,7 @@ pub fn Queue(comptime T: type) type { |
| 12 | 12 | tail: ?*Node, |
| 13 | 13 | mutex: std.Mutex, |
| 14 | 14 | |
| 15 | pub const Self = this; | |
| 15 | pub const Self = @This(); | |
| 16 | 16 | pub const Node = std.LinkedList(T).Node; |
| 17 | 17 | |
| 18 | 18 | pub fn init() Self { |
std/atomic/stack.zig+1-1| ... | ... | @@ -9,7 +9,7 @@ pub fn Stack(comptime T: type) type { |
| 9 | 9 | root: ?*Node, |
| 10 | 10 | lock: u8, |
| 11 | 11 | |
| 12 | pub const Self = this; | |
| 12 | pub const Self = @This(); | |
| 13 | 13 | |
| 14 | 14 | pub const Node = struct { |
| 15 | 15 | next: ?*Node, |
std/build.zig+1-1| ... | ... | @@ -1890,7 +1890,7 @@ const InstallArtifactStep = struct { |
| 1890 | 1890 | artifact: *LibExeObjStep, |
| 1891 | 1891 | dest_file: []const u8, |
| 1892 | 1892 | |
| 1893 | const Self = this; | |
| 1893 | const Self = @This(); | |
| 1894 | 1894 | |
| 1895 | 1895 | pub fn create(builder: *Builder, artifact: *LibExeObjStep) *Self { |
| 1896 | 1896 | const dest_dir = switch (artifact.kind) { |
std/crypto/blake2.zig+2-2| ... | ... | @@ -33,7 +33,7 @@ pub const Blake2s256 = Blake2s(256); |
| 33 | 33 | |
| 34 | 34 | fn Blake2s(comptime out_len: usize) type { |
| 35 | 35 | return struct { |
| 36 | const Self = this; | |
| 36 | const Self = @This(); | |
| 37 | 37 | const block_length = 64; |
| 38 | 38 | const digest_length = out_len / 8; |
| 39 | 39 | |
| ... | ... | @@ -266,7 +266,7 @@ pub const Blake2b512 = Blake2b(512); |
| 266 | 266 | |
| 267 | 267 | fn Blake2b(comptime out_len: usize) type { |
| 268 | 268 | return struct { |
| 269 | const Self = this; | |
| 269 | const Self = @This(); | |
| 270 | 270 | const block_length = 128; |
| 271 | 271 | const digest_length = out_len / 8; |
| 272 | 272 |
std/crypto/hmac.zig+1-1| ... | ... | @@ -9,7 +9,7 @@ pub const HmacSha256 = Hmac(crypto.Sha256); |
| 9 | 9 | |
| 10 | 10 | pub fn Hmac(comptime Hash: type) type { |
| 11 | 11 | return struct { |
| 12 | const Self = this; | |
| 12 | const Self = @This(); | |
| 13 | 13 | pub const mac_length = Hash.digest_length; |
| 14 | 14 | pub const minimum_key_length = 0; |
| 15 | 15 |
std/crypto/md5.zig+1-1| ... | ... | @@ -28,7 +28,7 @@ fn Rp(a: usize, b: usize, c: usize, d: usize, k: usize, s: u32, t: u32) RoundPar |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | pub const Md5 = struct { |
| 31 | const Self = this; | |
| 31 | const Self = @This(); | |
| 32 | 32 | const block_length = 64; |
| 33 | 33 | const digest_length = 16; |
| 34 | 34 |
std/crypto/poly1305.zig+1-1| ... | ... | @@ -10,7 +10,7 @@ const readInt = std.mem.readInt; |
| 10 | 10 | const writeInt = std.mem.writeInt; |
| 11 | 11 | |
| 12 | 12 | pub const Poly1305 = struct { |
| 13 | const Self = this; | |
| 13 | const Self = @This(); | |
| 14 | 14 | |
| 15 | 15 | pub const mac_length = 16; |
| 16 | 16 | pub const minimum_key_length = 32; |
std/crypto/sha1.zig+1-1| ... | ... | @@ -25,7 +25,7 @@ fn Rp(a: usize, b: usize, c: usize, d: usize, e: usize, i: u32) RoundParam { |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | pub const Sha1 = struct { |
| 28 | const Self = this; | |
| 28 | const Self = @This(); | |
| 29 | 29 | const block_length = 64; |
| 30 | 30 | const digest_length = 20; |
| 31 | 31 |
std/crypto/sha2.zig+2-2| ... | ... | @@ -77,7 +77,7 @@ pub const Sha256 = Sha2_32(Sha256Params); |
| 77 | 77 | |
| 78 | 78 | fn Sha2_32(comptime params: Sha2Params32) type { |
| 79 | 79 | return struct { |
| 80 | const Self = this; | |
| 80 | const Self = @This(); | |
| 81 | 81 | const block_length = 64; |
| 82 | 82 | const digest_length = params.out_len / 8; |
| 83 | 83 | |
| ... | ... | @@ -418,7 +418,7 @@ pub const Sha512 = Sha2_64(Sha512Params); |
| 418 | 418 | |
| 419 | 419 | fn Sha2_64(comptime params: Sha2Params64) type { |
| 420 | 420 | return struct { |
| 421 | const Self = this; | |
| 421 | const Self = @This(); | |
| 422 | 422 | const block_length = 128; |
| 423 | 423 | const digest_length = params.out_len / 8; |
| 424 | 424 |
std/crypto/sha3.zig+1-1| ... | ... | @@ -12,7 +12,7 @@ pub const Sha3_512 = Keccak(512, 0x06); |
| 12 | 12 | |
| 13 | 13 | fn Keccak(comptime bits: usize, comptime delim: u8) type { |
| 14 | 14 | return struct { |
| 15 | const Self = this; | |
| 15 | const Self = @This(); | |
| 16 | 16 | const block_length = 200; |
| 17 | 17 | const digest_length = bits / 8; |
| 18 | 18 |
std/event/channel.zig+1-1| ... | ... | @@ -25,7 +25,7 @@ pub fn Channel(comptime T: type) type { |
| 25 | 25 | buffer_index: usize, |
| 26 | 26 | buffer_len: usize, |
| 27 | 27 | |
| 28 | const SelfChannel = this; | |
| 28 | const SelfChannel = @This(); | |
| 29 | 29 | const GetNode = struct { |
| 30 | 30 | tick_node: *Loop.NextTickNode, |
| 31 | 31 | data: Data, |
std/event/fs.zig+1-1| ... | ... | @@ -724,7 +724,7 @@ pub fn Watch(comptime V: type) type { |
| 724 | 724 | |
| 725 | 725 | const FileToHandle = std.AutoHashMap([]const u8, promise); |
| 726 | 726 | |
| 727 | const Self = this; | |
| 727 | const Self = @This(); | |
| 728 | 728 | |
| 729 | 729 | pub const Event = struct { |
| 730 | 730 | id: Id, |
std/event/future.zig+1-1| ... | ... | @@ -21,7 +21,7 @@ pub fn Future(comptime T: type) type { |
| 21 | 21 | /// 2 - finished |
| 22 | 22 | available: u8, |
| 23 | 23 | |
| 24 | const Self = this; | |
| 24 | const Self = @This(); | |
| 25 | 25 | const Queue = std.atomic.Queue(promise); |
| 26 | 26 | |
| 27 | 27 | pub fn init(loop: *Loop) Self { |
std/event/group.zig+1-1| ... | ... | @@ -13,7 +13,7 @@ pub fn Group(comptime ReturnType: type) type { |
| 13 | 13 | alloc_stack: Stack, |
| 14 | 14 | lock: Lock, |
| 15 | 15 | |
| 16 | const Self = this; | |
| 16 | const Self = @This(); | |
| 17 | 17 | |
| 18 | 18 | const Error = switch (@typeInfo(ReturnType)) { |
| 19 | 19 | builtin.TypeId.ErrorUnion => |payload| payload.error_set, |
std/event/locked.zig+1-1| ... | ... | @@ -10,7 +10,7 @@ pub fn Locked(comptime T: type) type { |
| 10 | 10 | lock: Lock, |
| 11 | 11 | private_data: T, |
| 12 | 12 | |
| 13 | const Self = this; | |
| 13 | const Self = @This(); | |
| 14 | 14 | |
| 15 | 15 | pub const HeldLock = struct { |
| 16 | 16 | value: *T, |
std/event/rwlocked.zig+1-1| ... | ... | @@ -10,7 +10,7 @@ pub fn RwLocked(comptime T: type) type { |
| 10 | 10 | lock: RwLock, |
| 11 | 11 | locked_data: T, |
| 12 | 12 | |
| 13 | const Self = this; | |
| 13 | const Self = @This(); | |
| 14 | 14 | |
| 15 | 15 | pub const HeldReadLock = struct { |
| 16 | 16 | value: *const T, |
std/event/tcp.zig+1-1| ... | ... | @@ -132,7 +132,7 @@ test "listen on a port, send bytes, receive bytes" { |
| 132 | 132 | const MyServer = struct { |
| 133 | 133 | tcp_server: Server, |
| 134 | 134 | |
| 135 | const Self = this; | |
| 135 | const Self = @This(); | |
| 136 | 136 | async<*mem.Allocator> fn handler(tcp_server: *Server, _addr: *const std.net.Address, _socket: *const std.os.File) void { |
| 137 | 137 | const self = @fieldParentPtr(Self, "tcp_server", tcp_server); |
| 138 | 138 | var socket = _socket.*; // TODO https://github.com/ziglang/zig/issues/733 |
std/fmt/index.zig+1-1| ... | ... | @@ -1183,7 +1183,7 @@ test "fmt.format" { |
| 1183 | 1183 | //custom type format |
| 1184 | 1184 | { |
| 1185 | 1185 | const Vec2 = struct { |
| 1186 | const SelfType = this; | |
| 1186 | const SelfType = @This(); | |
| 1187 | 1187 | x: f32, |
| 1188 | 1188 | y: f32, |
| 1189 | 1189 |
std/hash/crc.zig+2-2| ... | ... | @@ -20,7 +20,7 @@ pub const Crc32 = Crc32WithPoly(Polynomial.IEEE); |
| 20 | 20 | // slicing-by-8 crc32 implementation. |
| 21 | 21 | pub fn Crc32WithPoly(comptime poly: u32) type { |
| 22 | 22 | return struct { |
| 23 | const Self = this; | |
| 23 | const Self = @This(); | |
| 24 | 24 | const lookup_tables = comptime block: { |
| 25 | 25 | @setEvalBranchQuota(20000); |
| 26 | 26 | var tables: [8][256]u32 = undefined; |
| ... | ... | @@ -117,7 +117,7 @@ test "crc32 castagnoli" { |
| 117 | 117 | // half-byte lookup table implementation. |
| 118 | 118 | pub fn Crc32SmallWithPoly(comptime poly: u32) type { |
| 119 | 119 | return struct { |
| 120 | const Self = this; | |
| 120 | const Self = @This(); | |
| 121 | 121 | const lookup_table = comptime block: { |
| 122 | 122 | var table: [16]u32 = undefined; |
| 123 | 123 |
std/hash/fnv.zig+1-1| ... | ... | @@ -13,7 +13,7 @@ pub const Fnv1a_128 = Fnv1a(u128, 0x1000000000000000000013b, 0x6c62272e07bb01426 |
| 13 | 13 | |
| 14 | 14 | fn Fnv1a(comptime T: type, comptime prime: T, comptime offset: T) type { |
| 15 | 15 | return struct { |
| 16 | const Self = this; | |
| 16 | const Self = @This(); | |
| 17 | 17 | |
| 18 | 18 | value: T, |
| 19 | 19 |
std/hash/siphash.zig+1-1| ... | ... | @@ -25,7 +25,7 @@ fn SipHash(comptime T: type, comptime c_rounds: usize, comptime d_rounds: usize) |
| 25 | 25 | debug.assert(c_rounds > 0 and d_rounds > 0); |
| 26 | 26 | |
| 27 | 27 | return struct { |
| 28 | const Self = this; | |
| 28 | const Self = @This(); | |
| 29 | 29 | const digest_size = 64; |
| 30 | 30 | const block_size = 64; |
| 31 | 31 |
std/hash_map.zig+1-3| ... | ... | @@ -22,7 +22,7 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u3 |
| 22 | 22 | // this is used to detect bugs where a hashtable is edited while an iterator is running. |
| 23 | 23 | modification_count: debug_u32, |
| 24 | 24 | |
| 25 | const Self = this; | |
| 25 | const Self = @This(); | |
| 26 | 26 | |
| 27 | 27 | pub const KV = struct { |
| 28 | 28 | key: K, |
| ... | ... | @@ -472,7 +472,6 @@ pub fn autoHash(key: var, comptime rng: *std.rand.Random, comptime HashInt: type |
| 472 | 472 | builtin.TypeId.Promise, builtin.TypeId.Fn => return autoHash(@ptrToInt(key), rng), |
| 473 | 473 | |
| 474 | 474 | builtin.TypeId.Namespace, |
| 475 | builtin.TypeId.Block, | |
| 476 | 475 | builtin.TypeId.BoundFn, |
| 477 | 476 | builtin.TypeId.ComptimeFloat, |
| 478 | 477 | builtin.TypeId.ComptimeInt, |
| ... | ... | @@ -517,7 +516,6 @@ pub fn autoEql(a: var, b: @typeOf(a)) bool { |
| 517 | 516 | builtin.TypeId.ComptimeFloat, |
| 518 | 517 | builtin.TypeId.ComptimeInt, |
| 519 | 518 | builtin.TypeId.Namespace, |
| 520 | builtin.TypeId.Block, | |
| 521 | 519 | builtin.TypeId.Promise, |
| 522 | 520 | builtin.TypeId.Enum, |
| 523 | 521 | builtin.TypeId.BoundFn, |
std/heap.zig+1-1| ... | ... | @@ -385,7 +385,7 @@ pub fn stackFallback(comptime size: usize, fallback_allocator: *Allocator) Stack |
| 385 | 385 | |
| 386 | 386 | pub fn StackFallbackAllocator(comptime size: usize) type { |
| 387 | 387 | return struct { |
| 388 | const Self = this; | |
| 388 | const Self = @This(); | |
| 389 | 389 | |
| 390 | 390 | buffer: [size]u8, |
| 391 | 391 | allocator: Allocator, |
std/io.zig+6-6| ... | ... | @@ -76,7 +76,7 @@ pub const FileOutStream = struct { |
| 76 | 76 | |
| 77 | 77 | pub fn InStream(comptime ReadError: type) type { |
| 78 | 78 | return struct { |
| 79 | const Self = this; | |
| 79 | const Self = @This(); | |
| 80 | 80 | pub const Error = ReadError; |
| 81 | 81 | |
| 82 | 82 | /// Return the number of bytes read. If the number read is smaller than buf.len, it |
| ... | ... | @@ -218,7 +218,7 @@ pub fn InStream(comptime ReadError: type) type { |
| 218 | 218 | |
| 219 | 219 | pub fn OutStream(comptime WriteError: type) type { |
| 220 | 220 | return struct { |
| 221 | const Self = this; | |
| 221 | const Self = @This(); | |
| 222 | 222 | pub const Error = WriteError; |
| 223 | 223 | |
| 224 | 224 | writeFn: fn (self: *Self, bytes: []const u8) Error!void, |
| ... | ... | @@ -291,7 +291,7 @@ pub fn BufferedInStream(comptime Error: type) type { |
| 291 | 291 | |
| 292 | 292 | pub fn BufferedInStreamCustom(comptime buffer_size: usize, comptime Error: type) type { |
| 293 | 293 | return struct { |
| 294 | const Self = this; | |
| 294 | const Self = @This(); | |
| 295 | 295 | const Stream = InStream(Error); |
| 296 | 296 | |
| 297 | 297 | pub stream: Stream, |
| ... | ... | @@ -361,7 +361,7 @@ pub fn BufferedInStreamCustom(comptime buffer_size: usize, comptime Error: type) |
| 361 | 361 | /// This makes look-ahead style parsing much easier. |
| 362 | 362 | pub fn PeekStream(comptime buffer_size: usize, comptime InStreamError: type) type { |
| 363 | 363 | return struct { |
| 364 | const Self = this; | |
| 364 | const Self = @This(); | |
| 365 | 365 | pub const Error = InStreamError; |
| 366 | 366 | pub const Stream = InStream(Error); |
| 367 | 367 | |
| ... | ... | @@ -424,7 +424,7 @@ pub fn PeekStream(comptime buffer_size: usize, comptime InStreamError: type) typ |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | pub const SliceInStream = struct { |
| 427 | const Self = this; | |
| 427 | const Self = @This(); | |
| 428 | 428 | pub const Error = error{}; |
| 429 | 429 | pub const Stream = InStream(Error); |
| 430 | 430 | |
| ... | ... | @@ -505,7 +505,7 @@ pub fn BufferedOutStream(comptime Error: type) type { |
| 505 | 505 | |
| 506 | 506 | pub fn BufferedOutStreamCustom(comptime buffer_size: usize, comptime OutStreamError: type) type { |
| 507 | 507 | return struct { |
| 508 | const Self = this; | |
| 508 | const Self = @This(); | |
| 509 | 509 | pub const Stream = OutStream(Error); |
| 510 | 510 | pub const Error = OutStreamError; |
| 511 | 511 |
std/lazy_init.zig+1-1| ... | ... | @@ -18,7 +18,7 @@ fn LazyInit(comptime T: type) type { |
| 18 | 18 | state: u8, // TODO make this an enum |
| 19 | 19 | data: Data, |
| 20 | 20 | |
| 21 | const Self = this; | |
| 21 | const Self = @This(); | |
| 22 | 22 | |
| 23 | 23 | // TODO this isn't working for void, investigate and then remove this special case |
| 24 | 24 | const Data = if (@sizeOf(T) == 0) u8 else T; |
std/linked_list.zig+1-1| ... | ... | @@ -7,7 +7,7 @@ const Allocator = mem.Allocator; |
| 7 | 7 | /// Generic doubly linked list. |
| 8 | 8 | pub fn LinkedList(comptime T: type) type { |
| 9 | 9 | return struct { |
| 10 | const Self = this; | |
| 10 | const Self = @This(); | |
| 11 | 11 | |
| 12 | 12 | /// Node inside the linked list wrapping the actual data. |
| 13 | 13 | pub const Node = struct { |
std/math/complex/index.zig+1-1| ... | ... | @@ -25,7 +25,7 @@ pub const tan = @import("tan.zig").tan; |
| 25 | 25 | |
| 26 | 26 | pub fn Complex(comptime T: type) type { |
| 27 | 27 | return struct { |
| 28 | const Self = this; | |
| 28 | const Self = @This(); | |
| 29 | 29 | |
| 30 | 30 | re: T, |
| 31 | 31 | im: T, |
std/mem.zig+1-1| ... | ... | @@ -3,7 +3,7 @@ const debug = std.debug; |
| 3 | 3 | const assert = debug.assert; |
| 4 | 4 | const math = std.math; |
| 5 | 5 | const builtin = @import("builtin"); |
| 6 | const mem = this; | |
| 6 | const mem = @This(); | |
| 7 | 7 | |
| 8 | 8 | pub const Allocator = struct { |
| 9 | 9 | pub const Error = error{OutOfMemory}; |
std/net.zig+1-1| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | const std = @import("index.zig"); |
| 2 | 2 | const builtin = @import("builtin"); |
| 3 | 3 | const assert = std.debug.assert; |
| 4 | const net = this; | |
| 4 | const net = @This(); | |
| 5 | 5 | const posix = std.os.posix; |
| 6 | 6 | const mem = std.mem; |
| 7 | 7 |
std/os/index.zig+1-1| ... | ... | @@ -6,7 +6,7 @@ const is_posix = switch (builtin.os) { |
| 6 | 6 | builtin.Os.linux, builtin.Os.macosx => true, |
| 7 | 7 | else => false, |
| 8 | 8 | }; |
| 9 | const os = this; | |
| 9 | const os = @This(); | |
| 10 | 10 | |
| 11 | 11 | test "std.os" { |
| 12 | 12 | _ = @import("child_process.zig"); |
std/segmented_list.zig+1-1| ... | ... | @@ -75,7 +75,7 @@ const Allocator = std.mem.Allocator; |
| 75 | 75 | /// size is small. `prealloc_item_count` must be 0, or a power of 2. |
| 76 | 76 | pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type { |
| 77 | 77 | return struct { |
| 78 | const Self = this; | |
| 78 | const Self = @This(); | |
| 79 | 79 | const prealloc_exp = blk: { |
| 80 | 80 | // we don't use the prealloc_exp constant when prealloc_item_count is 0. |
| 81 | 81 | assert(prealloc_item_count != 0); |
std/zig/ast.zig+2-2| ... | ... | @@ -231,7 +231,7 @@ pub const Error = union(enum) { |
| 231 | 231 | |
| 232 | 232 | fn SingleTokenError(comptime msg: []const u8) type { |
| 233 | 233 | return struct { |
| 234 | const ThisError = this; | |
| 234 | const ThisError = @This(); | |
| 235 | 235 | |
| 236 | 236 | token: TokenIndex, |
| 237 | 237 | |
| ... | ... | @@ -244,7 +244,7 @@ pub const Error = union(enum) { |
| 244 | 244 | |
| 245 | 245 | fn SimpleError(comptime msg: []const u8) type { |
| 246 | 246 | return struct { |
| 247 | const ThisError = this; | |
| 247 | const ThisError = @This(); | |
| 248 | 248 | |
| 249 | 249 | token: TokenIndex, |
| 250 | 250 |
std/zig/parser_test.zig+1-1| ... | ... | @@ -1354,7 +1354,7 @@ test "zig fmt: indexing" { |
| 1354 | 1354 | test "zig fmt: struct declaration" { |
| 1355 | 1355 | try testCanonical( |
| 1356 | 1356 | \\const S = struct { |
| 1357 | \\ const Self = this; | |
| 1357 | \\ const Self = @This(); | |
| 1358 | 1358 | \\ f1: u8, |
| 1359 | 1359 | \\ pub f3: u8, |
| 1360 | 1360 | \\ |
std/zig/render.zig+1-1| ... | ... | @@ -20,7 +20,7 @@ pub fn render(allocator: *mem.Allocator, stream: var, tree: *ast.Tree) (@typeOf( |
| 20 | 20 | |
| 21 | 21 | // make a passthrough stream that checks whether something changed |
| 22 | 22 | const MyStream = struct { |
| 23 | const MyStream = this; | |
| 23 | const MyStream = @This(); | |
| 24 | 24 | const StreamError = @typeOf(stream).Child.Error; |
| 25 | 25 | const Stream = std.io.OutStream(StreamError); |
| 26 | 26 |
test/cases/cast.zig+2-2| ... | ... | @@ -64,7 +64,7 @@ test "implicitly cast a container to a const pointer of it" { |
| 64 | 64 | |
| 65 | 65 | fn Struct(comptime T: type) type { |
| 66 | 66 | return struct { |
| 67 | const Self = this; | |
| 67 | const Self = @This(); | |
| 68 | 68 | x: T, |
| 69 | 69 | |
| 70 | 70 | fn pointer(self: *const Self) Self { |
| ... | ... | @@ -106,7 +106,7 @@ const Enum = enum { |
| 106 | 106 | |
| 107 | 107 | test "implicitly cast indirect pointer to maybe-indirect pointer" { |
| 108 | 108 | const S = struct { |
| 109 | const Self = this; | |
| 109 | const Self = @This(); | |
| 110 | 110 | x: u8, |
| 111 | 111 | fn constConst(p: *const *const Self) u8 { |
| 112 | 112 | return p.*.x; |
test/cases/eval.zig+1-1| ... | ... | @@ -628,7 +628,7 @@ test "call method with comptime pass-by-non-copying-value self parameter" { |
| 628 | 628 | const S = struct { |
| 629 | 629 | a: u8, |
| 630 | 630 | |
| 631 | fn b(comptime s: this) u8 { | |
| 631 | fn b(comptime s: @This()) u8 { | |
| 632 | 632 | return s.a; |
| 633 | 633 | } |
| 634 | 634 | }; |
test/cases/misc.zig-3| ... | ... | @@ -510,9 +510,6 @@ test "@typeId" { |
| 510 | 510 | assert(@typeId(AUnion) == Tid.Union); |
| 511 | 511 | assert(@typeId(fn () void) == Tid.Fn); |
| 512 | 512 | assert(@typeId(@typeOf(builtin)) == Tid.Namespace); |
| 513 | assert(@typeId(@typeOf(x: { | |
| 514 | break :x this; | |
| 515 | })) == Tid.Block); | |
| 516 | 513 | // TODO bound fn |
| 517 | 514 | // TODO arg tuple |
| 518 | 515 | // TODO opaque |
test/cases/reflection.zig+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | const assert = @import("std").debug.assert; |
| 2 | 2 | const mem = @import("std").mem; |
| 3 | const reflection = this; | |
| 3 | const reflection = @This(); | |
| 4 | 4 | |
| 5 | 5 | test "reflection: array, pointer, optional, error union type child" { |
| 6 | 6 | comptime { |
test/cases/struct.zig+2-2| ... | ... | @@ -423,10 +423,10 @@ fn alloc(comptime T: type) []T { |
| 423 | 423 | |
| 424 | 424 | test "call method with mutable reference to struct with no fields" { |
| 425 | 425 | const S = struct { |
| 426 | fn doC(s: *const this) bool { | |
| 426 | fn doC(s: *const @This()) bool { | |
| 427 | 427 | return true; |
| 428 | 428 | } |
| 429 | fn do(s: *this) bool { | |
| 429 | fn do(s: *@This()) bool { | |
| 430 | 430 | return true; |
| 431 | 431 | } |
| 432 | 432 | }; |
test/cases/this.zig+2-11| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | 1 | const assert = @import("std").debug.assert; |
| 2 | 2 | |
| 3 | const module = this; | |
| 3 | const module = @This(); | |
| 4 | 4 | |
| 5 | 5 | fn Point(comptime T: type) type { |
| 6 | 6 | return struct { |
| 7 | const Self = this; | |
| 7 | const Self = @This(); | |
| 8 | 8 | x: T, |
| 9 | 9 | y: T, |
| 10 | 10 | |
| ... | ... | @@ -19,11 +19,6 @@ fn add(x: i32, y: i32) i32 { |
| 19 | 19 | return x + y; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | fn factorial(x: i32) i32 { | |
| 23 | const selfFn = this; | |
| 24 | return if (x == 0) 1 else x * selfFn(x - 1); | |
| 25 | } | |
| 26 | ||
| 27 | 22 | test "this refer to module call private fn" { |
| 28 | 23 | assert(module.add(1, 2) == 3); |
| 29 | 24 | } |
| ... | ... | @@ -37,7 +32,3 @@ test "this refer to container" { |
| 37 | 32 | assert(pt.x == 13); |
| 38 | 33 | assert(pt.y == 35); |
| 39 | 34 | } |
| 40 | ||
| 41 | test "this refer to fn" { | |
| 42 | assert(factorial(5) == 120); | |
| 43 | } |
test/cases/type_info.zig+2-2| ... | ... | @@ -166,7 +166,7 @@ fn testUnion() void { |
| 166 | 166 | assert(TypeId(typeinfo_info) == TypeId.Union); |
| 167 | 167 | assert(typeinfo_info.Union.layout == TypeInfo.ContainerLayout.Auto); |
| 168 | 168 | assert(typeinfo_info.Union.tag_type.? == TypeId); |
| 169 | assert(typeinfo_info.Union.fields.len == 25); | |
| 169 | assert(typeinfo_info.Union.fields.len == 24); | |
| 170 | 170 | assert(typeinfo_info.Union.fields[4].enum_field != null); |
| 171 | 171 | assert(typeinfo_info.Union.fields[4].enum_field.?.value == 4); |
| 172 | 172 | assert(typeinfo_info.Union.fields[4].field_type == @typeOf(@typeInfo(u8).Int)); |
| ... | ... | @@ -217,7 +217,7 @@ fn testStruct() void { |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | const TestStruct = packed struct { |
| 220 | const Self = this; | |
| 220 | const Self = @This(); | |
| 221 | 221 | |
| 222 | 222 | fieldA: usize, |
| 223 | 223 | fieldB: void, |
test/compile_errors.zig+13-15| ... | ... | @@ -3813,11 +3813,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 3813 | 3813 | \\ return struct { |
| 3814 | 3814 | \\ b: B(), |
| 3815 | 3815 | \\ |
| 3816 | \\ const Self = this; | |
| 3816 | \\ const Self = @This(); | |
| 3817 | 3817 | \\ |
| 3818 | 3818 | \\ fn B() type { |
| 3819 | 3819 | \\ return struct { |
| 3820 | \\ const Self = this; | |
| 3820 | \\ const Self = @This(); | |
| 3821 | 3821 | \\ }; |
| 3822 | 3822 | \\ } |
| 3823 | 3823 | \\ }; |
| ... | ... | @@ -4314,12 +4314,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 4314 | 4314 | \\ var a = undefined; |
| 4315 | 4315 | \\ var b = 1; |
| 4316 | 4316 | \\ var c = 1.0; |
| 4317 | \\ var d = this; | |
| 4318 | \\ var e = null; | |
| 4319 | \\ var f = opaque.*; | |
| 4320 | \\ var g = i32; | |
| 4321 | \\ var h = @import("std",); | |
| 4322 | \\ var i = (Foo {}).bar; | |
| 4317 | \\ var d = null; | |
| 4318 | \\ var e = opaque.*; | |
| 4319 | \\ var f = i32; | |
| 4320 | \\ var g = @import("std",); | |
| 4321 | \\ var h = (Foo {}).bar; | |
| 4323 | 4322 | \\ |
| 4324 | 4323 | \\ var z: noreturn = return; |
| 4325 | 4324 | \\} |
| ... | ... | @@ -4332,13 +4331,12 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 4332 | 4331 | ".tmp_source.zig:7:4: error: variable of type '(undefined)' must be const or comptime", |
| 4333 | 4332 | ".tmp_source.zig:8:4: error: variable of type 'comptime_int' must be const or comptime", |
| 4334 | 4333 | ".tmp_source.zig:9:4: error: variable of type 'comptime_float' must be const or comptime", |
| 4335 | ".tmp_source.zig:10:4: error: variable of type '(block)' must be const or comptime", | |
| 4336 | ".tmp_source.zig:11:4: error: variable of type '(null)' must be const or comptime", | |
| 4337 | ".tmp_source.zig:12:4: error: variable of type 'Opaque' not allowed", | |
| 4338 | ".tmp_source.zig:13:4: error: variable of type 'type' must be const or comptime", | |
| 4339 | ".tmp_source.zig:14:4: error: variable of type '(namespace)' must be const or comptime", | |
| 4340 | ".tmp_source.zig:15:4: error: variable of type '(bound fn(*const Foo) void)' must be const or comptime", | |
| 4341 | ".tmp_source.zig:17:4: error: unreachable code", | |
| 4334 | ".tmp_source.zig:10:4: error: variable of type '(null)' must be const or comptime", | |
| 4335 | ".tmp_source.zig:11:4: error: variable of type 'Opaque' not allowed", | |
| 4336 | ".tmp_source.zig:12:4: error: variable of type 'type' must be const or comptime", | |
| 4337 | ".tmp_source.zig:13:4: error: variable of type '(namespace)' must be const or comptime", | |
| 4338 | ".tmp_source.zig:14:4: error: variable of type '(bound fn(*const Foo) void)' must be const or comptime", | |
| 4339 | ".tmp_source.zig:16:4: error: unreachable code", | |
| 4342 | 4340 | ); |
| 4343 | 4341 | |
| 4344 | 4342 | cases.add( |