authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-13 16:34:33-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-13 16:34:33-04:00
logc06a61e9bf93810174255474598cfeae785cfbd6
tree27d8f4262d8cd8c72c75e348e63e6c7d6a6ec0d4
parent7c3636aaa38e8efa77b73ba94362802517ea739e
signaturelock-open Commit is signed but in an unrecognized format.

remove `this`. add `@This()`.

closes #1283

55 files changed, 97 insertions(+), 266 deletions(-)

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