| author | |
| committer | |
| log | 8110639c7964fcb23c2b715f97ab6caa27506b93 |
| tree | 9556ad058e4001c0f0789a0fc82fc570e2d91d32 |
| parent | c2fb4bfff3b1a2bf4e7072cec04d67e8152900c1 |
| signature | Commit is signed but in an unrecognized format. |
9 files changed, 114 insertions(+), 105 deletions(-)
doc/langref.html.in+44-43| ... | @@ -1785,7 +1785,7 @@ test "fully anonymous list literal" { | ... | @@ -1785,7 +1785,7 @@ test "fully anonymous list literal" { |
| 1785 | dump(.{ @as(u32, 1234), @as(f64, 12.34), true, "hi"}); | 1785 | dump(.{ @as(u32, 1234), @as(f64, 12.34), true, "hi"}); |
| 1786 | } | 1786 | } |
| 1787 | 1787 | ||
| 1788 | fn dump(args: var) void { | 1788 | fn dump(args: anytype) void { |
| 1789 | assert(args.@"0" == 1234); | 1789 | assert(args.@"0" == 1234); |
| 1790 | assert(args.@"1" == 12.34); | 1790 | assert(args.@"1" == 12.34); |
| 1791 | assert(args.@"2"); | 1791 | assert(args.@"2"); |
| ... | @@ -2717,7 +2717,7 @@ test "fully anonymous struct" { | ... | @@ -2717,7 +2717,7 @@ test "fully anonymous struct" { |
| 2717 | }); | 2717 | }); |
| 2718 | } | 2718 | } |
| 2719 | 2719 | ||
| 2720 | fn dump(args: var) void { | 2720 | fn dump(args: anytype) void { |
| 2721 | assert(args.int == 1234); | 2721 | assert(args.int == 1234); |
| 2722 | assert(args.float == 12.34); | 2722 | assert(args.float == 12.34); |
| 2723 | assert(args.b); | 2723 | assert(args.b); |
| ... | @@ -4181,14 +4181,14 @@ test "pass struct to function" { | ... | @@ -4181,14 +4181,14 @@ test "pass struct to function" { |
| 4181 | {#header_close#} | 4181 | {#header_close#} |
| 4182 | {#header_open|Function Parameter Type Inference#} | 4182 | {#header_open|Function Parameter Type Inference#} |
| 4183 | <p> | 4183 | <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. |
| 4185 | In this case the parameter types will be inferred when the function is called. | 4185 | In this case the parameter types will be inferred when the function is called. |
| 4186 | Use {#link|@TypeOf#} and {#link|@typeInfo#} to get information about the inferred type. | 4186 | Use {#link|@TypeOf#} and {#link|@typeInfo#} to get information about the inferred type. |
| 4187 | </p> | 4187 | </p> |
| 4188 | {#code_begin|test#} | 4188 | {#code_begin|test#} |
| 4189 | const assert = @import("std").debug.assert; | 4189 | const assert = @import("std").debug.assert; |
| 4190 | 4190 | ||
| 4191 | fn addFortyTwo(x: var) @TypeOf(x) { | 4191 | fn addFortyTwo(x: anytype) @TypeOf(x) { |
| 4192 | return x + 42; | 4192 | return x + 42; |
| 4193 | } | 4193 | } |
| 4194 | 4194 | ||
| ... | @@ -5974,7 +5974,7 @@ pub fn main() void { | ... | @@ -5974,7 +5974,7 @@ pub fn main() void { |
| 5974 | 5974 | ||
| 5975 | {#code_begin|syntax#} | 5975 | {#code_begin|syntax#} |
| 5976 | /// Calls print and then flushes the buffer. | 5976 | /// Calls print and then flushes the buffer. |
| 5977 | pub fn printf(self: *OutStream, comptime format: []const u8, args: var) anyerror!void { | 5977 | pub fn printf(self: *OutStream, comptime format: []const u8, args: anytype) anyerror!void { |
| 5978 | const State = enum { | 5978 | const State = enum { |
| 5979 | Start, | 5979 | Start, |
| 5980 | OpenBrace, | 5980 | OpenBrace, |
| ... | @@ -6060,7 +6060,7 @@ pub fn printf(self: *OutStream, arg0: i32, arg1: []const u8) !void { | ... | @@ -6060,7 +6060,7 @@ pub fn printf(self: *OutStream, arg0: i32, arg1: []const u8) !void { |
| 6060 | on the type: | 6060 | on the type: |
| 6061 | </p> | 6061 | </p> |
| 6062 | {#code_begin|syntax#} | 6062 | {#code_begin|syntax#} |
| 6063 | pub fn printValue(self: *OutStream, value: var) !void { | 6063 | pub fn printValue(self: *OutStream, value: anytype) !void { |
| 6064 | switch (@typeInfo(@TypeOf(value))) { | 6064 | switch (@typeInfo(@TypeOf(value))) { |
| 6065 | .Int => { | 6065 | .Int => { |
| 6066 | return self.printInt(T, value); | 6066 | return self.printInt(T, value); |
| ... | @@ -6686,7 +6686,7 @@ fn readFile(allocator: *Allocator, filename: []const u8) ![]u8 { | ... | @@ -6686,7 +6686,7 @@ fn readFile(allocator: *Allocator, filename: []const u8) ![]u8 { |
| 6686 | </p> | 6686 | </p> |
| 6687 | {#header_close#} | 6687 | {#header_close#} |
| 6688 | {#header_open|@alignCast#} | 6688 | {#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> |
| 6690 | <p> | 6690 | <p> |
| 6691 | {#syntax#}ptr{#endsyntax#} can be {#syntax#}*T{#endsyntax#}, {#syntax#}fn(){#endsyntax#}, {#syntax#}?*T{#endsyntax#}, | 6691 | {#syntax#}ptr{#endsyntax#} can be {#syntax#}*T{#endsyntax#}, {#syntax#}fn(){#endsyntax#}, {#syntax#}?*T{#endsyntax#}, |
| 6692 | {#syntax#}?fn(){#endsyntax#}, or {#syntax#}[]T{#endsyntax#}. It returns the same type as {#syntax#}ptr{#endsyntax#} | 6692 | {#syntax#}?fn(){#endsyntax#}, or {#syntax#}[]T{#endsyntax#}. It returns the same type as {#syntax#}ptr{#endsyntax#} |
| ... | @@ -6723,7 +6723,7 @@ comptime { | ... | @@ -6723,7 +6723,7 @@ comptime { |
| 6723 | {#header_close#} | 6723 | {#header_close#} |
| 6724 | 6724 | ||
| 6725 | {#header_open|@asyncCall#} | 6725 | {#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> |
| 6727 | <p> | 6727 | <p> |
| 6728 | {#syntax#}@asyncCall{#endsyntax#} performs an {#syntax#}async{#endsyntax#} call on a function pointer, | 6728 | {#syntax#}@asyncCall{#endsyntax#} performs an {#syntax#}async{#endsyntax#} call on a function pointer, |
| 6729 | which may or may not be an {#link|async function|Async Functions#}. | 6729 | which may or may not be an {#link|async function|Async Functions#}. |
| ... | @@ -6811,7 +6811,7 @@ fn func(y: *i32) void { | ... | @@ -6811,7 +6811,7 @@ fn func(y: *i32) void { |
| 6811 | </p> | 6811 | </p> |
| 6812 | {#header_close#} | 6812 | {#header_close#} |
| 6813 | {#header_open|@bitCast#} | 6813 | {#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> |
| 6815 | <p> | 6815 | <p> |
| 6816 | Converts a value of one type to another type. | 6816 | Converts a value of one type to another type. |
| 6817 | </p> | 6817 | </p> |
| ... | @@ -6932,7 +6932,7 @@ fn func(y: *i32) void { | ... | @@ -6932,7 +6932,7 @@ fn func(y: *i32) void { |
| 6932 | {#header_close#} | 6932 | {#header_close#} |
| 6933 | 6933 | ||
| 6934 | {#header_open|@call#} | 6934 | {#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> |
| 6936 | <p> | 6936 | <p> |
| 6937 | Calls a function, in the same way that invoking an expression with parentheses does: | 6937 | Calls a function, in the same way that invoking an expression with parentheses does: |
| 6938 | </p> | 6938 | </p> |
| ... | @@ -7279,7 +7279,7 @@ test "main" { | ... | @@ -7279,7 +7279,7 @@ test "main" { |
| 7279 | {#header_close#} | 7279 | {#header_close#} |
| 7280 | 7280 | ||
| 7281 | {#header_open|@enumToInt#} | 7281 | {#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> |
| 7283 | <p> | 7283 | <p> |
| 7284 | Converts an enumeration value into its integer tag type. When a tagged union is passed, | 7284 | Converts an enumeration value into its integer tag type. When a tagged union is passed, |
| 7285 | the tag value is used as the enumeration value. | 7285 | the tag value is used as the enumeration value. |
| ... | @@ -7314,7 +7314,7 @@ test "main" { | ... | @@ -7314,7 +7314,7 @@ test "main" { |
| 7314 | {#header_close#} | 7314 | {#header_close#} |
| 7315 | 7315 | ||
| 7316 | {#header_open|@errorToInt#} | 7316 | {#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> |
| 7318 | <p> | 7318 | <p> |
| 7319 | Supports the following types: | 7319 | Supports the following types: |
| 7320 | </p> | 7320 | </p> |
| ... | @@ -7334,7 +7334,7 @@ test "main" { | ... | @@ -7334,7 +7334,7 @@ test "main" { |
| 7334 | {#header_close#} | 7334 | {#header_close#} |
| 7335 | 7335 | ||
| 7336 | {#header_open|@errSetCast#} | 7336 | {#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> |
| 7338 | <p> | 7338 | <p> |
| 7339 | Converts an error value from one error set to another error set. Attempting to convert an error | 7339 | Converts an error value from one error set to another error set. Attempting to convert an error |
| 7340 | which is not in the destination error set results in safety-protected {#link|Undefined Behavior#}. | 7340 | which is not in the destination error set results in safety-protected {#link|Undefined Behavior#}. |
| ... | @@ -7342,7 +7342,7 @@ test "main" { | ... | @@ -7342,7 +7342,7 @@ test "main" { |
| 7342 | {#header_close#} | 7342 | {#header_close#} |
| 7343 | 7343 | ||
| 7344 | {#header_open|@export#} | 7344 | {#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> |
| 7346 | <p> | 7346 | <p> |
| 7347 | Creates a symbol in the output object file. | 7347 | Creates a symbol in the output object file. |
| 7348 | </p> | 7348 | </p> |
| ... | @@ -7387,7 +7387,7 @@ export fn @"A function name that is a complete sentence."() void {} | ... | @@ -7387,7 +7387,7 @@ export fn @"A function name that is a complete sentence."() void {} |
| 7387 | {#header_close#} | 7387 | {#header_close#} |
| 7388 | 7388 | ||
| 7389 | {#header_open|@field#} | 7389 | {#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> |
| 7391 | <p>Performs field access by a compile-time string. | 7391 | <p>Performs field access by a compile-time string. |
| 7392 | </p> | 7392 | </p> |
| 7393 | {#code_begin|test#} | 7393 | {#code_begin|test#} |
| ... | @@ -7421,7 +7421,7 @@ test "field access by string" { | ... | @@ -7421,7 +7421,7 @@ test "field access by string" { |
| 7421 | {#header_close#} | 7421 | {#header_close#} |
| 7422 | 7422 | ||
| 7423 | {#header_open|@floatCast#} | 7423 | {#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> |
| 7425 | <p> | 7425 | <p> |
| 7426 | Convert from one float type to another. This cast is safe, but may cause the | 7426 | Convert from one float type to another. This cast is safe, but may cause the |
| 7427 | numeric value to lose precision. | 7427 | numeric value to lose precision. |
| ... | @@ -7429,7 +7429,7 @@ test "field access by string" { | ... | @@ -7429,7 +7429,7 @@ test "field access by string" { |
| 7429 | {#header_close#} | 7429 | {#header_close#} |
| 7430 | 7430 | ||
| 7431 | {#header_open|@floatToInt#} | 7431 | {#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> |
| 7433 | <p> | 7433 | <p> |
| 7434 | Converts the integer part of a floating point number to the destination type. | 7434 | Converts the integer part of a floating point number to the destination type. |
| 7435 | </p> | 7435 | </p> |
| ... | @@ -7455,7 +7455,7 @@ test "field access by string" { | ... | @@ -7455,7 +7455,7 @@ test "field access by string" { |
| 7455 | {#header_close#} | 7455 | {#header_close#} |
| 7456 | 7456 | ||
| 7457 | {#header_open|@Frame#} | 7457 | {#header_open|@Frame#} |
| 7458 | <pre>{#syntax#}@Frame(func: var) type{#endsyntax#}</pre> | 7458 | <pre>{#syntax#}@Frame(func: anytype) type{#endsyntax#}</pre> |
| 7459 | <p> | 7459 | <p> |
| 7460 | This function returns the frame type of a function. This works for {#link|Async Functions#} | 7460 | This function returns the frame type of a function. This works for {#link|Async Functions#} |
| 7461 | as well as any function without a specific calling convention. | 7461 | as well as any function without a specific calling convention. |
| ... | @@ -7581,7 +7581,7 @@ test "@hasDecl" { | ... | @@ -7581,7 +7581,7 @@ test "@hasDecl" { |
| 7581 | {#header_close#} | 7581 | {#header_close#} |
| 7582 | 7582 | ||
| 7583 | {#header_open|@intCast#} | 7583 | {#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> |
| 7585 | <p> | 7585 | <p> |
| 7586 | Converts an integer to another integer while keeping the same numerical value. | 7586 | Converts an integer to another integer while keeping the same numerical value. |
| 7587 | Attempting to convert a number which is out of range of the destination type results in | 7587 | Attempting to convert a number which is out of range of the destination type results in |
| ... | @@ -7622,7 +7622,7 @@ test "@hasDecl" { | ... | @@ -7622,7 +7622,7 @@ test "@hasDecl" { |
| 7622 | {#header_close#} | 7622 | {#header_close#} |
| 7623 | 7623 | ||
| 7624 | {#header_open|@intToFloat#} | 7624 | {#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> |
| 7626 | <p> | 7626 | <p> |
| 7627 | Converts an integer to the closest floating point representation. To convert the other way, use {#link|@floatToInt#}. This cast is always safe. | 7627 | Converts an integer to the closest floating point representation. To convert the other way, use {#link|@floatToInt#}. This cast is always safe. |
| 7628 | </p> | 7628 | </p> |
| ... | @@ -7773,7 +7773,7 @@ test "@wasmMemoryGrow" { | ... | @@ -7773,7 +7773,7 @@ test "@wasmMemoryGrow" { |
| 7773 | {#header_close#} | 7773 | {#header_close#} |
| 7774 | 7774 | ||
| 7775 | {#header_open|@ptrCast#} | 7775 | {#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> |
| 7777 | <p> | 7777 | <p> |
| 7778 | Converts a pointer of one type to a pointer of another type. | 7778 | Converts a pointer of one type to a pointer of another type. |
| 7779 | </p> | 7779 | </p> |
| ... | @@ -7784,7 +7784,7 @@ test "@wasmMemoryGrow" { | ... | @@ -7784,7 +7784,7 @@ test "@wasmMemoryGrow" { |
| 7784 | {#header_close#} | 7784 | {#header_close#} |
| 7785 | 7785 | ||
| 7786 | {#header_open|@ptrToInt#} | 7786 | {#header_open|@ptrToInt#} |
| 7787 | <pre>{#syntax#}@ptrToInt(value: var) usize{#endsyntax#}</pre> | 7787 | <pre>{#syntax#}@ptrToInt(value: anytype) usize{#endsyntax#}</pre> |
| 7788 | <p> | 7788 | <p> |
| 7789 | 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: | 7789 | 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: |
| 7790 | </p> | 7790 | </p> |
| ... | @@ -8042,7 +8042,7 @@ test "@setRuntimeSafety" { | ... | @@ -8042,7 +8042,7 @@ test "@setRuntimeSafety" { |
| 8042 | {#header_close#} | 8042 | {#header_close#} |
| 8043 | 8043 | ||
| 8044 | {#header_open|@splat#} | 8044 | {#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> |
| 8046 | <p> | 8046 | <p> |
| 8047 | Produces a vector of length {#syntax#}len{#endsyntax#} where each element is the value | 8047 | Produces a vector of length {#syntax#}len{#endsyntax#} where each element is the value |
| 8048 | {#syntax#}scalar{#endsyntax#}: | 8048 | {#syntax#}scalar{#endsyntax#}: |
| ... | @@ -8088,7 +8088,7 @@ fn doTheTest() void { | ... | @@ -8088,7 +8088,7 @@ fn doTheTest() void { |
| 8088 | {#code_end#} | 8088 | {#code_end#} |
| 8089 | {#header_close#} | 8089 | {#header_close#} |
| 8090 | {#header_open|@sqrt#} | 8090 | {#header_open|@sqrt#} |
| 8091 | <pre>{#syntax#}@sqrt(value: var) @TypeOf(value){#endsyntax#}</pre> | 8091 | <pre>{#syntax#}@sqrt(value: anytype) @TypeOf(value){#endsyntax#}</pre> |
| 8092 | <p> | 8092 | <p> |
| 8093 | Performs the square root of a floating point number. Uses a dedicated hardware instruction | 8093 | Performs the square root of a floating point number. Uses a dedicated hardware instruction |
| 8094 | when available. | 8094 | when available. |
| ... | @@ -8099,7 +8099,7 @@ fn doTheTest() void { | ... | @@ -8099,7 +8099,7 @@ fn doTheTest() void { |
| 8099 | </p> | 8099 | </p> |
| 8100 | {#header_close#} | 8100 | {#header_close#} |
| 8101 | {#header_open|@sin#} | 8101 | {#header_open|@sin#} |
| 8102 | <pre>{#syntax#}@sin(value: var) @TypeOf(value){#endsyntax#}</pre> | 8102 | <pre>{#syntax#}@sin(value: anytype) @TypeOf(value){#endsyntax#}</pre> |
| 8103 | <p> | 8103 | <p> |
| 8104 | Sine trigometric function on a floating point number. Uses a dedicated hardware instruction | 8104 | Sine trigometric function on a floating point number. Uses a dedicated hardware instruction |
| 8105 | when available. | 8105 | when available. |
| ... | @@ -8110,7 +8110,7 @@ fn doTheTest() void { | ... | @@ -8110,7 +8110,7 @@ fn doTheTest() void { |
| 8110 | </p> | 8110 | </p> |
| 8111 | {#header_close#} | 8111 | {#header_close#} |
| 8112 | {#header_open|@cos#} | 8112 | {#header_open|@cos#} |
| 8113 | <pre>{#syntax#}@cos(value: var) @TypeOf(value){#endsyntax#}</pre> | 8113 | <pre>{#syntax#}@cos(value: anytype) @TypeOf(value){#endsyntax#}</pre> |
| 8114 | <p> | 8114 | <p> |
| 8115 | Cosine trigometric function on a floating point number. Uses a dedicated hardware instruction | 8115 | Cosine trigometric function on a floating point number. Uses a dedicated hardware instruction |
| 8116 | when available. | 8116 | when available. |
| ... | @@ -8121,7 +8121,7 @@ fn doTheTest() void { | ... | @@ -8121,7 +8121,7 @@ fn doTheTest() void { |
| 8121 | </p> | 8121 | </p> |
| 8122 | {#header_close#} | 8122 | {#header_close#} |
| 8123 | {#header_open|@exp#} | 8123 | {#header_open|@exp#} |
| 8124 | <pre>{#syntax#}@exp(value: var) @TypeOf(value){#endsyntax#}</pre> | 8124 | <pre>{#syntax#}@exp(value: anytype) @TypeOf(value){#endsyntax#}</pre> |
| 8125 | <p> | 8125 | <p> |
| 8126 | Base-e exponential function on a floating point number. Uses a dedicated hardware instruction | 8126 | Base-e exponential function on a floating point number. Uses a dedicated hardware instruction |
| 8127 | when available. | 8127 | when available. |
| ... | @@ -8132,7 +8132,7 @@ fn doTheTest() void { | ... | @@ -8132,7 +8132,7 @@ fn doTheTest() void { |
| 8132 | </p> | 8132 | </p> |
| 8133 | {#header_close#} | 8133 | {#header_close#} |
| 8134 | {#header_open|@exp2#} | 8134 | {#header_open|@exp2#} |
| 8135 | <pre>{#syntax#}@exp2(value: var) @TypeOf(value){#endsyntax#}</pre> | 8135 | <pre>{#syntax#}@exp2(value: anytype) @TypeOf(value){#endsyntax#}</pre> |
| 8136 | <p> | 8136 | <p> |
| 8137 | Base-2 exponential function on a floating point number. Uses a dedicated hardware instruction | 8137 | Base-2 exponential function on a floating point number. Uses a dedicated hardware instruction |
| 8138 | when available. | 8138 | when available. |
| ... | @@ -8143,7 +8143,7 @@ fn doTheTest() void { | ... | @@ -8143,7 +8143,7 @@ fn doTheTest() void { |
| 8143 | </p> | 8143 | </p> |
| 8144 | {#header_close#} | 8144 | {#header_close#} |
| 8145 | {#header_open|@log#} | 8145 | {#header_open|@log#} |
| 8146 | <pre>{#syntax#}@log(value: var) @TypeOf(value){#endsyntax#}</pre> | 8146 | <pre>{#syntax#}@log(value: anytype) @TypeOf(value){#endsyntax#}</pre> |
| 8147 | <p> | 8147 | <p> |
| 8148 | Returns the natural logarithm of a floating point number. Uses a dedicated hardware instruction | 8148 | Returns the natural logarithm of a floating point number. Uses a dedicated hardware instruction |
| 8149 | when available. | 8149 | when available. |
| ... | @@ -8154,7 +8154,7 @@ fn doTheTest() void { | ... | @@ -8154,7 +8154,7 @@ fn doTheTest() void { |
| 8154 | </p> | 8154 | </p> |
| 8155 | {#header_close#} | 8155 | {#header_close#} |
| 8156 | {#header_open|@log2#} | 8156 | {#header_open|@log2#} |
| 8157 | <pre>{#syntax#}@log2(value: var) @TypeOf(value){#endsyntax#}</pre> | 8157 | <pre>{#syntax#}@log2(value: anytype) @TypeOf(value){#endsyntax#}</pre> |
| 8158 | <p> | 8158 | <p> |
| 8159 | Returns the logarithm to the base 2 of a floating point number. Uses a dedicated hardware instruction | 8159 | Returns the logarithm to the base 2 of a floating point number. Uses a dedicated hardware instruction |
| 8160 | when available. | 8160 | when available. |
| ... | @@ -8165,7 +8165,7 @@ fn doTheTest() void { | ... | @@ -8165,7 +8165,7 @@ fn doTheTest() void { |
| 8165 | </p> | 8165 | </p> |
| 8166 | {#header_close#} | 8166 | {#header_close#} |
| 8167 | {#header_open|@log10#} | 8167 | {#header_open|@log10#} |
| 8168 | <pre>{#syntax#}@log10(value: var) @TypeOf(value){#endsyntax#}</pre> | 8168 | <pre>{#syntax#}@log10(value: anytype) @TypeOf(value){#endsyntax#}</pre> |
| 8169 | <p> | 8169 | <p> |
| 8170 | Returns the logarithm to the base 10 of a floating point number. Uses a dedicated hardware instruction | 8170 | Returns the logarithm to the base 10 of a floating point number. Uses a dedicated hardware instruction |
| 8171 | when available. | 8171 | when available. |
| ... | @@ -8176,7 +8176,7 @@ fn doTheTest() void { | ... | @@ -8176,7 +8176,7 @@ fn doTheTest() void { |
| 8176 | </p> | 8176 | </p> |
| 8177 | {#header_close#} | 8177 | {#header_close#} |
| 8178 | {#header_open|@fabs#} | 8178 | {#header_open|@fabs#} |
| 8179 | <pre>{#syntax#}@fabs(value: var) @TypeOf(value){#endsyntax#}</pre> | 8179 | <pre>{#syntax#}@fabs(value: anytype) @TypeOf(value){#endsyntax#}</pre> |
| 8180 | <p> | 8180 | <p> |
| 8181 | Returns the absolute value of a floating point number. Uses a dedicated hardware instruction | 8181 | Returns the absolute value of a floating point number. Uses a dedicated hardware instruction |
| 8182 | when available. | 8182 | when available. |
| ... | @@ -8187,7 +8187,7 @@ fn doTheTest() void { | ... | @@ -8187,7 +8187,7 @@ fn doTheTest() void { |
| 8187 | </p> | 8187 | </p> |
| 8188 | {#header_close#} | 8188 | {#header_close#} |
| 8189 | {#header_open|@floor#} | 8189 | {#header_open|@floor#} |
| 8190 | <pre>{#syntax#}@floor(value: var) @TypeOf(value){#endsyntax#}</pre> | 8190 | <pre>{#syntax#}@floor(value: anytype) @TypeOf(value){#endsyntax#}</pre> |
| 8191 | <p> | 8191 | <p> |
| 8192 | Returns the largest integral value not greater than the given floating point number. | 8192 | Returns the largest integral value not greater than the given floating point number. |
| 8193 | Uses a dedicated hardware instruction when available. | 8193 | Uses a dedicated hardware instruction when available. |
| ... | @@ -8198,7 +8198,7 @@ fn doTheTest() void { | ... | @@ -8198,7 +8198,7 @@ fn doTheTest() void { |
| 8198 | </p> | 8198 | </p> |
| 8199 | {#header_close#} | 8199 | {#header_close#} |
| 8200 | {#header_open|@ceil#} | 8200 | {#header_open|@ceil#} |
| 8201 | <pre>{#syntax#}@ceil(value: var) @TypeOf(value){#endsyntax#}</pre> | 8201 | <pre>{#syntax#}@ceil(value: anytype) @TypeOf(value){#endsyntax#}</pre> |
| 8202 | <p> | 8202 | <p> |
| 8203 | Returns the largest integral value not less than the given floating point number. | 8203 | Returns the largest integral value not less than the given floating point number. |
| 8204 | Uses a dedicated hardware instruction when available. | 8204 | Uses a dedicated hardware instruction when available. |
| ... | @@ -8209,7 +8209,7 @@ fn doTheTest() void { | ... | @@ -8209,7 +8209,7 @@ fn doTheTest() void { |
| 8209 | </p> | 8209 | </p> |
| 8210 | {#header_close#} | 8210 | {#header_close#} |
| 8211 | {#header_open|@trunc#} | 8211 | {#header_open|@trunc#} |
| 8212 | <pre>{#syntax#}@trunc(value: var) @TypeOf(value){#endsyntax#}</pre> | 8212 | <pre>{#syntax#}@trunc(value: anytype) @TypeOf(value){#endsyntax#}</pre> |
| 8213 | <p> | 8213 | <p> |
| 8214 | Rounds the given floating point number to an integer, towards zero. | 8214 | Rounds the given floating point number to an integer, towards zero. |
| 8215 | Uses a dedicated hardware instruction when available. | 8215 | Uses a dedicated hardware instruction when available. |
| ... | @@ -8220,7 +8220,7 @@ fn doTheTest() void { | ... | @@ -8220,7 +8220,7 @@ fn doTheTest() void { |
| 8220 | </p> | 8220 | </p> |
| 8221 | {#header_close#} | 8221 | {#header_close#} |
| 8222 | {#header_open|@round#} | 8222 | {#header_open|@round#} |
| 8223 | <pre>{#syntax#}@round(value: var) @TypeOf(value){#endsyntax#}</pre> | 8223 | <pre>{#syntax#}@round(value: anytype) @TypeOf(value){#endsyntax#}</pre> |
| 8224 | <p> | 8224 | <p> |
| 8225 | Rounds the given floating point number to an integer, away from zero. Uses a dedicated hardware instruction | 8225 | Rounds the given floating point number to an integer, away from zero. Uses a dedicated hardware instruction |
| 8226 | when available. | 8226 | when available. |
| ... | @@ -8241,7 +8241,7 @@ fn doTheTest() void { | ... | @@ -8241,7 +8241,7 @@ fn doTheTest() void { |
| 8241 | {#header_close#} | 8241 | {#header_close#} |
| 8242 | 8242 | ||
| 8243 | {#header_open|@tagName#} | 8243 | {#header_open|@tagName#} |
| 8244 | <pre>{#syntax#}@tagName(value: var) []const u8{#endsyntax#}</pre> | 8244 | <pre>{#syntax#}@tagName(value: anytype) []const u8{#endsyntax#}</pre> |
| 8245 | <p> | 8245 | <p> |
| 8246 | 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#}. | 8246 | 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#}. |
| 8247 | </p> | 8247 | </p> |
| ... | @@ -8292,7 +8292,7 @@ fn List(comptime T: type) type { | ... | @@ -8292,7 +8292,7 @@ fn List(comptime T: type) type { |
| 8292 | {#header_close#} | 8292 | {#header_close#} |
| 8293 | 8293 | ||
| 8294 | {#header_open|@truncate#} | 8294 | {#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> |
| 8296 | <p> | 8296 | <p> |
| 8297 | This function truncates bits from an integer type, resulting in a smaller | 8297 | This function truncates bits from an integer type, resulting in a smaller |
| 8298 | or same-sized integer type. | 8298 | or same-sized integer type. |
| ... | @@ -10214,7 +10214,7 @@ TopLevelDecl | ... | @@ -10214,7 +10214,7 @@ TopLevelDecl |
| 10214 | / (KEYWORD_export / KEYWORD_extern STRINGLITERALSINGLE?)? KEYWORD_threadlocal? VarDecl | 10214 | / (KEYWORD_export / KEYWORD_extern STRINGLITERALSINGLE?)? KEYWORD_threadlocal? VarDecl |
| 10215 | / KEYWORD_usingnamespace Expr SEMICOLON | 10215 | / KEYWORD_usingnamespace Expr SEMICOLON |
| 10216 | 10216 | ||
| 10217 | FnProto &lt;- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_var / TypeExpr) | 10217 | FnProto &lt;- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_anytype / TypeExpr) |
| 10218 | 10218 | ||
| 10219 | VarDecl &lt;- (KEYWORD_const / KEYWORD_var) IDENTIFIER (COLON TypeExpr)? ByteAlign? LinkSection? (EQUAL Expr)? SEMICOLON | 10219 | VarDecl &lt;- (KEYWORD_const / KEYWORD_var) IDENTIFIER (COLON TypeExpr)? ByteAlign? LinkSection? (EQUAL Expr)? SEMICOLON |
| 10220 | 10220 | ||
| ... | @@ -10386,7 +10386,7 @@ LinkSection &lt;- KEYWORD_linksection LPAREN Expr RPAREN | ... | @@ -10386,7 +10386,7 @@ LinkSection &lt;- KEYWORD_linksection LPAREN Expr RPAREN |
| 10386 | ParamDecl &lt;- (KEYWORD_noalias / KEYWORD_comptime)? (IDENTIFIER COLON)? ParamType | 10386 | ParamDecl &lt;- (KEYWORD_noalias / KEYWORD_comptime)? (IDENTIFIER COLON)? ParamType |
| 10387 | 10387 | ||
| 10388 | ParamType | 10388 | ParamType |
| 10389 | &lt;- KEYWORD_var | 10389 | &lt;- KEYWORD_anytype |
| 10390 | / DOT3 | 10390 | / DOT3 |
| 10391 | / TypeExpr | 10391 | / TypeExpr |
| 10392 | 10392 | ||
| ... | @@ -10624,6 +10624,7 @@ KEYWORD_align &lt;- 'align' end_of_word | ... | @@ -10624,6 +10624,7 @@ KEYWORD_align &lt;- 'align' end_of_word |
| 10624 | KEYWORD_allowzero &lt;- 'allowzero' end_of_word | 10624 | KEYWORD_allowzero &lt;- 'allowzero' end_of_word |
| 10625 | KEYWORD_and &lt;- 'and' end_of_word | 10625 | KEYWORD_and &lt;- 'and' end_of_word |
| 10626 | KEYWORD_anyframe &lt;- 'anyframe' end_of_word | 10626 | KEYWORD_anyframe &lt;- 'anyframe' end_of_word |
| 10627 | KEYWORD_anytype &lt;- 'anytype' end_of_word | ||
| 10627 | KEYWORD_asm &lt;- 'asm' end_of_word | 10628 | KEYWORD_asm &lt;- 'asm' end_of_word |
| 10628 | KEYWORD_async &lt;- 'async' end_of_word | 10629 | KEYWORD_async &lt;- 'async' end_of_word |
| 10629 | KEYWORD_await &lt;- 'await' end_of_word | 10630 | KEYWORD_await &lt;- 'await' end_of_word |
| ... | @@ -10669,14 +10670,14 @@ KEYWORD_var &lt;- 'var' end_of_word | ... | @@ -10669,14 +10670,14 @@ KEYWORD_var &lt;- 'var' end_of_word |
| 10669 | KEYWORD_volatile &lt;- 'volatile' end_of_word | 10670 | KEYWORD_volatile &lt;- 'volatile' end_of_word |
| 10670 | KEYWORD_while &lt;- 'while' end_of_word | 10671 | KEYWORD_while &lt;- 'while' end_of_word |
| 10671 | 10672 | ||
| 10672 | keyword &lt;- KEYWORD_align / KEYWORD_and / KEYWORD_allowzero / KEYWORD_asm | 10673 | keyword &lt;- KEYWORD_align / KEYWORD_and / KEYWORD_anyframe / KEYWORD_anytype |
| 10673 | / KEYWORD_async / KEYWORD_await / KEYWORD_break | 10674 | / KEYWORD_allowzero / KEYWORD_asm / KEYWORD_async / KEYWORD_await / KEYWORD_break |
| 10674 | / KEYWORD_catch / KEYWORD_comptime / KEYWORD_const / KEYWORD_continue | 10675 | / KEYWORD_catch / KEYWORD_comptime / KEYWORD_const / KEYWORD_continue |
| 10675 | / KEYWORD_defer / KEYWORD_else / KEYWORD_enum / KEYWORD_errdefer | 10676 | / KEYWORD_defer / KEYWORD_else / KEYWORD_enum / KEYWORD_errdefer |
| 10676 | / KEYWORD_error / KEYWORD_export / KEYWORD_extern / KEYWORD_false | 10677 | / KEYWORD_error / KEYWORD_export / KEYWORD_extern / KEYWORD_false |
| 10677 | / KEYWORD_fn / KEYWORD_for / KEYWORD_if / KEYWORD_inline | 10678 | / KEYWORD_fn / KEYWORD_for / KEYWORD_if / KEYWORD_inline |
| 10678 | / KEYWORD_noalias / KEYWORD_null / KEYWORD_or | 10679 | / KEYWORD_noalias / KEYWORD_null / KEYWORD_or |
| 10679 | / KEYWORD_orelse / KEYWORD_packed / KEYWORD_anyframe / KEYWORD_pub | 10680 | / KEYWORD_orelse / KEYWORD_packed / KEYWORD_pub |
| 10680 | / KEYWORD_resume / KEYWORD_return / KEYWORD_linksection | 10681 | / KEYWORD_resume / KEYWORD_return / KEYWORD_linksection |
| 10681 | / KEYWORD_struct / KEYWORD_suspend | 10682 | / KEYWORD_struct / KEYWORD_suspend |
| 10682 | / KEYWORD_switch / KEYWORD_test / KEYWORD_threadlocal / KEYWORD_true / KEYWORD_try | 10683 | / KEYWORD_switch / KEYWORD_test / KEYWORD_threadlocal / KEYWORD_true / KEYWORD_try |
src/all_types.hpp+4-4| ... | @@ -692,7 +692,7 @@ enum NodeType { | ... | @@ -692,7 +692,7 @@ enum NodeType { |
| 692 | NodeTypeSuspend, | 692 | NodeTypeSuspend, |
| 693 | NodeTypeAnyFrameType, | 693 | NodeTypeAnyFrameType, |
| 694 | NodeTypeEnumLiteral, | 694 | NodeTypeEnumLiteral, |
| 695 | NodeTypeVarFieldType, | 695 | NodeTypeAnyTypeField, |
| 696 | }; | 696 | }; |
| 697 | 697 | ||
| 698 | enum FnInline { | 698 | enum FnInline { |
| ... | @@ -705,7 +705,7 @@ struct AstNodeFnProto { | ... | @@ -705,7 +705,7 @@ struct AstNodeFnProto { |
| 705 | Buf *name; | 705 | Buf *name; |
| 706 | ZigList<AstNode *> params; | 706 | ZigList<AstNode *> params; |
| 707 | AstNode *return_type; | 707 | AstNode *return_type; |
| 708 | Token *return_var_token; | 708 | Token *return_anytype_token; |
| 709 | AstNode *fn_def_node; | 709 | AstNode *fn_def_node; |
| 710 | // populated if this is an extern declaration | 710 | // populated if this is an extern declaration |
| 711 | Buf *lib_name; | 711 | Buf *lib_name; |
| ... | @@ -734,7 +734,7 @@ struct AstNodeFnDef { | ... | @@ -734,7 +734,7 @@ struct AstNodeFnDef { |
| 734 | struct AstNodeParamDecl { | 734 | struct AstNodeParamDecl { |
| 735 | Buf *name; | 735 | Buf *name; |
| 736 | AstNode *type; | 736 | AstNode *type; |
| 737 | Token *var_token; | 737 | Token *anytype_token; |
| 738 | Buf doc_comments; | 738 | Buf doc_comments; |
| 739 | bool is_noalias; | 739 | bool is_noalias; |
| 740 | bool is_comptime; | 740 | bool is_comptime; |
| ... | @@ -2145,7 +2145,7 @@ struct CodeGen { | ... | @@ -2145,7 +2145,7 @@ struct CodeGen { |
| 2145 | ZigType *entry_num_lit_float; | 2145 | ZigType *entry_num_lit_float; |
| 2146 | ZigType *entry_undef; | 2146 | ZigType *entry_undef; |
| 2147 | ZigType *entry_null; | 2147 | ZigType *entry_null; |
| 2148 | ZigType *entry_var; | 2148 | ZigType *entry_anytype; |
| 2149 | ZigType *entry_global_error_set; | 2149 | ZigType *entry_global_error_set; |
| 2150 | ZigType *entry_enum_literal; | 2150 | ZigType *entry_enum_literal; |
| 2151 | ZigType *entry_any_frame; | 2151 | ZigType *entry_any_frame; |
src/analyze.cpp+8-8| ... | @@ -1129,7 +1129,7 @@ ZigValue *analyze_const_value(CodeGen *g, Scope *scope, AstNode *node, ZigType * | ... | @@ -1129,7 +1129,7 @@ ZigValue *analyze_const_value(CodeGen *g, Scope *scope, AstNode *node, ZigType * |
| 1129 | ZigValue *result = g->pass1_arena->create<ZigValue>(); | 1129 | ZigValue *result = g->pass1_arena->create<ZigValue>(); |
| 1130 | ZigValue *result_ptr = g->pass1_arena->create<ZigValue>(); | 1130 | ZigValue *result_ptr = g->pass1_arena->create<ZigValue>(); |
| 1131 | result->special = ConstValSpecialUndef; | 1131 | 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; |
| 1133 | result_ptr->special = ConstValSpecialStatic; | 1133 | result_ptr->special = ConstValSpecialStatic; |
| 1134 | result_ptr->type = get_pointer_to_type(g, result->type, false); | 1134 | result_ptr->type = get_pointer_to_type(g, result->type, false); |
| 1135 | result_ptr->data.x_ptr.mut = ConstPtrMutComptimeVar; | 1135 | result_ptr->data.x_ptr.mut = ConstPtrMutComptimeVar; |
| ... | @@ -1230,7 +1230,7 @@ Error type_val_resolve_zero_bits(CodeGen *g, ZigValue *type_val, ZigType *parent | ... | @@ -1230,7 +1230,7 @@ Error type_val_resolve_zero_bits(CodeGen *g, ZigValue *type_val, ZigType *parent |
| 1230 | Error type_val_resolve_is_opaque_type(CodeGen *g, ZigValue *type_val, bool *is_opaque_type) { | 1230 | Error type_val_resolve_is_opaque_type(CodeGen *g, ZigValue *type_val, bool *is_opaque_type) { |
| 1231 | if (type_val->special != ConstValSpecialLazy) { | 1231 | if (type_val->special != ConstValSpecialLazy) { |
| 1232 | assert(type_val->special == ConstValSpecialStatic); | 1232 | 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) { |
| 1234 | *is_opaque_type = false; | 1234 | *is_opaque_type = false; |
| 1235 | return ErrorNone; | 1235 | return ErrorNone; |
| 1236 | } | 1236 | } |
| ... | @@ -1853,10 +1853,10 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc | ... | @@ -1853,10 +1853,10 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc |
| 1853 | buf_sprintf("var args only allowed in functions with C calling convention")); | 1853 | buf_sprintf("var args only allowed in functions with C calling convention")); |
| 1854 | return g->builtin_types.entry_invalid; | 1854 | return g->builtin_types.entry_invalid; |
| 1855 | } | 1855 | } |
| 1856 | } else if (param_node->data.param_decl.var_token != nullptr) { | 1856 | } else if (param_node->data.param_decl.anytype_token != nullptr) { |
| 1857 | if (!calling_convention_allows_zig_types(fn_type_id.cc)) { | 1857 | if (!calling_convention_allows_zig_types(fn_type_id.cc)) { |
| 1858 | add_node_error(g, param_node, | 1858 | 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'", |
| 1860 | calling_convention_name(fn_type_id.cc))); | 1860 | calling_convention_name(fn_type_id.cc))); |
| 1861 | return g->builtin_types.entry_invalid; | 1861 | return g->builtin_types.entry_invalid; |
| 1862 | } | 1862 | } |
| ... | @@ -1942,10 +1942,10 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc | ... | @@ -1942,10 +1942,10 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc |
| 1942 | fn_entry->align_bytes = fn_type_id.alignment; | 1942 | fn_entry->align_bytes = fn_type_id.alignment; |
| 1943 | } | 1943 | } |
| 1944 | 1944 | ||
| 1945 | if (fn_proto->return_var_token != nullptr) { | 1945 | if (fn_proto->return_anytype_token != nullptr) { |
| 1946 | if (!calling_convention_allows_zig_types(fn_type_id.cc)) { | 1946 | if (!calling_convention_allows_zig_types(fn_type_id.cc)) { |
| 1947 | add_node_error(g, fn_proto->return_type, | 1947 | 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'", |
| 1949 | calling_convention_name(fn_type_id.cc))); | 1949 | calling_convention_name(fn_type_id.cc))); |
| 1950 | return g->builtin_types.entry_invalid; | 1950 | return g->builtin_types.entry_invalid; |
| 1951 | } | 1951 | } |
| ... | @@ -3802,7 +3802,7 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) { | ... | @@ -3802,7 +3802,7 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) { |
| 3802 | case NodeTypeEnumLiteral: | 3802 | case NodeTypeEnumLiteral: |
| 3803 | case NodeTypeAnyFrameType: | 3803 | case NodeTypeAnyFrameType: |
| 3804 | case NodeTypeErrorSetField: | 3804 | case NodeTypeErrorSetField: |
| 3805 | case NodeTypeVarFieldType: | 3805 | case NodeTypeAnyTypeField: |
| 3806 | zig_unreachable(); | 3806 | zig_unreachable(); |
| 3807 | } | 3807 | } |
| 3808 | } | 3808 | } |
| ... | @@ -5868,7 +5868,7 @@ ZigValue *get_the_one_possible_value(CodeGen *g, ZigType *type_entry) { | ... | @@ -5868,7 +5868,7 @@ ZigValue *get_the_one_possible_value(CodeGen *g, ZigType *type_entry) { |
| 5868 | 5868 | ||
| 5869 | ReqCompTime type_requires_comptime(CodeGen *g, ZigType *ty) { | 5869 | ReqCompTime type_requires_comptime(CodeGen *g, ZigType *ty) { |
| 5870 | Error err; | 5870 | Error err; |
| 5871 | if (ty == g->builtin_types.entry_var) { | 5871 | if (ty == g->builtin_types.entry_anytype) { |
| 5872 | return ReqCompTimeYes; | 5872 | return ReqCompTimeYes; |
| 5873 | } | 5873 | } |
| 5874 | switch (ty->id) { | 5874 | switch (ty->id) { |
src/ast_render.cpp+8-8| ... | @@ -270,8 +270,8 @@ static const char *node_type_str(NodeType node_type) { | ... | @@ -270,8 +270,8 @@ static const char *node_type_str(NodeType node_type) { |
| 270 | return "EnumLiteral"; | 270 | return "EnumLiteral"; |
| 271 | case NodeTypeErrorSetField: | 271 | case NodeTypeErrorSetField: |
| 272 | return "ErrorSetField"; | 272 | return "ErrorSetField"; |
| 273 | case NodeTypeVarFieldType: | 273 | case NodeTypeAnyTypeField: |
| 274 | return "VarFieldType"; | 274 | return "AnyTypeField"; |
| 275 | } | 275 | } |
| 276 | zig_unreachable(); | 276 | zig_unreachable(); |
| 277 | } | 277 | } |
| ... | @@ -466,8 +466,8 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) { | ... | @@ -466,8 +466,8 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) { |
| 466 | } | 466 | } |
| 467 | if (param_decl->data.param_decl.is_var_args) { | 467 | if (param_decl->data.param_decl.is_var_args) { |
| 468 | fprintf(ar->f, "..."); | 468 | fprintf(ar->f, "..."); |
| 469 | } else if (param_decl->data.param_decl.var_token != nullptr) { | 469 | } else if (param_decl->data.param_decl.anytype_token != nullptr) { |
| 470 | fprintf(ar->f, "var"); | 470 | fprintf(ar->f, "anytype"); |
| 471 | } else { | 471 | } else { |
| 472 | render_node_grouped(ar, param_decl->data.param_decl.type); | 472 | render_node_grouped(ar, param_decl->data.param_decl.type); |
| 473 | } | 473 | } |
| ... | @@ -496,8 +496,8 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) { | ... | @@ -496,8 +496,8 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) { |
| 496 | fprintf(ar->f, ")"); | 496 | fprintf(ar->f, ")"); |
| 497 | } | 497 | } |
| 498 | 498 | ||
| 499 | if (node->data.fn_proto.return_var_token != nullptr) { | 499 | if (node->data.fn_proto.return_anytype_token != nullptr) { |
| 500 | fprintf(ar->f, "var"); | 500 | fprintf(ar->f, "anytype"); |
| 501 | } else { | 501 | } else { |
| 502 | AstNode *return_type_node = node->data.fn_proto.return_type; | 502 | AstNode *return_type_node = node->data.fn_proto.return_type; |
| 503 | assert(return_type_node != nullptr); | 503 | assert(return_type_node != nullptr); |
| ... | @@ -1216,8 +1216,8 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) { | ... | @@ -1216,8 +1216,8 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) { |
| 1216 | fprintf(ar->f, ".%s", buf_ptr(&node->data.enum_literal.identifier->data.str_lit.str)); | 1216 | fprintf(ar->f, ".%s", buf_ptr(&node->data.enum_literal.identifier->data.str_lit.str)); |
| 1217 | break; | 1217 | break; |
| 1218 | } | 1218 | } |
| 1219 | case NodeTypeVarFieldType: { | 1219 | case NodeTypeAnyTypeField: { |
| 1220 | fprintf(ar->f, "var"); | 1220 | fprintf(ar->f, "anytype"); |
| 1221 | break; | 1221 | break; |
| 1222 | } | 1222 | } |
| 1223 | case NodeTypeParamDecl: | 1223 | case NodeTypeParamDecl: |
src/codegen.cpp+2-2| ... | @@ -8448,8 +8448,8 @@ static void define_builtin_types(CodeGen *g) { | ... | @@ -8448,8 +8448,8 @@ static void define_builtin_types(CodeGen *g) { |
| 8448 | } | 8448 | } |
| 8449 | { | 8449 | { |
| 8450 | ZigType *entry = new_type_table_entry(ZigTypeIdOpaque); | 8450 | ZigType *entry = new_type_table_entry(ZigTypeIdOpaque); |
| 8451 | buf_init_from_str(&entry->name, "(var)"); | 8451 | buf_init_from_str(&entry->name, "(anytype)"); |
| 8452 | g->builtin_types.entry_var = entry; | 8452 | g->builtin_types.entry_anytype = entry; |
| 8453 | } | 8453 | } |
| 8454 | 8454 | ||
| 8455 | for (size_t i = 0; i < array_length(c_int_type_infos); i += 1) { | 8455 | 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 | ... | @@ -9942,7 +9942,7 @@ static IrInstSrc *ir_gen_fn_proto(IrBuilderSrc *irb, Scope *parent_scope, AstNod |
| 9942 | is_var_args = true; | 9942 | is_var_args = true; |
| 9943 | break; | 9943 | break; |
| 9944 | } | 9944 | } |
| 9945 | if (param_node->data.param_decl.var_token == nullptr) { | 9945 | if (param_node->data.param_decl.anytype_token == nullptr) { |
| 9946 | AstNode *type_node = param_node->data.param_decl.type; | 9946 | AstNode *type_node = param_node->data.param_decl.type; |
| 9947 | IrInstSrc *type_value = ir_gen_node(irb, type_node, parent_scope); | 9947 | IrInstSrc *type_value = ir_gen_node(irb, type_node, parent_scope); |
| 9948 | if (type_value == irb->codegen->invalid_inst_src) | 9948 | if (type_value == irb->codegen->invalid_inst_src) |
| ... | @@ -9968,7 +9968,7 @@ static IrInstSrc *ir_gen_fn_proto(IrBuilderSrc *irb, Scope *parent_scope, AstNod | ... | @@ -9968,7 +9968,7 @@ static IrInstSrc *ir_gen_fn_proto(IrBuilderSrc *irb, Scope *parent_scope, AstNod |
| 9968 | } | 9968 | } |
| 9969 | 9969 | ||
| 9970 | IrInstSrc *return_type; | 9970 | IrInstSrc *return_type; |
| 9971 | if (node->data.fn_proto.return_var_token == nullptr) { | 9971 | if (node->data.fn_proto.return_anytype_token == nullptr) { |
| 9972 | if (node->data.fn_proto.return_type == nullptr) { | 9972 | if (node->data.fn_proto.return_type == nullptr) { |
| 9973 | return_type = ir_build_const_type(irb, parent_scope, node, irb->codegen->builtin_types.entry_void); | 9973 | return_type = ir_build_const_type(irb, parent_scope, node, irb->codegen->builtin_types.entry_void); |
| 9974 | } else { | 9974 | } else { |
| ... | @@ -10226,9 +10226,9 @@ static IrInstSrc *ir_gen_node_raw(IrBuilderSrc *irb, AstNode *node, Scope *scope | ... | @@ -10226,9 +10226,9 @@ static IrInstSrc *ir_gen_node_raw(IrBuilderSrc *irb, AstNode *node, Scope *scope |
| 10226 | add_node_error(irb->codegen, node, | 10226 | add_node_error(irb->codegen, node, |
| 10227 | buf_sprintf("inferred array size invalid here")); | 10227 | buf_sprintf("inferred array size invalid here")); |
| 10228 | return irb->codegen->invalid_inst_src; | 10228 | return irb->codegen->invalid_inst_src; |
| 10229 | case NodeTypeVarFieldType: | 10229 | case NodeTypeAnyTypeField: |
| 10230 | return ir_lval_wrap(irb, scope, | 10230 | 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); |
| 10232 | } | 10232 | } |
| 10233 | zig_unreachable(); | 10233 | zig_unreachable(); |
| 10234 | } | 10234 | } |
| ... | @@ -10296,7 +10296,7 @@ static IrInstSrc *ir_gen_node_extra(IrBuilderSrc *irb, AstNode *node, Scope *sco | ... | @@ -10296,7 +10296,7 @@ static IrInstSrc *ir_gen_node_extra(IrBuilderSrc *irb, AstNode *node, Scope *sco |
| 10296 | case NodeTypeSuspend: | 10296 | case NodeTypeSuspend: |
| 10297 | case NodeTypeEnumLiteral: | 10297 | case NodeTypeEnumLiteral: |
| 10298 | case NodeTypeInferredArrayType: | 10298 | case NodeTypeInferredArrayType: |
| 10299 | case NodeTypeVarFieldType: | 10299 | case NodeTypeAnyTypeField: |
| 10300 | case NodeTypePrefixOpExpr: | 10300 | case NodeTypePrefixOpExpr: |
| 10301 | add_node_error(irb->codegen, node, | 10301 | add_node_error(irb->codegen, node, |
| 10302 | buf_sprintf("invalid left-hand side to assignment")); | 10302 | buf_sprintf("invalid left-hand side to assignment")); |
| ... | @@ -10518,7 +10518,7 @@ ZigValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ZigValue *const_va | ... | @@ -10518,7 +10518,7 @@ ZigValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ZigValue *const_va |
| 10518 | if (val == nullptr) return nullptr; | 10518 | if (val == nullptr) return nullptr; |
| 10519 | assert(const_val->type->id == ZigTypeIdPointer); | 10519 | assert(const_val->type->id == ZigTypeIdPointer); |
| 10520 | ZigType *expected_type = const_val->type->data.pointer.child_type; | 10520 | 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) { |
| 10522 | return val; | 10522 | return val; |
| 10523 | } | 10523 | } |
| 10524 | switch (type_has_one_possible_value(codegen, expected_type)) { | 10524 | switch (type_has_one_possible_value(codegen, expected_type)) { |
| ... | @@ -15040,7 +15040,7 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, IrInst *source_instr, | ... | @@ -15040,7 +15040,7 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, IrInst *source_instr, |
| 15040 | } | 15040 | } |
| 15041 | 15041 | ||
| 15042 | // This means the wanted type is anything. | 15042 | // 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) { |
| 15044 | return value; | 15044 | return value; |
| 15045 | } | 15045 | } |
| 15046 | 15046 | ||
| ... | @@ -15635,7 +15635,7 @@ static IrInstGen *ir_implicit_cast(IrAnalyze *ira, IrInstGen *value, ZigType *ex | ... | @@ -15635,7 +15635,7 @@ static IrInstGen *ir_implicit_cast(IrAnalyze *ira, IrInstGen *value, ZigType *ex |
| 15635 | static ZigType *get_ptr_elem_type(CodeGen *g, IrInstGen *ptr) { | 15635 | static ZigType *get_ptr_elem_type(CodeGen *g, IrInstGen *ptr) { |
| 15636 | ir_assert_gen(ptr->value->type->id == ZigTypeIdPointer, ptr); | 15636 | ir_assert_gen(ptr->value->type->id == ZigTypeIdPointer, ptr); |
| 15637 | ZigType *elem_type = ptr->value->type->data.pointer.child_type; | 15637 | 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) |
| 15639 | return elem_type; | 15639 | return elem_type; |
| 15640 | 15640 | ||
| 15641 | if (ir_resolve_lazy(g, ptr->base.source_node, ptr->value)) | 15641 | 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 | ... | @@ -15687,7 +15687,7 @@ static IrInstGen *ir_get_deref(IrAnalyze *ira, IrInst* source_instruction, IrIns |
| 15687 | } | 15687 | } |
| 15688 | if (ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { | 15688 | if (ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 15689 | ZigValue *pointee = const_ptr_pointee_unchecked(ira->codegen, ptr->value); | 15689 | 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) { |
| 15691 | child_type = pointee->type; | 15691 | child_type = pointee->type; |
| 15692 | } | 15692 | } |
| 15693 | if (pointee->special != ConstValSpecialRuntime) { | 15693 | if (pointee->special != ConstValSpecialRuntime) { |
| ... | @@ -19087,7 +19087,7 @@ static Error ir_result_has_type(IrAnalyze *ira, ResultLoc *result_loc, bool *out | ... | @@ -19087,7 +19087,7 @@ static Error ir_result_has_type(IrAnalyze *ira, ResultLoc *result_loc, bool *out |
| 19087 | ZigType *dest_type = ir_resolve_type(ira, result_cast->base.source_instruction->child); | 19087 | ZigType *dest_type = ir_resolve_type(ira, result_cast->base.source_instruction->child); |
| 19088 | if (type_is_invalid(dest_type)) | 19088 | if (type_is_invalid(dest_type)) |
| 19089 | return ErrorSemanticAnalyzeFail; | 19089 | return ErrorSemanticAnalyzeFail; |
| 19090 | *out = (dest_type != ira->codegen->builtin_types.entry_var); | 19090 | *out = (dest_type != ira->codegen->builtin_types.entry_anytype); |
| 19091 | return ErrorNone; | 19091 | return ErrorNone; |
| 19092 | } | 19092 | } |
| 19093 | case ResultLocIdVar: | 19093 | case ResultLocIdVar: |
| ... | @@ -19293,7 +19293,7 @@ static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInst *suspend_source_i | ... | @@ -19293,7 +19293,7 @@ static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInst *suspend_source_i |
| 19293 | if (type_is_invalid(dest_type)) | 19293 | if (type_is_invalid(dest_type)) |
| 19294 | return ira->codegen->invalid_inst_gen; | 19294 | return ira->codegen->invalid_inst_gen; |
| 19295 | 19295 | ||
| 19296 | if (dest_type == ira->codegen->builtin_types.entry_var) { | 19296 | if (dest_type == ira->codegen->builtin_types.entry_anytype) { |
| 19297 | return ir_resolve_no_result_loc(ira, suspend_source_instr, result_loc, value_type); | 19297 | return ir_resolve_no_result_loc(ira, suspend_source_instr, result_loc, value_type); |
| 19298 | } | 19298 | } |
| 19299 | 19299 | ||
| ... | @@ -19439,7 +19439,7 @@ static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInst *suspend_source_i | ... | @@ -19439,7 +19439,7 @@ static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInst *suspend_source_i |
| 19439 | return ira->codegen->invalid_inst_gen; | 19439 | return ira->codegen->invalid_inst_gen; |
| 19440 | } | 19440 | } |
| 19441 | 19441 | ||
| 19442 | if (child_type != ira->codegen->builtin_types.entry_var) { | 19442 | if (child_type != ira->codegen->builtin_types.entry_anytype) { |
| 19443 | if (type_size(ira->codegen, child_type) != type_size(ira->codegen, value_type)) { | 19443 | if (type_size(ira->codegen, child_type) != type_size(ira->codegen, value_type)) { |
| 19444 | // pointer cast won't work; we need a temporary location. | 19444 | // pointer cast won't work; we need a temporary location. |
| 19445 | result_bit_cast->parent->written = parent_was_written; | 19445 | result_bit_cast->parent->written = parent_was_written; |
| ... | @@ -19600,9 +19600,9 @@ static IrInstGen *ir_analyze_instruction_resolve_result(IrAnalyze *ira, IrInstSr | ... | @@ -19600,9 +19600,9 @@ static IrInstGen *ir_analyze_instruction_resolve_result(IrAnalyze *ira, IrInstSr |
| 19600 | if (type_is_invalid(implicit_elem_type)) | 19600 | if (type_is_invalid(implicit_elem_type)) |
| 19601 | return ira->codegen->invalid_inst_gen; | 19601 | return ira->codegen->invalid_inst_gen; |
| 19602 | } else { | 19602 | } else { |
| 19603 | implicit_elem_type = ira->codegen->builtin_types.entry_var; | 19603 | implicit_elem_type = ira->codegen->builtin_types.entry_anytype; |
| 19604 | } | 19604 | } |
| 19605 | if (implicit_elem_type == ira->codegen->builtin_types.entry_var) { | 19605 | if (implicit_elem_type == ira->codegen->builtin_types.entry_anytype) { |
| 19606 | Buf *bare_name = buf_alloc(); | 19606 | Buf *bare_name = buf_alloc(); |
| 19607 | Buf *name = get_anon_type_name(ira->codegen, nullptr, container_string(ContainerKindStruct), | 19607 | Buf *name = get_anon_type_name(ira->codegen, nullptr, container_string(ContainerKindStruct), |
| 19608 | instruction->base.base.scope, instruction->base.base.source_node, bare_name); | 19608 | 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 | ... | @@ -19759,7 +19759,7 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node |
| 19759 | assert(param_decl_node->type == NodeTypeParamDecl); | 19759 | assert(param_decl_node->type == NodeTypeParamDecl); |
| 19760 | 19760 | ||
| 19761 | IrInstGen *casted_arg; | 19761 | 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) { |
| 19763 | AstNode *param_type_node = param_decl_node->data.param_decl.type; | 19763 | AstNode *param_type_node = param_decl_node->data.param_decl.type; |
| 19764 | ZigType *param_type = ir_analyze_type_expr(ira, *exec_scope, param_type_node); | 19764 | ZigType *param_type = ir_analyze_type_expr(ira, *exec_scope, param_type_node); |
| 19765 | if (type_is_invalid(param_type)) | 19765 | if (type_is_invalid(param_type)) |
| ... | @@ -19799,7 +19799,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod | ... | @@ -19799,7 +19799,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 19799 | arg_part_of_generic_id = true; | 19799 | arg_part_of_generic_id = true; |
| 19800 | casted_arg = arg; | 19800 | casted_arg = arg; |
| 19801 | } else { | 19801 | } else { |
| 19802 | if (param_decl_node->data.param_decl.var_token == nullptr) { | 19802 | if (param_decl_node->data.param_decl.anytype_token == nullptr) { |
| 19803 | AstNode *param_type_node = param_decl_node->data.param_decl.type; | 19803 | AstNode *param_type_node = param_decl_node->data.param_decl.type; |
| 19804 | ZigType *param_type = ir_analyze_type_expr(ira, *child_scope, param_type_node); | 19804 | ZigType *param_type = ir_analyze_type_expr(ira, *child_scope, param_type_node); |
| 19805 | if (type_is_invalid(param_type)) | 19805 | if (type_is_invalid(param_type)) |
| ... | @@ -20011,7 +20011,7 @@ static IrInstGen *ir_analyze_store_ptr(IrAnalyze *ira, IrInst* source_instr, | ... | @@ -20011,7 +20011,7 @@ static IrInstGen *ir_analyze_store_ptr(IrAnalyze *ira, IrInst* source_instr, |
| 20011 | } | 20011 | } |
| 20012 | 20012 | ||
| 20013 | if (ptr->value->type->data.pointer.inferred_struct_field != nullptr && | 20013 | 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) |
| 20015 | { | 20015 | { |
| 20016 | child_type = ptr->value->type->data.pointer.inferred_struct_field->inferred_struct_type; | 20016 | child_type = ptr->value->type->data.pointer.inferred_struct_field->inferred_struct_type; |
| 20017 | } | 20017 | } |
| ... | @@ -20202,6 +20202,11 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, | ... | @@ -20202,6 +20202,11 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 20202 | } | 20202 | } |
| 20203 | 20203 | ||
| 20204 | AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type; | 20204 | 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 | } | ||
| 20205 | ZigType *specified_return_type = ir_analyze_type_expr(ira, exec_scope, return_type_node); | 20210 | ZigType *specified_return_type = ir_analyze_type_expr(ira, exec_scope, return_type_node); |
| 20206 | if (type_is_invalid(specified_return_type)) | 20211 | if (type_is_invalid(specified_return_type)) |
| 20207 | return ira->codegen->invalid_inst_gen; | 20212 | return ira->codegen->invalid_inst_gen; |
| ... | @@ -20364,7 +20369,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, | ... | @@ -20364,7 +20369,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 20364 | inst_fn_type_id.alignment = align_bytes; | 20369 | inst_fn_type_id.alignment = align_bytes; |
| 20365 | } | 20370 | } |
| 20366 | 20371 | ||
| 20367 | if (fn_proto_node->data.fn_proto.return_var_token == nullptr) { | 20372 | if (fn_proto_node->data.fn_proto.return_anytype_token == nullptr) { |
| 20368 | AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type; | 20373 | AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type; |
| 20369 | ZigType *specified_return_type = ir_analyze_type_expr(ira, impl_fn->child_scope, return_type_node); | 20374 | ZigType *specified_return_type = ir_analyze_type_expr(ira, impl_fn->child_scope, return_type_node); |
| 20370 | if (type_is_invalid(specified_return_type)) | 20375 | if (type_is_invalid(specified_return_type)) |
| ... | @@ -20463,7 +20468,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, | ... | @@ -20463,7 +20468,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 20463 | if (type_is_invalid(dummy_result->value->type)) | 20468 | if (type_is_invalid(dummy_result->value->type)) |
| 20464 | return ira->codegen->invalid_inst_gen; | 20469 | return ira->codegen->invalid_inst_gen; |
| 20465 | ZigType *res_child_type = result_loc->value->type->data.pointer.child_type; | 20470 | 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) { |
| 20467 | res_child_type = impl_fn_type_id->return_type; | 20472 | res_child_type = impl_fn_type_id->return_type; |
| 20468 | } | 20473 | } |
| 20469 | if (!handle_is_ptr(ira->codegen, res_child_type)) { | 20474 | if (!handle_is_ptr(ira->codegen, res_child_type)) { |
| ... | @@ -20606,7 +20611,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, | ... | @@ -20606,7 +20611,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 20606 | if (type_is_invalid(dummy_result->value->type)) | 20611 | if (type_is_invalid(dummy_result->value->type)) |
| 20607 | return ira->codegen->invalid_inst_gen; | 20612 | return ira->codegen->invalid_inst_gen; |
| 20608 | ZigType *res_child_type = result_loc->value->type->data.pointer.child_type; | 20613 | 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) { |
| 20610 | res_child_type = return_type; | 20615 | res_child_type = return_type; |
| 20611 | } | 20616 | } |
| 20612 | if (!handle_is_ptr(ira->codegen, res_child_type)) { | 20617 | 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, | ... | @@ -22337,7 +22342,7 @@ static IrInstGen *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_name, |
| 22337 | inferred_struct_field->inferred_struct_type = container_type; | 22342 | inferred_struct_field->inferred_struct_type = container_type; |
| 22338 | inferred_struct_field->field_name = field_name; | 22343 | inferred_struct_field->field_name = field_name; |
| 22339 | 22344 | ||
| 22340 | ZigType *elem_type = ira->codegen->builtin_types.entry_var; | 22345 | ZigType *elem_type = ira->codegen->builtin_types.entry_anytype; |
| 22341 | ZigType *field_ptr_type = get_pointer_to_type_extra2(ira->codegen, elem_type, | 22346 | ZigType *field_ptr_type = get_pointer_to_type_extra2(ira->codegen, elem_type, |
| 22342 | container_ptr_type->data.pointer.is_const, container_ptr_type->data.pointer.is_volatile, | 22347 | container_ptr_type->data.pointer.is_const, container_ptr_type->data.pointer.is_volatile, |
| 22343 | PtrLenSingle, 0, 0, 0, false, VECTOR_INDEX_NONE, inferred_struct_field, nullptr); | 22348 | 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 | ... | @@ -25115,7 +25120,7 @@ static ZigValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_type_ent |
| 25115 | fields[5]->special = ConstValSpecialStatic; | 25120 | fields[5]->special = ConstValSpecialStatic; |
| 25116 | fields[5]->type = ira->codegen->builtin_types.entry_bool; | 25121 | fields[5]->type = ira->codegen->builtin_types.entry_bool; |
| 25117 | fields[5]->data.x_bool = attrs_type->data.pointer.allow_zero; | 25122 | fields[5]->data.x_bool = attrs_type->data.pointer.allow_zero; |
| 25118 | // sentinel: var | 25123 | // sentinel: anytype |
| 25119 | ensure_field_index(result->type, "sentinel", 6); | 25124 | ensure_field_index(result->type, "sentinel", 6); |
| 25120 | fields[6]->special = ConstValSpecialStatic; | 25125 | fields[6]->special = ConstValSpecialStatic; |
| 25121 | if (attrs_type->data.pointer.child_type->id != ZigTypeIdOpaque) { | 25126 | 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 | ... | @@ -25243,7 +25248,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 25243 | fields[1]->special = ConstValSpecialStatic; | 25248 | fields[1]->special = ConstValSpecialStatic; |
| 25244 | fields[1]->type = ira->codegen->builtin_types.entry_type; | 25249 | fields[1]->type = ira->codegen->builtin_types.entry_type; |
| 25245 | fields[1]->data.x_type = type_entry->data.array.child_type; | 25250 | fields[1]->data.x_type = type_entry->data.array.child_type; |
| 25246 | // sentinel: var | 25251 | // sentinel: anytype |
| 25247 | fields[2]->special = ConstValSpecialStatic; | 25252 | fields[2]->special = ConstValSpecialStatic; |
| 25248 | fields[2]->type = get_optional_type(ira->codegen, type_entry->data.array.child_type); | 25253 | fields[2]->type = get_optional_type(ira->codegen, type_entry->data.array.child_type); |
| 25249 | fields[2]->data.x_optional = type_entry->data.array.sentinel; | 25254 | 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 | ... | @@ -25598,7 +25603,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 25598 | inner_fields[2]->type = ira->codegen->builtin_types.entry_type; | 25603 | inner_fields[2]->type = ira->codegen->builtin_types.entry_type; |
| 25599 | inner_fields[2]->data.x_type = struct_field->type_entry; | 25604 | inner_fields[2]->data.x_type = struct_field->type_entry; |
| 25600 | 25605 | ||
| 25601 | // default_value: var | 25606 | // default_value: anytype |
| 25602 | inner_fields[3]->special = ConstValSpecialStatic; | 25607 | inner_fields[3]->special = ConstValSpecialStatic; |
| 25603 | inner_fields[3]->type = get_optional_type2(ira->codegen, struct_field->type_entry); | 25608 | inner_fields[3]->type = get_optional_type2(ira->codegen, struct_field->type_entry); |
| 25604 | if (inner_fields[3]->type == nullptr) return ErrorSemanticAnalyzeFail; | 25609 | 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 | ... | @@ -25736,7 +25741,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 25736 | ZigValue **fields = alloc_const_vals_ptrs(ira->codegen, 1); | 25741 | ZigValue **fields = alloc_const_vals_ptrs(ira->codegen, 1); |
| 25737 | result->data.x_struct.fields = fields; | 25742 | result->data.x_struct.fields = fields; |
| 25738 | ZigFn *fn = type_entry->data.frame.fn; | 25743 | ZigFn *fn = type_entry->data.frame.fn; |
| 25739 | // function: var | 25744 | // function: anytype |
| 25740 | ensure_field_index(result->type, "function", 0); | 25745 | ensure_field_index(result->type, "function", 0); |
| 25741 | fields[0] = create_const_fn(ira->codegen, fn); | 25746 | fields[0] = create_const_fn(ira->codegen, fn); |
| 25742 | break; | 25747 | break; |
| ... | @@ -29996,7 +30001,7 @@ static IrInstGen *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstSrcArgTy | ... | @@ -29996,7 +30001,7 @@ static IrInstGen *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstSrcArgTy |
| 29996 | if (arg_index >= fn_type_id->param_count) { | 30001 | if (arg_index >= fn_type_id->param_count) { |
| 29997 | if (instruction->allow_var) { | 30002 | if (instruction->allow_var) { |
| 29998 | // TODO remove this with var args | 30003 | // 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); |
| 30000 | } | 30005 | } |
| 30001 | ir_add_error(ira, &arg_index_inst->base, | 30006 | ir_add_error(ira, &arg_index_inst->base, |
| 30002 | buf_sprintf("arg index %" ZIG_PRI_u64 " out of bounds; '%s' has %" ZIG_PRI_usize " arguments", | 30007 | 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 | ... | @@ -30010,7 +30015,7 @@ static IrInstGen *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstSrcArgTy |
| 30010 | ir_assert(fn_type->data.fn.is_generic, &instruction->base.base); | 30015 | ir_assert(fn_type->data.fn.is_generic, &instruction->base.base); |
| 30011 | 30016 | ||
| 30012 | if (instruction->allow_var) { | 30017 | 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); |
| 30014 | } else { | 30019 | } else { |
| 30015 | ir_add_error(ira, &arg_index_inst->base, | 30020 | ir_add_error(ira, &arg_index_inst->base, |
| 30016 | buf_sprintf("@ArgType could not resolve the type of arg %" ZIG_PRI_u64 " because '%s' is generic", | 30021 | 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 | ... | @@ -786,7 +786,7 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B |
| 786 | return nullptr; | 786 | return nullptr; |
| 787 | } | 787 | } |
| 788 | 788 | ||
| 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) |
| 790 | static AstNode *ast_parse_fn_proto(ParseContext *pc) { | 790 | static AstNode *ast_parse_fn_proto(ParseContext *pc) { |
| 791 | Token *first = eat_token_if(pc, TokenIdKeywordFn); | 791 | Token *first = eat_token_if(pc, TokenIdKeywordFn); |
| 792 | if (first == nullptr) { | 792 | if (first == nullptr) { |
| ... | @@ -801,10 +801,10 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) { | ... | @@ -801,10 +801,10 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) { |
| 801 | AstNode *align_expr = ast_parse_byte_align(pc); | 801 | AstNode *align_expr = ast_parse_byte_align(pc); |
| 802 | AstNode *section_expr = ast_parse_link_section(pc); | 802 | AstNode *section_expr = ast_parse_link_section(pc); |
| 803 | AstNode *callconv_expr = ast_parse_callconv(pc); | 803 | AstNode *callconv_expr = ast_parse_callconv(pc); |
| 804 | Token *var = eat_token_if(pc, TokenIdKeywordVar); | 804 | Token *anytype = eat_token_if(pc, TokenIdKeywordAnyType); |
| 805 | Token *exmark = nullptr; | 805 | Token *exmark = nullptr; |
| 806 | AstNode *return_type = nullptr; | 806 | AstNode *return_type = nullptr; |
| 807 | if (var == nullptr) { | 807 | if (anytype == nullptr) { |
| 808 | exmark = eat_token_if(pc, TokenIdBang); | 808 | exmark = eat_token_if(pc, TokenIdBang); |
| 809 | return_type = ast_expect(pc, ast_parse_type_expr); | 809 | return_type = ast_expect(pc, ast_parse_type_expr); |
| 810 | } | 810 | } |
| ... | @@ -816,7 +816,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) { | ... | @@ -816,7 +816,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) { |
| 816 | res->data.fn_proto.align_expr = align_expr; | 816 | res->data.fn_proto.align_expr = align_expr; |
| 817 | res->data.fn_proto.section_expr = section_expr; | 817 | res->data.fn_proto.section_expr = section_expr; |
| 818 | res->data.fn_proto.callconv_expr = callconv_expr; | 818 | 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; |
| 820 | res->data.fn_proto.auto_err_set = exmark != nullptr; | 820 | res->data.fn_proto.auto_err_set = exmark != nullptr; |
| 821 | res->data.fn_proto.return_type = return_type; | 821 | res->data.fn_proto.return_type = return_type; |
| 822 | 822 | ||
| ... | @@ -870,9 +870,9 @@ static AstNode *ast_parse_container_field(ParseContext *pc) { | ... | @@ -870,9 +870,9 @@ static AstNode *ast_parse_container_field(ParseContext *pc) { |
| 870 | 870 | ||
| 871 | AstNode *type_expr = nullptr; | 871 | AstNode *type_expr = nullptr; |
| 872 | if (eat_token_if(pc, TokenIdColon) != nullptr) { | 872 | if (eat_token_if(pc, TokenIdColon) != nullptr) { |
| 873 | Token *var_tok = eat_token_if(pc, TokenIdKeywordVar); | 873 | Token *anytype_tok = eat_token_if(pc, TokenIdKeywordAnyType); |
| 874 | if (var_tok != nullptr) { | 874 | if (anytype_tok != nullptr) { |
| 875 | type_expr = ast_create_node(pc, NodeTypeVarFieldType, var_tok); | 875 | type_expr = ast_create_node(pc, NodeTypeAnyTypeField, anytype_tok); |
| 876 | } else { | 876 | } else { |
| 877 | type_expr = ast_expect(pc, ast_parse_type_expr); | 877 | type_expr = ast_expect(pc, ast_parse_type_expr); |
| 878 | } | 878 | } |
| ... | @@ -2191,14 +2191,14 @@ static AstNode *ast_parse_param_decl(ParseContext *pc) { | ... | @@ -2191,14 +2191,14 @@ static AstNode *ast_parse_param_decl(ParseContext *pc) { |
| 2191 | } | 2191 | } |
| 2192 | 2192 | ||
| 2193 | // ParamType | 2193 | // ParamType |
| 2194 | // <- KEYWORD_var | 2194 | // <- KEYWORD_anytype |
| 2195 | // / DOT3 | 2195 | // / DOT3 |
| 2196 | // / TypeExpr | 2196 | // / TypeExpr |
| 2197 | static AstNode *ast_parse_param_type(ParseContext *pc) { | 2197 | static AstNode *ast_parse_param_type(ParseContext *pc) { |
| 2198 | Token *var_token = eat_token_if(pc, TokenIdKeywordVar); | 2198 | Token *anytype_token = eat_token_if(pc, TokenIdKeywordAnyType); |
| 2199 | if (var_token != nullptr) { | 2199 | if (anytype_token != nullptr) { |
| 2200 | AstNode *res = ast_create_node(pc, NodeTypeParamDecl, var_token); | 2200 | AstNode *res = ast_create_node(pc, NodeTypeParamDecl, anytype_token); |
| 2201 | res->data.param_decl.var_token = var_token; | 2201 | res->data.param_decl.anytype_token = anytype_token; |
| 2202 | return res; | 2202 | return res; |
| 2203 | } | 2203 | } |
| 2204 | 2204 | ||
| ... | @@ -3207,7 +3207,7 @@ void ast_visit_node_children(AstNode *node, void (*visit)(AstNode **, void *cont | ... | @@ -3207,7 +3207,7 @@ void ast_visit_node_children(AstNode *node, void (*visit)(AstNode **, void *cont |
| 3207 | visit_field(&node->data.suspend.block, visit, context); | 3207 | visit_field(&node->data.suspend.block, visit, context); |
| 3208 | break; | 3208 | break; |
| 3209 | case NodeTypeEnumLiteral: | 3209 | case NodeTypeEnumLiteral: |
| 3210 | case NodeTypeVarFieldType: | 3210 | case NodeTypeAnyTypeField: |
| 3211 | break; | 3211 | break; |
| 3212 | } | 3212 | } |
| 3213 | } | 3213 | } |
src/tokenizer.cpp+2| ... | @@ -106,6 +106,7 @@ static const struct ZigKeyword zig_keywords[] = { | ... | @@ -106,6 +106,7 @@ static const struct ZigKeyword zig_keywords[] = { |
| 106 | {"allowzero", TokenIdKeywordAllowZero}, | 106 | {"allowzero", TokenIdKeywordAllowZero}, |
| 107 | {"and", TokenIdKeywordAnd}, | 107 | {"and", TokenIdKeywordAnd}, |
| 108 | {"anyframe", TokenIdKeywordAnyFrame}, | 108 | {"anyframe", TokenIdKeywordAnyFrame}, |
| 109 | {"anytype", TokenIdKeywordAnyType}, | ||
| 109 | {"asm", TokenIdKeywordAsm}, | 110 | {"asm", TokenIdKeywordAsm}, |
| 110 | {"async", TokenIdKeywordAsync}, | 111 | {"async", TokenIdKeywordAsync}, |
| 111 | {"await", TokenIdKeywordAwait}, | 112 | {"await", TokenIdKeywordAwait}, |
| ... | @@ -1569,6 +1570,7 @@ const char * token_name(TokenId id) { | ... | @@ -1569,6 +1570,7 @@ const char * token_name(TokenId id) { |
| 1569 | case TokenIdKeywordAlign: return "align"; | 1570 | case TokenIdKeywordAlign: return "align"; |
| 1570 | case TokenIdKeywordAnd: return "and"; | 1571 | case TokenIdKeywordAnd: return "and"; |
| 1571 | case TokenIdKeywordAnyFrame: return "anyframe"; | 1572 | case TokenIdKeywordAnyFrame: return "anyframe"; |
| 1573 | case TokenIdKeywordAnyType: return "anytype"; | ||
| 1572 | case TokenIdKeywordAsm: return "asm"; | 1574 | case TokenIdKeywordAsm: return "asm"; |
| 1573 | case TokenIdKeywordBreak: return "break"; | 1575 | case TokenIdKeywordBreak: return "break"; |
| 1574 | case TokenIdKeywordCatch: return "catch"; | 1576 | case TokenIdKeywordCatch: return "catch"; |
src/tokenizer.hpp+1| ... | @@ -54,6 +54,7 @@ enum TokenId { | ... | @@ -54,6 +54,7 @@ enum TokenId { |
| 54 | TokenIdKeywordAllowZero, | 54 | TokenIdKeywordAllowZero, |
| 55 | TokenIdKeywordAnd, | 55 | TokenIdKeywordAnd, |
| 56 | TokenIdKeywordAnyFrame, | 56 | TokenIdKeywordAnyFrame, |
| 57 | TokenIdKeywordAnyType, | ||
| 57 | TokenIdKeywordAsm, | 58 | TokenIdKeywordAsm, |
| 58 | TokenIdKeywordAsync, | 59 | TokenIdKeywordAsync, |
| 59 | TokenIdKeywordAwait, | 60 | TokenIdKeywordAwait, |