authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-07-11 14:08:20+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-07-11 17:41:33+03:00
log8110639c7964fcb23c2b715f97ab6caa27506b93
tree9556ad058e4001c0f0789a0fc82fc570e2d91d32
parentc2fb4bfff3b1a2bf4e7072cec04d67e8152900c1
signaturelock-open Commit is signed but in an unrecognized format.

add 'anytype' to stage1 and langref


9 files changed, 114 insertions(+), 105 deletions(-)

doc/langref.html.in+44-43
......@@ -1785,7 +1785,7 @@ test "fully anonymous list literal" {
17851785 dump(.{ @as(u32, 1234), @as(f64, 12.34), true, "hi"});
17861786}
17871787
1788fn dump(args: var) void {
1788fn dump(args: anytype) void {
17891789 assert(args.@"0" == 1234);
17901790 assert(args.@"1" == 12.34);
17911791 assert(args.@"2");
......@@ -2717,7 +2717,7 @@ test "fully anonymous struct" {
27172717 });
27182718}
27192719
2720fn dump(args: var) void {
2720fn dump(args: anytype) void {
27212721 assert(args.int == 1234);
27222722 assert(args.float == 12.34);
27232723 assert(args.b);
......@@ -4181,14 +4181,14 @@ test "pass struct to function" {
41814181 {#header_close#}
41824182 {#header_open|Function Parameter Type Inference#}
41834183 <p>
4184 Function parameters can be declared with {#syntax#}var{#endsyntax#} in place of the type.
4184 Function parameters can be declared with {#syntax#}anytype{#endsyntax#} in place of the type.
41854185 In this case the parameter types will be inferred when the function is called.
41864186 Use {#link|@TypeOf#} and {#link|@typeInfo#} to get information about the inferred type.
41874187 </p>
41884188 {#code_begin|test#}
41894189const assert = @import("std").debug.assert;
41904190
4191fn addFortyTwo(x: var) @TypeOf(x) {
4191fn addFortyTwo(x: anytype) @TypeOf(x) {
41924192 return x + 42;
41934193}
41944194
......@@ -5974,7 +5974,7 @@ pub fn main() void {
59745974
59755975 {#code_begin|syntax#}
59765976/// Calls print and then flushes the buffer.
5977pub fn printf(self: *OutStream, comptime format: []const u8, args: var) anyerror!void {
5977pub fn printf(self: *OutStream, comptime format: []const u8, args: anytype) anyerror!void {
59785978 const State = enum {
59795979 Start,
59805980 OpenBrace,
......@@ -6060,7 +6060,7 @@ pub fn printf(self: *OutStream, arg0: i32, arg1: []const u8) !void {
60606060 on the type:
60616061 </p>
60626062 {#code_begin|syntax#}
6063pub fn printValue(self: *OutStream, value: var) !void {
6063pub fn printValue(self: *OutStream, value: anytype) !void {
60646064 switch (@typeInfo(@TypeOf(value))) {
60656065 .Int => {
60666066 return self.printInt(T, value);
......@@ -6686,7 +6686,7 @@ fn readFile(allocator: *Allocator, filename: []const u8) ![]u8 {
66866686 </p>
66876687 {#header_close#}
66886688 {#header_open|@alignCast#}
6689 <pre>{#syntax#}@alignCast(comptime alignment: u29, ptr: var) var{#endsyntax#}</pre>
6689 <pre>{#syntax#}@alignCast(comptime alignment: u29, ptr: anytype) anytype{#endsyntax#}</pre>
66906690 <p>
66916691 {#syntax#}ptr{#endsyntax#} can be {#syntax#}*T{#endsyntax#}, {#syntax#}fn(){#endsyntax#}, {#syntax#}?*T{#endsyntax#},
66926692 {#syntax#}?fn(){#endsyntax#}, or {#syntax#}[]T{#endsyntax#}. It returns the same type as {#syntax#}ptr{#endsyntax#}
......@@ -6723,7 +6723,7 @@ comptime {
67236723 {#header_close#}
67246724
67256725 {#header_open|@asyncCall#}
6726 <pre>{#syntax#}@asyncCall(frame_buffer: []align(@alignOf(@Frame(anyAsyncFunction))) u8, result_ptr, function_ptr, args: var) anyframe->T{#endsyntax#}</pre>
6726 <pre>{#syntax#}@asyncCall(frame_buffer: []align(@alignOf(@Frame(anyAsyncFunction))) u8, result_ptr, function_ptr, args: anytype) anyframe->T{#endsyntax#}</pre>
67276727 <p>
67286728 {#syntax#}@asyncCall{#endsyntax#} performs an {#syntax#}async{#endsyntax#} call on a function pointer,
67296729 which may or may not be an {#link|async function|Async Functions#}.
......@@ -6811,7 +6811,7 @@ fn func(y: *i32) void {
68116811 </p>
68126812 {#header_close#}
68136813 {#header_open|@bitCast#}
6814 <pre>{#syntax#}@bitCast(comptime DestType: type, value: var) DestType{#endsyntax#}</pre>
6814 <pre>{#syntax#}@bitCast(comptime DestType: type, value: anytype) DestType{#endsyntax#}</pre>
68156815 <p>
68166816 Converts a value of one type to another type.
68176817 </p>
......@@ -6932,7 +6932,7 @@ fn func(y: *i32) void {
69326932 {#header_close#}
69336933
69346934 {#header_open|@call#}
6935 <pre>{#syntax#}@call(options: std.builtin.CallOptions, function: var, args: var) var{#endsyntax#}</pre>
6935 <pre>{#syntax#}@call(options: std.builtin.CallOptions, function: anytype, args: anytype) anytype{#endsyntax#}</pre>
69366936 <p>
69376937 Calls a function, in the same way that invoking an expression with parentheses does:
69386938 </p>
......@@ -7279,7 +7279,7 @@ test "main" {
72797279 {#header_close#}
72807280
72817281 {#header_open|@enumToInt#}
7282 <pre>{#syntax#}@enumToInt(enum_or_tagged_union: var) var{#endsyntax#}</pre>
7282 <pre>{#syntax#}@enumToInt(enum_or_tagged_union: anytype) anytype{#endsyntax#}</pre>
72837283 <p>
72847284 Converts an enumeration value into its integer tag type. When a tagged union is passed,
72857285 the tag value is used as the enumeration value.
......@@ -7314,7 +7314,7 @@ test "main" {
73147314 {#header_close#}
73157315
73167316 {#header_open|@errorToInt#}
7317 <pre>{#syntax#}@errorToInt(err: var) std.meta.IntType(false, @sizeOf(anyerror) * 8){#endsyntax#}</pre>
7317 <pre>{#syntax#}@errorToInt(err: anytype) std.meta.IntType(false, @sizeOf(anyerror) * 8){#endsyntax#}</pre>
73187318 <p>
73197319 Supports the following types:
73207320 </p>
......@@ -7334,7 +7334,7 @@ test "main" {
73347334 {#header_close#}
73357335
73367336 {#header_open|@errSetCast#}
7337 <pre>{#syntax#}@errSetCast(comptime T: DestType, value: var) DestType{#endsyntax#}</pre>
7337 <pre>{#syntax#}@errSetCast(comptime T: DestType, value: anytype) DestType{#endsyntax#}</pre>
73387338 <p>
73397339 Converts an error value from one error set to another error set. Attempting to convert an error
73407340 which is not in the destination error set results in safety-protected {#link|Undefined Behavior#}.
......@@ -7342,7 +7342,7 @@ test "main" {
73427342 {#header_close#}
73437343
73447344 {#header_open|@export#}
7345 <pre>{#syntax#}@export(target: var, comptime options: std.builtin.ExportOptions) void{#endsyntax#}</pre>
7345 <pre>{#syntax#}@export(target: anytype, comptime options: std.builtin.ExportOptions) void{#endsyntax#}</pre>
73467346 <p>
73477347 Creates a symbol in the output object file.
73487348 </p>
......@@ -7387,7 +7387,7 @@ export fn @"A function name that is a complete sentence."() void {}
73877387 {#header_close#}
73887388
73897389 {#header_open|@field#}
7390 <pre>{#syntax#}@field(lhs: var, comptime field_name: []const u8) (field){#endsyntax#}</pre>
7390 <pre>{#syntax#}@field(lhs: anytype, comptime field_name: []const u8) (field){#endsyntax#}</pre>
73917391 <p>Performs field access by a compile-time string.
73927392 </p>
73937393 {#code_begin|test#}
......@@ -7421,7 +7421,7 @@ test "field access by string" {
74217421 {#header_close#}
74227422
74237423 {#header_open|@floatCast#}
7424 <pre>{#syntax#}@floatCast(comptime DestType: type, value: var) DestType{#endsyntax#}</pre>
7424 <pre>{#syntax#}@floatCast(comptime DestType: type, value: anytype) DestType{#endsyntax#}</pre>
74257425 <p>
74267426 Convert from one float type to another. This cast is safe, but may cause the
74277427 numeric value to lose precision.
......@@ -7429,7 +7429,7 @@ test "field access by string" {
74297429 {#header_close#}
74307430
74317431 {#header_open|@floatToInt#}
7432 <pre>{#syntax#}@floatToInt(comptime DestType: type, float: var) DestType{#endsyntax#}</pre>
7432 <pre>{#syntax#}@floatToInt(comptime DestType: type, float: anytype) DestType{#endsyntax#}</pre>
74337433 <p>
74347434 Converts the integer part of a floating point number to the destination type.
74357435 </p>
......@@ -7455,7 +7455,7 @@ test "field access by string" {
74557455 {#header_close#}
74567456
74577457 {#header_open|@Frame#}
7458 <pre>{#syntax#}@Frame(func: var) type{#endsyntax#}</pre>
7458 <pre>{#syntax#}@Frame(func: anytype) type{#endsyntax#}</pre>
74597459 <p>
74607460 This function returns the frame type of a function. This works for {#link|Async Functions#}
74617461 as well as any function without a specific calling convention.
......@@ -7581,7 +7581,7 @@ test "@hasDecl" {
75817581 {#header_close#}
75827582
75837583 {#header_open|@intCast#}
7584 <pre>{#syntax#}@intCast(comptime DestType: type, int: var) DestType{#endsyntax#}</pre>
7584 <pre>{#syntax#}@intCast(comptime DestType: type, int: anytype) DestType{#endsyntax#}</pre>
75857585 <p>
75867586 Converts an integer to another integer while keeping the same numerical value.
75877587 Attempting to convert a number which is out of range of the destination type results in
......@@ -7622,7 +7622,7 @@ test "@hasDecl" {
76227622 {#header_close#}
76237623
76247624 {#header_open|@intToFloat#}
7625 <pre>{#syntax#}@intToFloat(comptime DestType: type, int: var) DestType{#endsyntax#}</pre>
7625 <pre>{#syntax#}@intToFloat(comptime DestType: type, int: anytype) DestType{#endsyntax#}</pre>
76267626 <p>
76277627 Converts an integer to the closest floating point representation. To convert the other way, use {#link|@floatToInt#}. This cast is always safe.
76287628 </p>
......@@ -7773,7 +7773,7 @@ test "@wasmMemoryGrow" {
77737773 {#header_close#}
77747774
77757775 {#header_open|@ptrCast#}
7776 <pre>{#syntax#}@ptrCast(comptime DestType: type, value: var) DestType{#endsyntax#}</pre>
7776 <pre>{#syntax#}@ptrCast(comptime DestType: type, value: anytype) DestType{#endsyntax#}</pre>
77777777 <p>
77787778 Converts a pointer of one type to a pointer of another type.
77797779 </p>
......@@ -7784,7 +7784,7 @@ test "@wasmMemoryGrow" {
77847784 {#header_close#}
77857785
77867786 {#header_open|@ptrToInt#}
7787 <pre>{#syntax#}@ptrToInt(value: var) usize{#endsyntax#}</pre>
7787 <pre>{#syntax#}@ptrToInt(value: anytype) usize{#endsyntax#}</pre>
77887788 <p>
77897789 Converts {#syntax#}value{#endsyntax#} to a {#syntax#}usize{#endsyntax#} which is the address of the pointer. {#syntax#}value{#endsyntax#} can be one of these types:
77907790 </p>
......@@ -8042,7 +8042,7 @@ test "@setRuntimeSafety" {
80428042 {#header_close#}
80438043
80448044 {#header_open|@splat#}
8045 <pre>{#syntax#}@splat(comptime len: u32, scalar: var) std.meta.Vector(len, @TypeOf(scalar)){#endsyntax#}</pre>
8045 <pre>{#syntax#}@splat(comptime len: u32, scalar: anytype) std.meta.Vector(len, @TypeOf(scalar)){#endsyntax#}</pre>
80468046 <p>
80478047 Produces a vector of length {#syntax#}len{#endsyntax#} where each element is the value
80488048 {#syntax#}scalar{#endsyntax#}:
......@@ -8088,7 +8088,7 @@ fn doTheTest() void {
80888088 {#code_end#}
80898089 {#header_close#}
80908090 {#header_open|@sqrt#}
8091 <pre>{#syntax#}@sqrt(value: var) @TypeOf(value){#endsyntax#}</pre>
8091 <pre>{#syntax#}@sqrt(value: anytype) @TypeOf(value){#endsyntax#}</pre>
80928092 <p>
80938093 Performs the square root of a floating point number. Uses a dedicated hardware instruction
80948094 when available.
......@@ -8099,7 +8099,7 @@ fn doTheTest() void {
80998099 </p>
81008100 {#header_close#}
81018101 {#header_open|@sin#}
8102 <pre>{#syntax#}@sin(value: var) @TypeOf(value){#endsyntax#}</pre>
8102 <pre>{#syntax#}@sin(value: anytype) @TypeOf(value){#endsyntax#}</pre>
81038103 <p>
81048104 Sine trigometric function on a floating point number. Uses a dedicated hardware instruction
81058105 when available.
......@@ -8110,7 +8110,7 @@ fn doTheTest() void {
81108110 </p>
81118111 {#header_close#}
81128112 {#header_open|@cos#}
8113 <pre>{#syntax#}@cos(value: var) @TypeOf(value){#endsyntax#}</pre>
8113 <pre>{#syntax#}@cos(value: anytype) @TypeOf(value){#endsyntax#}</pre>
81148114 <p>
81158115 Cosine trigometric function on a floating point number. Uses a dedicated hardware instruction
81168116 when available.
......@@ -8121,7 +8121,7 @@ fn doTheTest() void {
81218121 </p>
81228122 {#header_close#}
81238123 {#header_open|@exp#}
8124 <pre>{#syntax#}@exp(value: var) @TypeOf(value){#endsyntax#}</pre>
8124 <pre>{#syntax#}@exp(value: anytype) @TypeOf(value){#endsyntax#}</pre>
81258125 <p>
81268126 Base-e exponential function on a floating point number. Uses a dedicated hardware instruction
81278127 when available.
......@@ -8132,7 +8132,7 @@ fn doTheTest() void {
81328132 </p>
81338133 {#header_close#}
81348134 {#header_open|@exp2#}
8135 <pre>{#syntax#}@exp2(value: var) @TypeOf(value){#endsyntax#}</pre>
8135 <pre>{#syntax#}@exp2(value: anytype) @TypeOf(value){#endsyntax#}</pre>
81368136 <p>
81378137 Base-2 exponential function on a floating point number. Uses a dedicated hardware instruction
81388138 when available.
......@@ -8143,7 +8143,7 @@ fn doTheTest() void {
81438143 </p>
81448144 {#header_close#}
81458145 {#header_open|@log#}
8146 <pre>{#syntax#}@log(value: var) @TypeOf(value){#endsyntax#}</pre>
8146 <pre>{#syntax#}@log(value: anytype) @TypeOf(value){#endsyntax#}</pre>
81478147 <p>
81488148 Returns the natural logarithm of a floating point number. Uses a dedicated hardware instruction
81498149 when available.
......@@ -8154,7 +8154,7 @@ fn doTheTest() void {
81548154 </p>
81558155 {#header_close#}
81568156 {#header_open|@log2#}
8157 <pre>{#syntax#}@log2(value: var) @TypeOf(value){#endsyntax#}</pre>
8157 <pre>{#syntax#}@log2(value: anytype) @TypeOf(value){#endsyntax#}</pre>
81588158 <p>
81598159 Returns the logarithm to the base 2 of a floating point number. Uses a dedicated hardware instruction
81608160 when available.
......@@ -8165,7 +8165,7 @@ fn doTheTest() void {
81658165 </p>
81668166 {#header_close#}
81678167 {#header_open|@log10#}
8168 <pre>{#syntax#}@log10(value: var) @TypeOf(value){#endsyntax#}</pre>
8168 <pre>{#syntax#}@log10(value: anytype) @TypeOf(value){#endsyntax#}</pre>
81698169 <p>
81708170 Returns the logarithm to the base 10 of a floating point number. Uses a dedicated hardware instruction
81718171 when available.
......@@ -8176,7 +8176,7 @@ fn doTheTest() void {
81768176 </p>
81778177 {#header_close#}
81788178 {#header_open|@fabs#}
8179 <pre>{#syntax#}@fabs(value: var) @TypeOf(value){#endsyntax#}</pre>
8179 <pre>{#syntax#}@fabs(value: anytype) @TypeOf(value){#endsyntax#}</pre>
81808180 <p>
81818181 Returns the absolute value of a floating point number. Uses a dedicated hardware instruction
81828182 when available.
......@@ -8187,7 +8187,7 @@ fn doTheTest() void {
81878187 </p>
81888188 {#header_close#}
81898189 {#header_open|@floor#}
8190 <pre>{#syntax#}@floor(value: var) @TypeOf(value){#endsyntax#}</pre>
8190 <pre>{#syntax#}@floor(value: anytype) @TypeOf(value){#endsyntax#}</pre>
81918191 <p>
81928192 Returns the largest integral value not greater than the given floating point number.
81938193 Uses a dedicated hardware instruction when available.
......@@ -8198,7 +8198,7 @@ fn doTheTest() void {
81988198 </p>
81998199 {#header_close#}
82008200 {#header_open|@ceil#}
8201 <pre>{#syntax#}@ceil(value: var) @TypeOf(value){#endsyntax#}</pre>
8201 <pre>{#syntax#}@ceil(value: anytype) @TypeOf(value){#endsyntax#}</pre>
82028202 <p>
82038203 Returns the largest integral value not less than the given floating point number.
82048204 Uses a dedicated hardware instruction when available.
......@@ -8209,7 +8209,7 @@ fn doTheTest() void {
82098209 </p>
82108210 {#header_close#}
82118211 {#header_open|@trunc#}
8212 <pre>{#syntax#}@trunc(value: var) @TypeOf(value){#endsyntax#}</pre>
8212 <pre>{#syntax#}@trunc(value: anytype) @TypeOf(value){#endsyntax#}</pre>
82138213 <p>
82148214 Rounds the given floating point number to an integer, towards zero.
82158215 Uses a dedicated hardware instruction when available.
......@@ -8220,7 +8220,7 @@ fn doTheTest() void {
82208220 </p>
82218221 {#header_close#}
82228222 {#header_open|@round#}
8223 <pre>{#syntax#}@round(value: var) @TypeOf(value){#endsyntax#}</pre>
8223 <pre>{#syntax#}@round(value: anytype) @TypeOf(value){#endsyntax#}</pre>
82248224 <p>
82258225 Rounds the given floating point number to an integer, away from zero. Uses a dedicated hardware instruction
82268226 when available.
......@@ -8241,7 +8241,7 @@ fn doTheTest() void {
82418241 {#header_close#}
82428242
82438243 {#header_open|@tagName#}
8244 <pre>{#syntax#}@tagName(value: var) []const u8{#endsyntax#}</pre>
8244 <pre>{#syntax#}@tagName(value: anytype) []const u8{#endsyntax#}</pre>
82458245 <p>
82468246 Converts an enum value or union value to a slice of bytes representing the name.</p><p>If the enum is non-exhaustive and the tag value does not map to a name, it invokes safety-checked {#link|Undefined Behavior#}.
82478247 </p>
......@@ -8292,7 +8292,7 @@ fn List(comptime T: type) type {
82928292 {#header_close#}
82938293
82948294 {#header_open|@truncate#}
8295 <pre>{#syntax#}@truncate(comptime T: type, integer: var) T{#endsyntax#}</pre>
8295 <pre>{#syntax#}@truncate(comptime T: type, integer: anytype) T{#endsyntax#}</pre>
82968296 <p>
82978297 This function truncates bits from an integer type, resulting in a smaller
82988298 or same-sized integer type.
......@@ -10214,7 +10214,7 @@ TopLevelDecl
1021410214 / (KEYWORD_export / KEYWORD_extern STRINGLITERALSINGLE?)? KEYWORD_threadlocal? VarDecl
1021510215 / KEYWORD_usingnamespace Expr SEMICOLON
1021610216
10217FnProto &lt;- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_var / TypeExpr)
10217FnProto &lt;- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_anytype / TypeExpr)
1021810218
1021910219VarDecl &lt;- (KEYWORD_const / KEYWORD_var) IDENTIFIER (COLON TypeExpr)? ByteAlign? LinkSection? (EQUAL Expr)? SEMICOLON
1022010220
......@@ -10386,7 +10386,7 @@ LinkSection &lt;- KEYWORD_linksection LPAREN Expr RPAREN
1038610386ParamDecl &lt;- (KEYWORD_noalias / KEYWORD_comptime)? (IDENTIFIER COLON)? ParamType
1038710387
1038810388ParamType
10389 &lt;- KEYWORD_var
10389 &lt;- KEYWORD_anytype
1039010390 / DOT3
1039110391 / TypeExpr
1039210392
......@@ -10624,6 +10624,7 @@ KEYWORD_align &lt;- 'align' end_of_word
1062410624KEYWORD_allowzero &lt;- 'allowzero' end_of_word
1062510625KEYWORD_and &lt;- 'and' end_of_word
1062610626KEYWORD_anyframe &lt;- 'anyframe' end_of_word
10627KEYWORD_anytype &lt;- 'anytype' end_of_word
1062710628KEYWORD_asm &lt;- 'asm' end_of_word
1062810629KEYWORD_async &lt;- 'async' end_of_word
1062910630KEYWORD_await &lt;- 'await' end_of_word
......@@ -10669,14 +10670,14 @@ KEYWORD_var &lt;- 'var' end_of_word
1066910670KEYWORD_volatile &lt;- 'volatile' end_of_word
1067010671KEYWORD_while &lt;- 'while' end_of_word
1067110672
10672keyword &lt;- KEYWORD_align / KEYWORD_and / KEYWORD_allowzero / KEYWORD_asm
10673 / KEYWORD_async / KEYWORD_await / KEYWORD_break
10673keyword &lt;- KEYWORD_align / KEYWORD_and / KEYWORD_anyframe / KEYWORD_anytype
10674 / KEYWORD_allowzero / KEYWORD_asm / KEYWORD_async / KEYWORD_await / KEYWORD_break
1067410675 / KEYWORD_catch / KEYWORD_comptime / KEYWORD_const / KEYWORD_continue
1067510676 / KEYWORD_defer / KEYWORD_else / KEYWORD_enum / KEYWORD_errdefer
1067610677 / KEYWORD_error / KEYWORD_export / KEYWORD_extern / KEYWORD_false
1067710678 / KEYWORD_fn / KEYWORD_for / KEYWORD_if / KEYWORD_inline
1067810679 / KEYWORD_noalias / KEYWORD_null / KEYWORD_or
10679 / KEYWORD_orelse / KEYWORD_packed / KEYWORD_anyframe / KEYWORD_pub
10680 / KEYWORD_orelse / KEYWORD_packed / KEYWORD_pub
1068010681 / KEYWORD_resume / KEYWORD_return / KEYWORD_linksection
1068110682 / KEYWORD_struct / KEYWORD_suspend
1068210683 / KEYWORD_switch / KEYWORD_test / KEYWORD_threadlocal / KEYWORD_true / KEYWORD_try
src/all_types.hpp+4-4
......@@ -692,7 +692,7 @@ enum NodeType {
692692 NodeTypeSuspend,
693693 NodeTypeAnyFrameType,
694694 NodeTypeEnumLiteral,
695 NodeTypeVarFieldType,
695 NodeTypeAnyTypeField,
696696};
697697
698698enum FnInline {
......@@ -705,7 +705,7 @@ struct AstNodeFnProto {
705705 Buf *name;
706706 ZigList<AstNode *> params;
707707 AstNode *return_type;
708 Token *return_var_token;
708 Token *return_anytype_token;
709709 AstNode *fn_def_node;
710710 // populated if this is an extern declaration
711711 Buf *lib_name;
......@@ -734,7 +734,7 @@ struct AstNodeFnDef {
734734struct AstNodeParamDecl {
735735 Buf *name;
736736 AstNode *type;
737 Token *var_token;
737 Token *anytype_token;
738738 Buf doc_comments;
739739 bool is_noalias;
740740 bool is_comptime;
......@@ -2145,7 +2145,7 @@ struct CodeGen {
21452145 ZigType *entry_num_lit_float;
21462146 ZigType *entry_undef;
21472147 ZigType *entry_null;
2148 ZigType *entry_var;
2148 ZigType *entry_anytype;
21492149 ZigType *entry_global_error_set;
21502150 ZigType *entry_enum_literal;
21512151 ZigType *entry_any_frame;
src/analyze.cpp+8-8
......@@ -1129,7 +1129,7 @@ ZigValue *analyze_const_value(CodeGen *g, Scope *scope, AstNode *node, ZigType *
11291129 ZigValue *result = g->pass1_arena->create<ZigValue>();
11301130 ZigValue *result_ptr = g->pass1_arena->create<ZigValue>();
11311131 result->special = ConstValSpecialUndef;
1132 result->type = (type_entry == nullptr) ? g->builtin_types.entry_var : type_entry;
1132 result->type = (type_entry == nullptr) ? g->builtin_types.entry_anytype : type_entry;
11331133 result_ptr->special = ConstValSpecialStatic;
11341134 result_ptr->type = get_pointer_to_type(g, result->type, false);
11351135 result_ptr->data.x_ptr.mut = ConstPtrMutComptimeVar;
......@@ -1230,7 +1230,7 @@ Error type_val_resolve_zero_bits(CodeGen *g, ZigValue *type_val, ZigType *parent
12301230Error type_val_resolve_is_opaque_type(CodeGen *g, ZigValue *type_val, bool *is_opaque_type) {
12311231 if (type_val->special != ConstValSpecialLazy) {
12321232 assert(type_val->special == ConstValSpecialStatic);
1233 if (type_val->data.x_type == g->builtin_types.entry_var) {
1233 if (type_val->data.x_type == g->builtin_types.entry_anytype) {
12341234 *is_opaque_type = false;
12351235 return ErrorNone;
12361236 }
......@@ -1853,10 +1853,10 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc
18531853 buf_sprintf("var args only allowed in functions with C calling convention"));
18541854 return g->builtin_types.entry_invalid;
18551855 }
1856 } else if (param_node->data.param_decl.var_token != nullptr) {
1856 } else if (param_node->data.param_decl.anytype_token != nullptr) {
18571857 if (!calling_convention_allows_zig_types(fn_type_id.cc)) {
18581858 add_node_error(g, param_node,
1859 buf_sprintf("parameter of type 'var' not allowed in function with calling convention '%s'",
1859 buf_sprintf("parameter of type 'anytype' not allowed in function with calling convention '%s'",
18601860 calling_convention_name(fn_type_id.cc)));
18611861 return g->builtin_types.entry_invalid;
18621862 }
......@@ -1942,10 +1942,10 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc
19421942 fn_entry->align_bytes = fn_type_id.alignment;
19431943 }
19441944
1945 if (fn_proto->return_var_token != nullptr) {
1945 if (fn_proto->return_anytype_token != nullptr) {
19461946 if (!calling_convention_allows_zig_types(fn_type_id.cc)) {
19471947 add_node_error(g, fn_proto->return_type,
1948 buf_sprintf("return type 'var' not allowed in function with calling convention '%s'",
1948 buf_sprintf("return type 'anytype' not allowed in function with calling convention '%s'",
19491949 calling_convention_name(fn_type_id.cc)));
19501950 return g->builtin_types.entry_invalid;
19511951 }
......@@ -3802,7 +3802,7 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) {
38023802 case NodeTypeEnumLiteral:
38033803 case NodeTypeAnyFrameType:
38043804 case NodeTypeErrorSetField:
3805 case NodeTypeVarFieldType:
3805 case NodeTypeAnyTypeField:
38063806 zig_unreachable();
38073807 }
38083808}
......@@ -5868,7 +5868,7 @@ ZigValue *get_the_one_possible_value(CodeGen *g, ZigType *type_entry) {
58685868
58695869ReqCompTime type_requires_comptime(CodeGen *g, ZigType *ty) {
58705870 Error err;
5871 if (ty == g->builtin_types.entry_var) {
5871 if (ty == g->builtin_types.entry_anytype) {
58725872 return ReqCompTimeYes;
58735873 }
58745874 switch (ty->id) {
src/ast_render.cpp+8-8
......@@ -270,8 +270,8 @@ static const char *node_type_str(NodeType node_type) {
270270 return "EnumLiteral";
271271 case NodeTypeErrorSetField:
272272 return "ErrorSetField";
273 case NodeTypeVarFieldType:
274 return "VarFieldType";
273 case NodeTypeAnyTypeField:
274 return "AnyTypeField";
275275 }
276276 zig_unreachable();
277277}
......@@ -466,8 +466,8 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {
466466 }
467467 if (param_decl->data.param_decl.is_var_args) {
468468 fprintf(ar->f, "...");
469 } else if (param_decl->data.param_decl.var_token != nullptr) {
470 fprintf(ar->f, "var");
469 } else if (param_decl->data.param_decl.anytype_token != nullptr) {
470 fprintf(ar->f, "anytype");
471471 } else {
472472 render_node_grouped(ar, param_decl->data.param_decl.type);
473473 }
......@@ -496,8 +496,8 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {
496496 fprintf(ar->f, ")");
497497 }
498498
499 if (node->data.fn_proto.return_var_token != nullptr) {
500 fprintf(ar->f, "var");
499 if (node->data.fn_proto.return_anytype_token != nullptr) {
500 fprintf(ar->f, "anytype");
501501 } else {
502502 AstNode *return_type_node = node->data.fn_proto.return_type;
503503 assert(return_type_node != nullptr);
......@@ -1216,8 +1216,8 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {
12161216 fprintf(ar->f, ".%s", buf_ptr(&node->data.enum_literal.identifier->data.str_lit.str));
12171217 break;
12181218 }
1219 case NodeTypeVarFieldType: {
1220 fprintf(ar->f, "var");
1219 case NodeTypeAnyTypeField: {
1220 fprintf(ar->f, "anytype");
12211221 break;
12221222 }
12231223 case NodeTypeParamDecl:
src/codegen.cpp+2-2
......@@ -8448,8 +8448,8 @@ static void define_builtin_types(CodeGen *g) {
84488448 }
84498449 {
84508450 ZigType *entry = new_type_table_entry(ZigTypeIdOpaque);
8451 buf_init_from_str(&entry->name, "(var)");
8452 g->builtin_types.entry_var = entry;
8451 buf_init_from_str(&entry->name, "(anytype)");
8452 g->builtin_types.entry_anytype = entry;
84538453 }
84548454
84558455 for (size_t i = 0; i < array_length(c_int_type_infos); i += 1) {
src/ir.cpp+32-27
......@@ -9942,7 +9942,7 @@ static IrInstSrc *ir_gen_fn_proto(IrBuilderSrc *irb, Scope *parent_scope, AstNod
99429942 is_var_args = true;
99439943 break;
99449944 }
9945 if (param_node->data.param_decl.var_token == nullptr) {
9945 if (param_node->data.param_decl.anytype_token == nullptr) {
99469946 AstNode *type_node = param_node->data.param_decl.type;
99479947 IrInstSrc *type_value = ir_gen_node(irb, type_node, parent_scope);
99489948 if (type_value == irb->codegen->invalid_inst_src)
......@@ -9968,7 +9968,7 @@ static IrInstSrc *ir_gen_fn_proto(IrBuilderSrc *irb, Scope *parent_scope, AstNod
99689968 }
99699969
99709970 IrInstSrc *return_type;
9971 if (node->data.fn_proto.return_var_token == nullptr) {
9971 if (node->data.fn_proto.return_anytype_token == nullptr) {
99729972 if (node->data.fn_proto.return_type == nullptr) {
99739973 return_type = ir_build_const_type(irb, parent_scope, node, irb->codegen->builtin_types.entry_void);
99749974 } else {
......@@ -10226,9 +10226,9 @@ static IrInstSrc *ir_gen_node_raw(IrBuilderSrc *irb, AstNode *node, Scope *scope
1022610226 add_node_error(irb->codegen, node,
1022710227 buf_sprintf("inferred array size invalid here"));
1022810228 return irb->codegen->invalid_inst_src;
10229 case NodeTypeVarFieldType:
10229 case NodeTypeAnyTypeField:
1023010230 return ir_lval_wrap(irb, scope,
10231 ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_var), lval, result_loc);
10231 ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_anytype), lval, result_loc);
1023210232 }
1023310233 zig_unreachable();
1023410234}
......@@ -10296,7 +10296,7 @@ static IrInstSrc *ir_gen_node_extra(IrBuilderSrc *irb, AstNode *node, Scope *sco
1029610296 case NodeTypeSuspend:
1029710297 case NodeTypeEnumLiteral:
1029810298 case NodeTypeInferredArrayType:
10299 case NodeTypeVarFieldType:
10299 case NodeTypeAnyTypeField:
1030010300 case NodeTypePrefixOpExpr:
1030110301 add_node_error(irb->codegen, node,
1030210302 buf_sprintf("invalid left-hand side to assignment"));
......@@ -10518,7 +10518,7 @@ ZigValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ZigValue *const_va
1051810518 if (val == nullptr) return nullptr;
1051910519 assert(const_val->type->id == ZigTypeIdPointer);
1052010520 ZigType *expected_type = const_val->type->data.pointer.child_type;
10521 if (expected_type == codegen->builtin_types.entry_var) {
10521 if (expected_type == codegen->builtin_types.entry_anytype) {
1052210522 return val;
1052310523 }
1052410524 switch (type_has_one_possible_value(codegen, expected_type)) {
......@@ -15040,7 +15040,7 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, IrInst *source_instr,
1504015040 }
1504115041
1504215042 // This means the wanted type is anything.
15043 if (wanted_type == ira->codegen->builtin_types.entry_var) {
15043 if (wanted_type == ira->codegen->builtin_types.entry_anytype) {
1504415044 return value;
1504515045 }
1504615046
......@@ -15635,7 +15635,7 @@ static IrInstGen *ir_implicit_cast(IrAnalyze *ira, IrInstGen *value, ZigType *ex
1563515635static ZigType *get_ptr_elem_type(CodeGen *g, IrInstGen *ptr) {
1563615636 ir_assert_gen(ptr->value->type->id == ZigTypeIdPointer, ptr);
1563715637 ZigType *elem_type = ptr->value->type->data.pointer.child_type;
15638 if (elem_type != g->builtin_types.entry_var)
15638 if (elem_type != g->builtin_types.entry_anytype)
1563915639 return elem_type;
1564015640
1564115641 if (ir_resolve_lazy(g, ptr->base.source_node, ptr->value))
......@@ -15687,7 +15687,7 @@ static IrInstGen *ir_get_deref(IrAnalyze *ira, IrInst* source_instruction, IrIns
1568715687 }
1568815688 if (ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) {
1568915689 ZigValue *pointee = const_ptr_pointee_unchecked(ira->codegen, ptr->value);
15690 if (child_type == ira->codegen->builtin_types.entry_var) {
15690 if (child_type == ira->codegen->builtin_types.entry_anytype) {
1569115691 child_type = pointee->type;
1569215692 }
1569315693 if (pointee->special != ConstValSpecialRuntime) {
......@@ -19087,7 +19087,7 @@ static Error ir_result_has_type(IrAnalyze *ira, ResultLoc *result_loc, bool *out
1908719087 ZigType *dest_type = ir_resolve_type(ira, result_cast->base.source_instruction->child);
1908819088 if (type_is_invalid(dest_type))
1908919089 return ErrorSemanticAnalyzeFail;
19090 *out = (dest_type != ira->codegen->builtin_types.entry_var);
19090 *out = (dest_type != ira->codegen->builtin_types.entry_anytype);
1909119091 return ErrorNone;
1909219092 }
1909319093 case ResultLocIdVar:
......@@ -19293,7 +19293,7 @@ static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInst *suspend_source_i
1929319293 if (type_is_invalid(dest_type))
1929419294 return ira->codegen->invalid_inst_gen;
1929519295
19296 if (dest_type == ira->codegen->builtin_types.entry_var) {
19296 if (dest_type == ira->codegen->builtin_types.entry_anytype) {
1929719297 return ir_resolve_no_result_loc(ira, suspend_source_instr, result_loc, value_type);
1929819298 }
1929919299
......@@ -19439,7 +19439,7 @@ static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInst *suspend_source_i
1943919439 return ira->codegen->invalid_inst_gen;
1944019440 }
1944119441
19442 if (child_type != ira->codegen->builtin_types.entry_var) {
19442 if (child_type != ira->codegen->builtin_types.entry_anytype) {
1944319443 if (type_size(ira->codegen, child_type) != type_size(ira->codegen, value_type)) {
1944419444 // pointer cast won't work; we need a temporary location.
1944519445 result_bit_cast->parent->written = parent_was_written;
......@@ -19600,9 +19600,9 @@ static IrInstGen *ir_analyze_instruction_resolve_result(IrAnalyze *ira, IrInstSr
1960019600 if (type_is_invalid(implicit_elem_type))
1960119601 return ira->codegen->invalid_inst_gen;
1960219602 } else {
19603 implicit_elem_type = ira->codegen->builtin_types.entry_var;
19603 implicit_elem_type = ira->codegen->builtin_types.entry_anytype;
1960419604 }
19605 if (implicit_elem_type == ira->codegen->builtin_types.entry_var) {
19605 if (implicit_elem_type == ira->codegen->builtin_types.entry_anytype) {
1960619606 Buf *bare_name = buf_alloc();
1960719607 Buf *name = get_anon_type_name(ira->codegen, nullptr, container_string(ContainerKindStruct),
1960819608 instruction->base.base.scope, instruction->base.base.source_node, bare_name);
......@@ -19759,7 +19759,7 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node
1975919759 assert(param_decl_node->type == NodeTypeParamDecl);
1976019760
1976119761 IrInstGen *casted_arg;
19762 if (param_decl_node->data.param_decl.var_token == nullptr) {
19762 if (param_decl_node->data.param_decl.anytype_token == nullptr) {
1976319763 AstNode *param_type_node = param_decl_node->data.param_decl.type;
1976419764 ZigType *param_type = ir_analyze_type_expr(ira, *exec_scope, param_type_node);
1976519765 if (type_is_invalid(param_type))
......@@ -19799,7 +19799,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
1979919799 arg_part_of_generic_id = true;
1980019800 casted_arg = arg;
1980119801 } else {
19802 if (param_decl_node->data.param_decl.var_token == nullptr) {
19802 if (param_decl_node->data.param_decl.anytype_token == nullptr) {
1980319803 AstNode *param_type_node = param_decl_node->data.param_decl.type;
1980419804 ZigType *param_type = ir_analyze_type_expr(ira, *child_scope, param_type_node);
1980519805 if (type_is_invalid(param_type))
......@@ -20011,7 +20011,7 @@ static IrInstGen *ir_analyze_store_ptr(IrAnalyze *ira, IrInst* source_instr,
2001120011 }
2001220012
2001320013 if (ptr->value->type->data.pointer.inferred_struct_field != nullptr &&
20014 child_type == ira->codegen->builtin_types.entry_var)
20014 child_type == ira->codegen->builtin_types.entry_anytype)
2001520015 {
2001620016 child_type = ptr->value->type->data.pointer.inferred_struct_field->inferred_struct_type;
2001720017 }
......@@ -20202,6 +20202,11 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,
2020220202 }
2020320203
2020420204 AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type;
20205 if (return_type_node == nullptr) {
20206 ir_add_error(ira, &fn_ref->base,
20207 buf_sprintf("TODO implement inferred return types https://github.com/ziglang/zig/issues/447"));
20208 return ira->codegen->invalid_inst_gen;
20209 }
2020520210 ZigType *specified_return_type = ir_analyze_type_expr(ira, exec_scope, return_type_node);
2020620211 if (type_is_invalid(specified_return_type))
2020720212 return ira->codegen->invalid_inst_gen;
......@@ -20364,7 +20369,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,
2036420369 inst_fn_type_id.alignment = align_bytes;
2036520370 }
2036620371
20367 if (fn_proto_node->data.fn_proto.return_var_token == nullptr) {
20372 if (fn_proto_node->data.fn_proto.return_anytype_token == nullptr) {
2036820373 AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type;
2036920374 ZigType *specified_return_type = ir_analyze_type_expr(ira, impl_fn->child_scope, return_type_node);
2037020375 if (type_is_invalid(specified_return_type))
......@@ -20463,7 +20468,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,
2046320468 if (type_is_invalid(dummy_result->value->type))
2046420469 return ira->codegen->invalid_inst_gen;
2046520470 ZigType *res_child_type = result_loc->value->type->data.pointer.child_type;
20466 if (res_child_type == ira->codegen->builtin_types.entry_var) {
20471 if (res_child_type == ira->codegen->builtin_types.entry_anytype) {
2046720472 res_child_type = impl_fn_type_id->return_type;
2046820473 }
2046920474 if (!handle_is_ptr(ira->codegen, res_child_type)) {
......@@ -20606,7 +20611,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,
2060620611 if (type_is_invalid(dummy_result->value->type))
2060720612 return ira->codegen->invalid_inst_gen;
2060820613 ZigType *res_child_type = result_loc->value->type->data.pointer.child_type;
20609 if (res_child_type == ira->codegen->builtin_types.entry_var) {
20614 if (res_child_type == ira->codegen->builtin_types.entry_anytype) {
2061020615 res_child_type = return_type;
2061120616 }
2061220617 if (!handle_is_ptr(ira->codegen, res_child_type)) {
......@@ -22337,7 +22342,7 @@ static IrInstGen *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_name,
2233722342 inferred_struct_field->inferred_struct_type = container_type;
2233822343 inferred_struct_field->field_name = field_name;
2233922344
22340 ZigType *elem_type = ira->codegen->builtin_types.entry_var;
22345 ZigType *elem_type = ira->codegen->builtin_types.entry_anytype;
2234122346 ZigType *field_ptr_type = get_pointer_to_type_extra2(ira->codegen, elem_type,
2234222347 container_ptr_type->data.pointer.is_const, container_ptr_type->data.pointer.is_volatile,
2234322348 PtrLenSingle, 0, 0, 0, false, VECTOR_INDEX_NONE, inferred_struct_field, nullptr);
......@@ -25115,7 +25120,7 @@ static ZigValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_type_ent
2511525120 fields[5]->special = ConstValSpecialStatic;
2511625121 fields[5]->type = ira->codegen->builtin_types.entry_bool;
2511725122 fields[5]->data.x_bool = attrs_type->data.pointer.allow_zero;
25118 // sentinel: var
25123 // sentinel: anytype
2511925124 ensure_field_index(result->type, "sentinel", 6);
2512025125 fields[6]->special = ConstValSpecialStatic;
2512125126 if (attrs_type->data.pointer.child_type->id != ZigTypeIdOpaque) {
......@@ -25243,7 +25248,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy
2524325248 fields[1]->special = ConstValSpecialStatic;
2524425249 fields[1]->type = ira->codegen->builtin_types.entry_type;
2524525250 fields[1]->data.x_type = type_entry->data.array.child_type;
25246 // sentinel: var
25251 // sentinel: anytype
2524725252 fields[2]->special = ConstValSpecialStatic;
2524825253 fields[2]->type = get_optional_type(ira->codegen, type_entry->data.array.child_type);
2524925254 fields[2]->data.x_optional = type_entry->data.array.sentinel;
......@@ -25598,7 +25603,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy
2559825603 inner_fields[2]->type = ira->codegen->builtin_types.entry_type;
2559925604 inner_fields[2]->data.x_type = struct_field->type_entry;
2560025605
25601 // default_value: var
25606 // default_value: anytype
2560225607 inner_fields[3]->special = ConstValSpecialStatic;
2560325608 inner_fields[3]->type = get_optional_type2(ira->codegen, struct_field->type_entry);
2560425609 if (inner_fields[3]->type == nullptr) return ErrorSemanticAnalyzeFail;
......@@ -25736,7 +25741,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy
2573625741 ZigValue **fields = alloc_const_vals_ptrs(ira->codegen, 1);
2573725742 result->data.x_struct.fields = fields;
2573825743 ZigFn *fn = type_entry->data.frame.fn;
25739 // function: var
25744 // function: anytype
2574025745 ensure_field_index(result->type, "function", 0);
2574125746 fields[0] = create_const_fn(ira->codegen, fn);
2574225747 break;
......@@ -29996,7 +30001,7 @@ static IrInstGen *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstSrcArgTy
2999630001 if (arg_index >= fn_type_id->param_count) {
2999730002 if (instruction->allow_var) {
2999830003 // TODO remove this with var args
29999 return ir_const_type(ira, &instruction->base.base, ira->codegen->builtin_types.entry_var);
30004 return ir_const_type(ira, &instruction->base.base, ira->codegen->builtin_types.entry_anytype);
3000030005 }
3000130006 ir_add_error(ira, &arg_index_inst->base,
3000230007 buf_sprintf("arg index %" ZIG_PRI_u64 " out of bounds; '%s' has %" ZIG_PRI_usize " arguments",
......@@ -30010,7 +30015,7 @@ static IrInstGen *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstSrcArgTy
3001030015 ir_assert(fn_type->data.fn.is_generic, &instruction->base.base);
3001130016
3001230017 if (instruction->allow_var) {
30013 return ir_const_type(ira, &instruction->base.base, ira->codegen->builtin_types.entry_var);
30018 return ir_const_type(ira, &instruction->base.base, ira->codegen->builtin_types.entry_anytype);
3001430019 } else {
3001530020 ir_add_error(ira, &arg_index_inst->base,
3001630021 buf_sprintf("@ArgType could not resolve the type of arg %" ZIG_PRI_u64 " because '%s' is generic",
src/parser.cpp+13-13
......@@ -786,7 +786,7 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B
786786 return nullptr;
787787}
788788
789// FnProto <- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_var / TypeExpr)
789// FnProto <- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_anytype / TypeExpr)
790790static AstNode *ast_parse_fn_proto(ParseContext *pc) {
791791 Token *first = eat_token_if(pc, TokenIdKeywordFn);
792792 if (first == nullptr) {
......@@ -801,10 +801,10 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) {
801801 AstNode *align_expr = ast_parse_byte_align(pc);
802802 AstNode *section_expr = ast_parse_link_section(pc);
803803 AstNode *callconv_expr = ast_parse_callconv(pc);
804 Token *var = eat_token_if(pc, TokenIdKeywordVar);
804 Token *anytype = eat_token_if(pc, TokenIdKeywordAnyType);
805805 Token *exmark = nullptr;
806806 AstNode *return_type = nullptr;
807 if (var == nullptr) {
807 if (anytype == nullptr) {
808808 exmark = eat_token_if(pc, TokenIdBang);
809809 return_type = ast_expect(pc, ast_parse_type_expr);
810810 }
......@@ -816,7 +816,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) {
816816 res->data.fn_proto.align_expr = align_expr;
817817 res->data.fn_proto.section_expr = section_expr;
818818 res->data.fn_proto.callconv_expr = callconv_expr;
819 res->data.fn_proto.return_var_token = var;
819 res->data.fn_proto.return_anytype_token = anytype;
820820 res->data.fn_proto.auto_err_set = exmark != nullptr;
821821 res->data.fn_proto.return_type = return_type;
822822
......@@ -870,9 +870,9 @@ static AstNode *ast_parse_container_field(ParseContext *pc) {
870870
871871 AstNode *type_expr = nullptr;
872872 if (eat_token_if(pc, TokenIdColon) != nullptr) {
873 Token *var_tok = eat_token_if(pc, TokenIdKeywordVar);
874 if (var_tok != nullptr) {
875 type_expr = ast_create_node(pc, NodeTypeVarFieldType, var_tok);
873 Token *anytype_tok = eat_token_if(pc, TokenIdKeywordAnyType);
874 if (anytype_tok != nullptr) {
875 type_expr = ast_create_node(pc, NodeTypeAnyTypeField, anytype_tok);
876876 } else {
877877 type_expr = ast_expect(pc, ast_parse_type_expr);
878878 }
......@@ -2191,14 +2191,14 @@ static AstNode *ast_parse_param_decl(ParseContext *pc) {
21912191}
21922192
21932193// ParamType
2194// <- KEYWORD_var
2194// <- KEYWORD_anytype
21952195// / DOT3
21962196// / TypeExpr
21972197static AstNode *ast_parse_param_type(ParseContext *pc) {
2198 Token *var_token = eat_token_if(pc, TokenIdKeywordVar);
2199 if (var_token != nullptr) {
2200 AstNode *res = ast_create_node(pc, NodeTypeParamDecl, var_token);
2201 res->data.param_decl.var_token = var_token;
2198 Token *anytype_token = eat_token_if(pc, TokenIdKeywordAnyType);
2199 if (anytype_token != nullptr) {
2200 AstNode *res = ast_create_node(pc, NodeTypeParamDecl, anytype_token);
2201 res->data.param_decl.anytype_token = anytype_token;
22022202 return res;
22032203 }
22042204
......@@ -3207,7 +3207,7 @@ void ast_visit_node_children(AstNode *node, void (*visit)(AstNode **, void *cont
32073207 visit_field(&node->data.suspend.block, visit, context);
32083208 break;
32093209 case NodeTypeEnumLiteral:
3210 case NodeTypeVarFieldType:
3210 case NodeTypeAnyTypeField:
32113211 break;
32123212 }
32133213}
src/tokenizer.cpp+2
......@@ -106,6 +106,7 @@ static const struct ZigKeyword zig_keywords[] = {
106106 {"allowzero", TokenIdKeywordAllowZero},
107107 {"and", TokenIdKeywordAnd},
108108 {"anyframe", TokenIdKeywordAnyFrame},
109 {"anytype", TokenIdKeywordAnyType},
109110 {"asm", TokenIdKeywordAsm},
110111 {"async", TokenIdKeywordAsync},
111112 {"await", TokenIdKeywordAwait},
......@@ -1569,6 +1570,7 @@ const char * token_name(TokenId id) {
15691570 case TokenIdKeywordAlign: return "align";
15701571 case TokenIdKeywordAnd: return "and";
15711572 case TokenIdKeywordAnyFrame: return "anyframe";
1573 case TokenIdKeywordAnyType: return "anytype";
15721574 case TokenIdKeywordAsm: return "asm";
15731575 case TokenIdKeywordBreak: return "break";
15741576 case TokenIdKeywordCatch: return "catch";
src/tokenizer.hpp+1
......@@ -54,6 +54,7 @@ enum TokenId {
5454 TokenIdKeywordAllowZero,
5555 TokenIdKeywordAnd,
5656 TokenIdKeywordAnyFrame,
57 TokenIdKeywordAnyType,
5758 TokenIdKeywordAsm,
5859 TokenIdKeywordAsync,
5960 TokenIdKeywordAwait,