authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-07-12 07:35:01+00:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-07-12 07:35:01+00:00
logfe08a4d0654b4d73b78f65cf1a31a037002e2243
treeb762e87c5191c1d3c1231c5baf3eee73351e3452
parent2dcb70a6befc2cc0a8f46a7e64cde534d37f6f3e
parentbe1507a7afe4c8869abdbab67a32ede6afe3d938
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #5846 from Vexu/anytype

Rename 'var' type to 'anytype'

166 files changed, 792 insertions(+), 746 deletions(-)

build.zig+4-4
......@@ -153,7 +153,7 @@ pub fn build(b: *Builder) !void {
153153 test_step.dependOn(docs_step);
154154}
155155
156fn dependOnLib(b: *Builder, lib_exe_obj: var, dep: LibraryDep) void {
156fn dependOnLib(b: *Builder, lib_exe_obj: anytype, dep: LibraryDep) void {
157157 for (dep.libdirs.items) |lib_dir| {
158158 lib_exe_obj.addLibPath(lib_dir);
159159 }
......@@ -193,7 +193,7 @@ fn fileExists(filename: []const u8) !bool {
193193 return true;
194194}
195195
196fn addCppLib(b: *Builder, lib_exe_obj: var, cmake_binary_dir: []const u8, lib_name: []const u8) void {
196fn addCppLib(b: *Builder, lib_exe_obj: anytype, cmake_binary_dir: []const u8, lib_name: []const u8) void {
197197 lib_exe_obj.addObjectFile(fs.path.join(b.allocator, &[_][]const u8{
198198 cmake_binary_dir,
199199 "zig_cpp",
......@@ -275,7 +275,7 @@ fn findLLVM(b: *Builder, llvm_config_exe: []const u8) !LibraryDep {
275275 return result;
276276}
277277
278fn configureStage2(b: *Builder, exe: var, ctx: Context) !void {
278fn configureStage2(b: *Builder, exe: anytype, ctx: Context) !void {
279279 exe.addIncludeDir("src");
280280 exe.addIncludeDir(ctx.cmake_binary_dir);
281281 addCppLib(b, exe, ctx.cmake_binary_dir, "zig_cpp");
......@@ -340,7 +340,7 @@ fn configureStage2(b: *Builder, exe: var, ctx: Context) !void {
340340fn addCxxKnownPath(
341341 b: *Builder,
342342 ctx: Context,
343 exe: var,
343 exe: anytype,
344344 objname: []const u8,
345345 errtxt: ?[]const u8,
346346) !void {
doc/docgen.zig+6-5
......@@ -212,7 +212,7 @@ const Tokenizer = struct {
212212 }
213213};
214214
215fn parseError(tokenizer: *Tokenizer, token: Token, comptime fmt: []const u8, args: var) anyerror {
215fn parseError(tokenizer: *Tokenizer, token: Token, comptime fmt: []const u8, args: anytype) anyerror {
216216 const loc = tokenizer.getTokenLocation(token);
217217 const args_prefix = .{ tokenizer.source_file_name, loc.line + 1, loc.column + 1 };
218218 warn("{}:{}:{}: error: " ++ fmt ++ "\n", args_prefix ++ args);
......@@ -634,7 +634,7 @@ fn escapeHtml(allocator: *mem.Allocator, input: []const u8) ![]u8 {
634634 return buf.toOwnedSlice();
635635}
636636
637fn writeEscaped(out: var, input: []const u8) !void {
637fn writeEscaped(out: anytype, input: []const u8) !void {
638638 for (input) |c| {
639639 try switch (c) {
640640 '&' => out.writeAll("&amp;"),
......@@ -765,7 +765,7 @@ fn isType(name: []const u8) bool {
765765 return false;
766766}
767767
768fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Token, raw_src: []const u8) !void {
768fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: anytype, source_token: Token, raw_src: []const u8) !void {
769769 const src = mem.trim(u8, raw_src, " \n");
770770 try out.writeAll("<code class=\"zig\">");
771771 var tokenizer = std.zig.Tokenizer.init(src);
......@@ -825,6 +825,7 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
825825 .Keyword_volatile,
826826 .Keyword_allowzero,
827827 .Keyword_while,
828 .Keyword_anytype,
828829 => {
829830 try out.writeAll("<span class=\"tok-kw\">");
830831 try writeEscaped(out, src[token.loc.start..token.loc.end]);
......@@ -977,12 +978,12 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
977978 try out.writeAll("</code>");
978979}
979980
980fn tokenizeAndPrint(docgen_tokenizer: *Tokenizer, out: var, source_token: Token) !void {
981fn tokenizeAndPrint(docgen_tokenizer: *Tokenizer, out: anytype, source_token: Token) !void {
981982 const raw_src = docgen_tokenizer.buffer[source_token.start..source_token.end];
982983 return tokenizeAndPrintRaw(docgen_tokenizer, out, source_token, raw_src);
983984}
984985
985fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var, zig_exe: []const u8) !void {
986fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: anytype, zig_exe: []const u8) !void {
986987 var code_progress_index: usize = 0;
987988
988989 var env_map = try process.getEnvMap(allocator);
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
lib/std/array_list.zig+1-1
......@@ -53,7 +53,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
5353 /// Deprecated: use `items` field directly.
5454 /// Return contents as a slice. Only valid while the list
5555 /// doesn't change size.
56 pub fn span(self: var) @TypeOf(self.items) {
56 pub fn span(self: anytype) @TypeOf(self.items) {
5757 return self.items;
5858 }
5959
lib/std/array_list_sentineled.zig+2-2
......@@ -69,7 +69,7 @@ pub fn ArrayListSentineled(comptime T: type, comptime sentinel: T) type {
6969 }
7070
7171 /// Only works when `T` is `u8`.
72 pub fn allocPrint(allocator: *Allocator, comptime format: []const u8, args: var) !Self {
72 pub fn allocPrint(allocator: *Allocator, comptime format: []const u8, args: anytype) !Self {
7373 const size = std.math.cast(usize, std.fmt.count(format, args)) catch |err| switch (err) {
7474 error.Overflow => return error.OutOfMemory,
7575 };
......@@ -82,7 +82,7 @@ pub fn ArrayListSentineled(comptime T: type, comptime sentinel: T) type {
8282 self.list.deinit();
8383 }
8484
85 pub fn span(self: var) @TypeOf(self.list.items[0..:sentinel]) {
85 pub fn span(self: anytype) @TypeOf(self.list.items[0..:sentinel]) {
8686 return self.list.items[0..self.len() :sentinel];
8787 }
8888
lib/std/atomic/queue.zig+2-2
......@@ -123,10 +123,10 @@ pub fn Queue(comptime T: type) type {
123123 /// Dumps the contents of the queue to `stream`.
124124 /// Up to 4 elements from the head are dumped and the tail of the queue is
125125 /// dumped as well.
126 pub fn dumpToStream(self: *Self, stream: var) !void {
126 pub fn dumpToStream(self: *Self, stream: anytype) !void {
127127 const S = struct {
128128 fn dumpRecursive(
129 s: var,
129 s: anytype,
130130 optional_node: ?*Node,
131131 indent: usize,
132132 comptime depth: comptime_int,
lib/std/build.zig+2-2
......@@ -312,7 +312,7 @@ pub const Builder = struct {
312312 return write_file_step;
313313 }
314314
315 pub fn addLog(self: *Builder, comptime format: []const u8, args: var) *LogStep {
315 pub fn addLog(self: *Builder, comptime format: []const u8, args: anytype) *LogStep {
316316 const data = self.fmt(format, args);
317317 const log_step = self.allocator.create(LogStep) catch unreachable;
318318 log_step.* = LogStep.init(self, data);
......@@ -883,7 +883,7 @@ pub const Builder = struct {
883883 return fs.path.resolve(self.allocator, &[_][]const u8{ self.build_root, rel_path }) catch unreachable;
884884 }
885885
886 pub fn fmt(self: *Builder, comptime format: []const u8, args: var) []u8 {
886 pub fn fmt(self: *Builder, comptime format: []const u8, args: anytype) []u8 {
887887 return fmt_lib.allocPrint(self.allocator, format, args) catch unreachable;
888888 }
889889
lib/std/build/emit_raw.zig+1-1
......@@ -126,7 +126,7 @@ const BinaryElfOutput = struct {
126126 return segment.p_offset <= section.elfOffset and (segment.p_offset + segment.p_filesz) >= (section.elfOffset + section.fileSize);
127127 }
128128
129 fn sectionValidForOutput(shdr: var) bool {
129 fn sectionValidForOutput(shdr: anytype) bool {
130130 return shdr.sh_size > 0 and shdr.sh_type != elf.SHT_NOBITS and
131131 ((shdr.sh_flags & elf.SHF_ALLOC) == elf.SHF_ALLOC);
132132 }
lib/std/builtin.zig+5-5
......@@ -198,7 +198,7 @@ pub const TypeInfo = union(enum) {
198198 /// The type of the sentinel is the element type of the pointer, which is
199199 /// the value of the `child` field in this struct. However there is no way
200200 /// to refer to that type here, so we use `var`.
201 sentinel: var,
201 sentinel: anytype,
202202
203203 /// This data structure is used by the Zig language code generation and
204204 /// therefore must be kept in sync with the compiler implementation.
......@@ -220,7 +220,7 @@ pub const TypeInfo = union(enum) {
220220 /// The type of the sentinel is the element type of the array, which is
221221 /// the value of the `child` field in this struct. However there is no way
222222 /// to refer to that type here, so we use `var`.
223 sentinel: var,
223 sentinel: anytype,
224224 };
225225
226226 /// This data structure is used by the Zig language code generation and
......@@ -237,7 +237,7 @@ pub const TypeInfo = union(enum) {
237237 name: []const u8,
238238 offset: ?comptime_int,
239239 field_type: type,
240 default_value: var,
240 default_value: anytype,
241241 };
242242
243243 /// This data structure is used by the Zig language code generation and
......@@ -328,7 +328,7 @@ pub const TypeInfo = union(enum) {
328328 /// This data structure is used by the Zig language code generation and
329329 /// therefore must be kept in sync with the compiler implementation.
330330 pub const Frame = struct {
331 function: var,
331 function: anytype,
332332 };
333333
334334 /// This data structure is used by the Zig language code generation and
......@@ -452,7 +452,7 @@ pub const Version = struct {
452452 self: Version,
453453 comptime fmt: []const u8,
454454 options: std.fmt.FormatOptions,
455 out_stream: var,
455 out_stream: anytype,
456456 ) !void {
457457 if (fmt.len == 0) {
458458 if (self.patch == 0) {
lib/std/c.zig+1-1
......@@ -27,7 +27,7 @@ pub usingnamespace switch (std.Target.current.os.tag) {
2727 else => struct {},
2828};
2929
30pub fn getErrno(rc: var) u16 {
30pub fn getErrno(rc: anytype) u16 {
3131 if (rc == -1) {
3232 return @intCast(u16, _errno().*);
3333 } else {
lib/std/c/ast.zig+7-7
......@@ -64,7 +64,7 @@ pub const Error = union(enum) {
6464 NothingDeclared: SimpleError("declaration doesn't declare anything"),
6565 QualifierIgnored: SingleTokenError("qualifier '{}' ignored"),
6666
67 pub fn render(self: *const Error, tree: *Tree, stream: var) !void {
67 pub fn render(self: *const Error, tree: *Tree, stream: anytype) !void {
6868 switch (self.*) {
6969 .InvalidToken => |*x| return x.render(tree, stream),
7070 .ExpectedToken => |*x| return x.render(tree, stream),
......@@ -114,7 +114,7 @@ pub const Error = union(enum) {
114114 token: TokenIndex,
115115 expected_id: @TagType(Token.Id),
116116
117 pub fn render(self: *const ExpectedToken, tree: *Tree, stream: var) !void {
117 pub fn render(self: *const ExpectedToken, tree: *Tree, stream: anytype) !void {
118118 const found_token = tree.tokens.at(self.token);
119119 if (found_token.id == .Invalid) {
120120 return stream.print("expected '{}', found invalid bytes", .{self.expected_id.symbol()});
......@@ -129,7 +129,7 @@ pub const Error = union(enum) {
129129 token: TokenIndex,
130130 type_spec: *Node.TypeSpec,
131131
132 pub fn render(self: *const ExpectedToken, tree: *Tree, stream: var) !void {
132 pub fn render(self: *const ExpectedToken, tree: *Tree, stream: anytype) !void {
133133 try stream.write("invalid type specifier '");
134134 try type_spec.spec.print(tree, stream);
135135 const token_name = tree.tokens.at(self.token).id.symbol();
......@@ -141,7 +141,7 @@ pub const Error = union(enum) {
141141 kw: TokenIndex,
142142 name: TokenIndex,
143143
144 pub fn render(self: *const ExpectedToken, tree: *Tree, stream: var) !void {
144 pub fn render(self: *const ExpectedToken, tree: *Tree, stream: anytype) !void {
145145 return stream.print("must use '{}' tag to refer to type '{}'", .{ tree.slice(kw), tree.slice(name) });
146146 }
147147 };
......@@ -150,7 +150,7 @@ pub const Error = union(enum) {
150150 return struct {
151151 token: TokenIndex,
152152
153 pub fn render(self: *const @This(), tree: *Tree, stream: var) !void {
153 pub fn render(self: *const @This(), tree: *Tree, stream: anytype) !void {
154154 const actual_token = tree.tokens.at(self.token);
155155 return stream.print(msg, .{actual_token.id.symbol()});
156156 }
......@@ -163,7 +163,7 @@ pub const Error = union(enum) {
163163
164164 token: TokenIndex,
165165
166 pub fn render(self: *const ThisError, tokens: *Tree.TokenList, stream: var) !void {
166 pub fn render(self: *const ThisError, tokens: *Tree.TokenList, stream: anytype) !void {
167167 return stream.write(msg);
168168 }
169169 };
......@@ -317,7 +317,7 @@ pub const Node = struct {
317317 sym_type: *Type,
318318 },
319319
320 pub fn print(self: *@This(), self: *const @This(), tree: *Tree, stream: var) !void {
320 pub fn print(self: *@This(), self: *const @This(), tree: *Tree, stream: anytype) !void {
321321 switch (self.spec) {
322322 .None => unreachable,
323323 .Void => |index| try stream.write(tree.slice(index)),
lib/std/cache_hash.zig+1-1
......@@ -70,7 +70,7 @@ pub const CacheHash = struct {
7070
7171 /// Convert the input value into bytes and record it as a dependency of the
7272 /// process being cached
73 pub fn add(self: *CacheHash, val: var) void {
73 pub fn add(self: *CacheHash, val: anytype) void {
7474 assert(self.manifest_file == null);
7575
7676 const valPtr = switch (@typeInfo(@TypeOf(val))) {
lib/std/comptime_string_map.zig+3-3
......@@ -8,7 +8,7 @@ const mem = std.mem;
88/// `kvs` expects a list literal containing list literals or an array/slice of structs
99/// where `.@"0"` is the `[]const u8` key and `.@"1"` is the associated value of type `V`.
1010/// TODO: https://github.com/ziglang/zig/issues/4335
11pub fn ComptimeStringMap(comptime V: type, comptime kvs: var) type {
11pub fn ComptimeStringMap(comptime V: type, comptime kvs: anytype) type {
1212 const precomputed = comptime blk: {
1313 @setEvalBranchQuota(2000);
1414 const KV = struct {
......@@ -126,7 +126,7 @@ test "ComptimeStringMap slice of structs" {
126126 testMap(map);
127127}
128128
129fn testMap(comptime map: var) void {
129fn testMap(comptime map: anytype) void {
130130 std.testing.expectEqual(TestEnum.A, map.get("have").?);
131131 std.testing.expectEqual(TestEnum.B, map.get("nothing").?);
132132 std.testing.expect(null == map.get("missing"));
......@@ -165,7 +165,7 @@ test "ComptimeStringMap void value type, list literal of list literals" {
165165 testSet(map);
166166}
167167
168fn testSet(comptime map: var) void {
168fn testSet(comptime map: anytype) void {
169169 std.testing.expectEqual({}, map.get("have").?);
170170 std.testing.expectEqual({}, map.get("nothing").?);
171171 std.testing.expect(null == map.get("missing"));
lib/std/crypto/benchmark.zig+6-6
......@@ -29,7 +29,7 @@ const hashes = [_]Crypto{
2929 Crypto{ .ty = crypto.Blake3, .name = "blake3" },
3030};
3131
32pub fn benchmarkHash(comptime Hash: var, comptime bytes: comptime_int) !u64 {
32pub fn benchmarkHash(comptime Hash: anytype, comptime bytes: comptime_int) !u64 {
3333 var h = Hash.init();
3434
3535 var block: [Hash.digest_length]u8 = undefined;
......@@ -56,7 +56,7 @@ const macs = [_]Crypto{
5656 Crypto{ .ty = crypto.HmacSha256, .name = "hmac-sha256" },
5757};
5858
59pub fn benchmarkMac(comptime Mac: var, comptime bytes: comptime_int) !u64 {
59pub fn benchmarkMac(comptime Mac: anytype, comptime bytes: comptime_int) !u64 {
6060 std.debug.assert(32 >= Mac.mac_length and 32 >= Mac.minimum_key_length);
6161
6262 var in: [1 * MiB]u8 = undefined;
......@@ -81,7 +81,7 @@ pub fn benchmarkMac(comptime Mac: var, comptime bytes: comptime_int) !u64 {
8181
8282const exchanges = [_]Crypto{Crypto{ .ty = crypto.X25519, .name = "x25519" }};
8383
84pub fn benchmarkKeyExchange(comptime DhKeyExchange: var, comptime exchange_count: comptime_int) !u64 {
84pub fn benchmarkKeyExchange(comptime DhKeyExchange: anytype, comptime exchange_count: comptime_int) !u64 {
8585 std.debug.assert(DhKeyExchange.minimum_key_length >= DhKeyExchange.secret_length);
8686
8787 var in: [DhKeyExchange.minimum_key_length]u8 = undefined;
......@@ -166,21 +166,21 @@ pub fn main() !void {
166166 inline for (hashes) |H| {
167167 if (filter == null or std.mem.indexOf(u8, H.name, filter.?) != null) {
168168 const throughput = try benchmarkHash(H.ty, mode(32 * MiB));
169 try stdout.print("{:>11}: {:5} MiB/s\n", .{H.name, throughput / (1 * MiB)});
169 try stdout.print("{:>11}: {:5} MiB/s\n", .{ H.name, throughput / (1 * MiB) });
170170 }
171171 }
172172
173173 inline for (macs) |M| {
174174 if (filter == null or std.mem.indexOf(u8, M.name, filter.?) != null) {
175175 const throughput = try benchmarkMac(M.ty, mode(128 * MiB));
176 try stdout.print("{:>11}: {:5} MiB/s\n", .{M.name, throughput / (1 * MiB)});
176 try stdout.print("{:>11}: {:5} MiB/s\n", .{ M.name, throughput / (1 * MiB) });
177177 }
178178 }
179179
180180 inline for (exchanges) |E| {
181181 if (filter == null or std.mem.indexOf(u8, E.name, filter.?) != null) {
182182 const throughput = try benchmarkKeyExchange(E.ty, mode(1000));
183 try stdout.print("{:>11}: {:5} exchanges/s\n", .{E.name, throughput});
183 try stdout.print("{:>11}: {:5} exchanges/s\n", .{ E.name, throughput });
184184 }
185185 }
186186}
lib/std/crypto/test.zig+1-1
......@@ -4,7 +4,7 @@ const mem = std.mem;
44const fmt = std.fmt;
55
66// Hash using the specified hasher `H` asserting `expected == H(input)`.
7pub fn assertEqualHash(comptime Hasher: var, comptime expected: []const u8, input: []const u8) void {
7pub fn assertEqualHash(comptime Hasher: anytype, comptime expected: []const u8, input: []const u8) void {
88 var h: [expected.len / 2]u8 = undefined;
99 Hasher.hash(input, h[0..]);
1010
lib/std/debug.zig+12-12
......@@ -58,7 +58,7 @@ pub const warn = print;
5858
5959/// Print to stderr, unbuffered, and silently returning on failure. Intended
6060/// for use in "printf debugging." Use `std.log` functions for proper logging.
61pub fn print(comptime fmt: []const u8, args: var) void {
61pub fn print(comptime fmt: []const u8, args: anytype) void {
6262 const held = stderr_mutex.acquire();
6363 defer held.release();
6464 const stderr = io.getStdErr().writer();
......@@ -223,7 +223,7 @@ pub fn assert(ok: bool) void {
223223 if (!ok) unreachable; // assertion failure
224224}
225225
226pub fn panic(comptime format: []const u8, args: var) noreturn {
226pub fn panic(comptime format: []const u8, args: anytype) noreturn {
227227 @setCold(true);
228228 // TODO: remove conditional once wasi / LLVM defines __builtin_return_address
229229 const first_trace_addr = if (builtin.os.tag == .wasi) null else @returnAddress();
......@@ -241,7 +241,7 @@ var panic_mutex = std.Mutex.init();
241241/// This is used to catch and handle panics triggered by the panic handler.
242242threadlocal var panic_stage: usize = 0;
243243
244pub fn panicExtra(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, comptime format: []const u8, args: var) noreturn {
244pub fn panicExtra(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, comptime format: []const u8, args: anytype) noreturn {
245245 @setCold(true);
246246
247247 if (enable_segfault_handler) {
......@@ -306,7 +306,7 @@ const RESET = "\x1b[0m";
306306
307307pub fn writeStackTrace(
308308 stack_trace: builtin.StackTrace,
309 out_stream: var,
309 out_stream: anytype,
310310 allocator: *mem.Allocator,
311311 debug_info: *DebugInfo,
312312 tty_config: TTY.Config,
......@@ -384,7 +384,7 @@ pub const StackIterator = struct {
384384};
385385
386386pub fn writeCurrentStackTrace(
387 out_stream: var,
387 out_stream: anytype,
388388 debug_info: *DebugInfo,
389389 tty_config: TTY.Config,
390390 start_addr: ?usize,
......@@ -399,7 +399,7 @@ pub fn writeCurrentStackTrace(
399399}
400400
401401pub fn writeCurrentStackTraceWindows(
402 out_stream: var,
402 out_stream: anytype,
403403 debug_info: *DebugInfo,
404404 tty_config: TTY.Config,
405405 start_addr: ?usize,
......@@ -435,7 +435,7 @@ pub const TTY = struct {
435435 // TODO give this a payload of file handle
436436 windows_api,
437437
438 fn setColor(conf: Config, out_stream: var, color: Color) void {
438 fn setColor(conf: Config, out_stream: anytype, color: Color) void {
439439 nosuspend switch (conf) {
440440 .no_color => return,
441441 .escape_codes => switch (color) {
......@@ -555,7 +555,7 @@ fn machoSearchSymbols(symbols: []const MachoSymbol, address: usize) ?*const Mach
555555}
556556
557557/// TODO resources https://github.com/ziglang/zig/issues/4353
558pub fn printSourceAtAddress(debug_info: *DebugInfo, out_stream: var, address: usize, tty_config: TTY.Config) !void {
558pub fn printSourceAtAddress(debug_info: *DebugInfo, out_stream: anytype, address: usize, tty_config: TTY.Config) !void {
559559 const module = debug_info.getModuleForAddress(address) catch |err| switch (err) {
560560 error.MissingDebugInfo, error.InvalidDebugInfo => {
561561 return printLineInfo(
......@@ -586,13 +586,13 @@ pub fn printSourceAtAddress(debug_info: *DebugInfo, out_stream: var, address: us
586586}
587587
588588fn printLineInfo(
589 out_stream: var,
589 out_stream: anytype,
590590 line_info: ?LineInfo,
591591 address: usize,
592592 symbol_name: []const u8,
593593 compile_unit_name: []const u8,
594594 tty_config: TTY.Config,
595 comptime printLineFromFile: var,
595 comptime printLineFromFile: anytype,
596596) !void {
597597 nosuspend {
598598 tty_config.setColor(out_stream, .White);
......@@ -820,7 +820,7 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf
820820 }
821821}
822822
823fn readSparseBitVector(stream: var, allocator: *mem.Allocator) ![]usize {
823fn readSparseBitVector(stream: anytype, allocator: *mem.Allocator) ![]usize {
824824 const num_words = try stream.readIntLittle(u32);
825825 var word_i: usize = 0;
826826 var list = ArrayList(usize).init(allocator);
......@@ -1004,7 +1004,7 @@ fn readMachODebugInfo(allocator: *mem.Allocator, macho_file: File) !ModuleDebugI
10041004 };
10051005}
10061006
1007fn printLineFromFileAnyOs(out_stream: var, line_info: LineInfo) !void {
1007fn printLineFromFileAnyOs(out_stream: anytype, line_info: LineInfo) !void {
10081008 // Need this to always block even in async I/O mode, because this could potentially
10091009 // be called from e.g. the event loop code crashing.
10101010 var f = try fs.cwd().openFile(line_info.file_name, .{ .intended_io_mode = .blocking });
lib/std/debug/leb128.zig+7-7
......@@ -3,7 +3,7 @@ const testing = std.testing;
33
44/// Read a single unsigned LEB128 value from the given reader as type T,
55/// or error.Overflow if the value cannot fit.
6pub fn readULEB128(comptime T: type, reader: var) !T {
6pub fn readULEB128(comptime T: type, reader: anytype) !T {
77 const U = if (T.bit_count < 8) u8 else T;
88 const ShiftT = std.math.Log2Int(U);
99
......@@ -33,7 +33,7 @@ pub fn readULEB128(comptime T: type, reader: var) !T {
3333}
3434
3535/// Write a single unsigned integer as unsigned LEB128 to the given writer.
36pub fn writeULEB128(writer: var, uint_value: var) !void {
36pub fn writeULEB128(writer: anytype, uint_value: anytype) !void {
3737 const T = @TypeOf(uint_value);
3838 const U = if (T.bit_count < 8) u8 else T;
3939 var value = @intCast(U, uint_value);
......@@ -61,7 +61,7 @@ pub fn readULEB128Mem(comptime T: type, ptr: *[]const u8) !T {
6161
6262/// Write a single unsigned LEB128 integer to the given memory as unsigned LEB128,
6363/// returning the number of bytes written.
64pub fn writeULEB128Mem(ptr: []u8, uint_value: var) !usize {
64pub fn writeULEB128Mem(ptr: []u8, uint_value: anytype) !usize {
6565 const T = @TypeOf(uint_value);
6666 const max_group = (T.bit_count + 6) / 7;
6767 var buf = std.io.fixedBufferStream(ptr);
......@@ -71,7 +71,7 @@ pub fn writeULEB128Mem(ptr: []u8, uint_value: var) !usize {
7171
7272/// Read a single signed LEB128 value from the given reader as type T,
7373/// or error.Overflow if the value cannot fit.
74pub fn readILEB128(comptime T: type, reader: var) !T {
74pub fn readILEB128(comptime T: type, reader: anytype) !T {
7575 const S = if (T.bit_count < 8) i8 else T;
7676 const U = std.meta.Int(false, S.bit_count);
7777 const ShiftU = std.math.Log2Int(U);
......@@ -120,7 +120,7 @@ pub fn readILEB128(comptime T: type, reader: var) !T {
120120}
121121
122122/// Write a single signed integer as signed LEB128 to the given writer.
123pub fn writeILEB128(writer: var, int_value: var) !void {
123pub fn writeILEB128(writer: anytype, int_value: anytype) !void {
124124 const T = @TypeOf(int_value);
125125 const S = if (T.bit_count < 8) i8 else T;
126126 const U = std.meta.Int(false, S.bit_count);
......@@ -152,7 +152,7 @@ pub fn readILEB128Mem(comptime T: type, ptr: *[]const u8) !T {
152152
153153/// Write a single signed LEB128 integer to the given memory as unsigned LEB128,
154154/// returning the number of bytes written.
155pub fn writeILEB128Mem(ptr: []u8, int_value: var) !usize {
155pub fn writeILEB128Mem(ptr: []u8, int_value: anytype) !usize {
156156 const T = @TypeOf(int_value);
157157 var buf = std.io.fixedBufferStream(ptr);
158158 try writeILEB128(buf.writer(), int_value);
......@@ -295,7 +295,7 @@ test "deserialize unsigned LEB128" {
295295 try test_read_uleb128_seq(u64, 4, "\x81\x01\x3f\x80\x7f\x80\x80\x80\x00");
296296}
297297
298fn test_write_leb128(value: var) !void {
298fn test_write_leb128(value: anytype) !void {
299299 const T = @TypeOf(value);
300300
301301 const writeStream = if (T.is_signed) writeILEB128 else writeULEB128;
lib/std/dwarf.zig+9-9
......@@ -236,7 +236,7 @@ const LineNumberProgram = struct {
236236 }
237237};
238238
239fn readUnitLength(in_stream: var, endian: builtin.Endian, is_64: *bool) !u64 {
239fn readUnitLength(in_stream: anytype, endian: builtin.Endian, is_64: *bool) !u64 {
240240 const first_32_bits = try in_stream.readInt(u32, endian);
241241 is_64.* = (first_32_bits == 0xffffffff);
242242 if (is_64.*) {
......@@ -249,7 +249,7 @@ fn readUnitLength(in_stream: var, endian: builtin.Endian, is_64: *bool) !u64 {
249249}
250250
251251// TODO the nosuspends here are workarounds
252fn readAllocBytes(allocator: *mem.Allocator, in_stream: var, size: usize) ![]u8 {
252fn readAllocBytes(allocator: *mem.Allocator, in_stream: anytype, size: usize) ![]u8 {
253253 const buf = try allocator.alloc(u8, size);
254254 errdefer allocator.free(buf);
255255 if ((try nosuspend in_stream.read(buf)) < size) return error.EndOfFile;
......@@ -257,25 +257,25 @@ fn readAllocBytes(allocator: *mem.Allocator, in_stream: var, size: usize) ![]u8
257257}
258258
259259// TODO the nosuspends here are workarounds
260fn readAddress(in_stream: var, endian: builtin.Endian, is_64: bool) !u64 {
260fn readAddress(in_stream: anytype, endian: builtin.Endian, is_64: bool) !u64 {
261261 return nosuspend if (is_64)
262262 try in_stream.readInt(u64, endian)
263263 else
264264 @as(u64, try in_stream.readInt(u32, endian));
265265}
266266
267fn parseFormValueBlockLen(allocator: *mem.Allocator, in_stream: var, size: usize) !FormValue {
267fn parseFormValueBlockLen(allocator: *mem.Allocator, in_stream: anytype, size: usize) !FormValue {
268268 const buf = try readAllocBytes(allocator, in_stream, size);
269269 return FormValue{ .Block = buf };
270270}
271271
272272// TODO the nosuspends here are workarounds
273fn parseFormValueBlock(allocator: *mem.Allocator, in_stream: var, endian: builtin.Endian, size: usize) !FormValue {
273fn parseFormValueBlock(allocator: *mem.Allocator, in_stream: anytype, endian: builtin.Endian, size: usize) !FormValue {
274274 const block_len = try nosuspend in_stream.readVarInt(usize, endian, size);
275275 return parseFormValueBlockLen(allocator, in_stream, block_len);
276276}
277277
278fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: var, signed: bool, endian: builtin.Endian, comptime size: i32) !FormValue {
278fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: anytype, signed: bool, endian: builtin.Endian, comptime size: i32) !FormValue {
279279 // TODO: Please forgive me, I've worked around zig not properly spilling some intermediate values here.
280280 // `nosuspend` should be removed from all the function calls once it is fixed.
281281 return FormValue{
......@@ -302,7 +302,7 @@ fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: var, signed: boo
302302}
303303
304304// TODO the nosuspends here are workarounds
305fn parseFormValueRef(allocator: *mem.Allocator, in_stream: var, endian: builtin.Endian, size: i32) !FormValue {
305fn parseFormValueRef(allocator: *mem.Allocator, in_stream: anytype, endian: builtin.Endian, size: i32) !FormValue {
306306 return FormValue{
307307 .Ref = switch (size) {
308308 1 => try nosuspend in_stream.readInt(u8, endian),
......@@ -316,7 +316,7 @@ fn parseFormValueRef(allocator: *mem.Allocator, in_stream: var, endian: builtin.
316316}
317317
318318// TODO the nosuspends here are workarounds
319fn parseFormValue(allocator: *mem.Allocator, in_stream: var, form_id: u64, endian: builtin.Endian, is_64: bool) anyerror!FormValue {
319fn parseFormValue(allocator: *mem.Allocator, in_stream: anytype, form_id: u64, endian: builtin.Endian, is_64: bool) anyerror!FormValue {
320320 return switch (form_id) {
321321 FORM_addr => FormValue{ .Address = try readAddress(in_stream, endian, @sizeOf(usize) == 8) },
322322 FORM_block1 => parseFormValueBlock(allocator, in_stream, endian, 1),
......@@ -670,7 +670,7 @@ pub const DwarfInfo = struct {
670670 }
671671 }
672672
673 fn parseDie(di: *DwarfInfo, in_stream: var, abbrev_table: *const AbbrevTable, is_64: bool) !?Die {
673 fn parseDie(di: *DwarfInfo, in_stream: anytype, abbrev_table: *const AbbrevTable, is_64: bool) !?Die {
674674 const abbrev_code = try leb.readULEB128(u64, in_stream);
675675 if (abbrev_code == 0) return null;
676676 const table_entry = getAbbrevTableEntry(abbrev_table, abbrev_code) orelse return error.InvalidDebugInfo;
lib/std/elf.zig+2-2
......@@ -517,7 +517,7 @@ pub fn readAllHeaders(allocator: *mem.Allocator, file: File) !AllHeaders {
517517 return hdrs;
518518}
519519
520pub fn int(is_64: bool, need_bswap: bool, int_32: var, int_64: var) @TypeOf(int_64) {
520pub fn int(is_64: bool, need_bswap: bool, int_32: anytype, int_64: anytype) @TypeOf(int_64) {
521521 if (is_64) {
522522 if (need_bswap) {
523523 return @byteSwap(@TypeOf(int_64), int_64);
......@@ -529,7 +529,7 @@ pub fn int(is_64: bool, need_bswap: bool, int_32: var, int_64: var) @TypeOf(int_
529529 }
530530}
531531
532pub fn int32(need_bswap: bool, int_32: var, comptime Int64: var) Int64 {
532pub fn int32(need_bswap: bool, int_32: anytype, comptime Int64: anytype) Int64 {
533533 if (need_bswap) {
534534 return @byteSwap(@TypeOf(int_32), int_32);
535535 } else {
lib/std/event/group.zig+1-1
......@@ -65,7 +65,7 @@ pub fn Group(comptime ReturnType: type) type {
6565 /// allocated by the group and freed by `wait`.
6666 /// `func` must be async and have return type `ReturnType`.
6767 /// Thread-safe.
68 pub fn call(self: *Self, comptime func: var, args: var) error{OutOfMemory}!void {
68 pub fn call(self: *Self, comptime func: anytype, args: anytype) error{OutOfMemory}!void {
6969 var frame = try self.allocator.create(@TypeOf(@call(.{ .modifier = .async_kw }, func, args)));
7070 errdefer self.allocator.destroy(frame);
7171 const node = try self.allocator.create(AllocStack.Node);
lib/std/fmt.zig+36-36
......@@ -69,16 +69,16 @@ fn peekIsAlign(comptime fmt: []const u8) bool {
6969///
7070/// If a formatted user type contains a function of the type
7171/// ```
72/// pub fn format(value: ?, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: var) !void
72/// pub fn format(value: ?, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void
7373/// ```
7474/// with `?` being the type formatted, this function will be called instead of the default implementation.
7575/// This allows user types to be formatted in a logical manner instead of dumping all fields of the type.
7676///
7777/// A user type may be a `struct`, `vector`, `union` or `enum` type.
7878pub fn format(
79 writer: var,
79 writer: anytype,
8080 comptime fmt: []const u8,
81 args: var,
81 args: anytype,
8282) !void {
8383 const ArgSetType = u32;
8484 if (@typeInfo(@TypeOf(args)) != .Struct) {
......@@ -311,10 +311,10 @@ pub fn format(
311311}
312312
313313pub fn formatType(
314 value: var,
314 value: anytype,
315315 comptime fmt: []const u8,
316316 options: FormatOptions,
317 writer: var,
317 writer: anytype,
318318 max_depth: usize,
319319) @TypeOf(writer).Error!void {
320320 if (comptime std.mem.eql(u8, fmt, "*")) {
......@@ -490,10 +490,10 @@ pub fn formatType(
490490}
491491
492492fn formatValue(
493 value: var,
493 value: anytype,
494494 comptime fmt: []const u8,
495495 options: FormatOptions,
496 writer: var,
496 writer: anytype,
497497) !void {
498498 if (comptime std.mem.eql(u8, fmt, "B")) {
499499 return formatBytes(value, options, 1000, writer);
......@@ -511,10 +511,10 @@ fn formatValue(
511511}
512512
513513pub fn formatIntValue(
514 value: var,
514 value: anytype,
515515 comptime fmt: []const u8,
516516 options: FormatOptions,
517 writer: var,
517 writer: anytype,
518518) !void {
519519 comptime var radix = 10;
520520 comptime var uppercase = false;
......@@ -551,10 +551,10 @@ pub fn formatIntValue(
551551}
552552
553553fn formatFloatValue(
554 value: var,
554 value: anytype,
555555 comptime fmt: []const u8,
556556 options: FormatOptions,
557 writer: var,
557 writer: anytype,
558558) !void {
559559 if (fmt.len == 0 or comptime std.mem.eql(u8, fmt, "e")) {
560560 return formatFloatScientific(value, options, writer);
......@@ -569,7 +569,7 @@ pub fn formatText(
569569 bytes: []const u8,
570570 comptime fmt: []const u8,
571571 options: FormatOptions,
572 writer: var,
572 writer: anytype,
573573) !void {
574574 if (comptime std.mem.eql(u8, fmt, "s") or (fmt.len == 0)) {
575575 return formatBuf(bytes, options, writer);
......@@ -586,7 +586,7 @@ pub fn formatText(
586586pub fn formatAsciiChar(
587587 c: u8,
588588 options: FormatOptions,
589 writer: var,
589 writer: anytype,
590590) !void {
591591 return writer.writeAll(@as(*const [1]u8, &c));
592592}
......@@ -594,7 +594,7 @@ pub fn formatAsciiChar(
594594pub fn formatBuf(
595595 buf: []const u8,
596596 options: FormatOptions,
597 writer: var,
597 writer: anytype,
598598) !void {
599599 const width = options.width orelse buf.len;
600600 var padding = if (width > buf.len) (width - buf.len) else 0;
......@@ -626,9 +626,9 @@ pub fn formatBuf(
626626// It should be the case that every full precision, printed value can be re-parsed back to the
627627// same type unambiguously.
628628pub fn formatFloatScientific(
629 value: var,
629 value: anytype,
630630 options: FormatOptions,
631 writer: var,
631 writer: anytype,
632632) !void {
633633 var x = @floatCast(f64, value);
634634
......@@ -719,9 +719,9 @@ pub fn formatFloatScientific(
719719// Print a float of the format x.yyyyy where the number of y is specified by the precision argument.
720720// By default floats are printed at full precision (no rounding).
721721pub fn formatFloatDecimal(
722 value: var,
722 value: anytype,
723723 options: FormatOptions,
724 writer: var,
724 writer: anytype,
725725) !void {
726726 var x = @as(f64, value);
727727
......@@ -860,10 +860,10 @@ pub fn formatFloatDecimal(
860860}
861861
862862pub fn formatBytes(
863 value: var,
863 value: anytype,
864864 options: FormatOptions,
865865 comptime radix: usize,
866 writer: var,
866 writer: anytype,
867867) !void {
868868 if (value == 0) {
869869 return writer.writeAll("0B");
......@@ -901,11 +901,11 @@ pub fn formatBytes(
901901}
902902
903903pub fn formatInt(
904 value: var,
904 value: anytype,
905905 base: u8,
906906 uppercase: bool,
907907 options: FormatOptions,
908 writer: var,
908 writer: anytype,
909909) !void {
910910 const int_value = if (@TypeOf(value) == comptime_int) blk: {
911911 const Int = math.IntFittingRange(value, value);
......@@ -921,11 +921,11 @@ pub fn formatInt(
921921}
922922
923923fn formatIntSigned(
924 value: var,
924 value: anytype,
925925 base: u8,
926926 uppercase: bool,
927927 options: FormatOptions,
928 writer: var,
928 writer: anytype,
929929) !void {
930930 const new_options = FormatOptions{
931931 .width = if (options.width) |w| (if (w == 0) 0 else w - 1) else null,
......@@ -948,11 +948,11 @@ fn formatIntSigned(
948948}
949949
950950fn formatIntUnsigned(
951 value: var,
951 value: anytype,
952952 base: u8,
953953 uppercase: bool,
954954 options: FormatOptions,
955 writer: var,
955 writer: anytype,
956956) !void {
957957 assert(base >= 2);
958958 var buf: [math.max(@TypeOf(value).bit_count, 1)]u8 = undefined;
......@@ -990,7 +990,7 @@ fn formatIntUnsigned(
990990 }
991991}
992992
993pub fn formatIntBuf(out_buf: []u8, value: var, base: u8, uppercase: bool, options: FormatOptions) usize {
993pub fn formatIntBuf(out_buf: []u8, value: anytype, base: u8, uppercase: bool, options: FormatOptions) usize {
994994 var fbs = std.io.fixedBufferStream(out_buf);
995995 formatInt(value, base, uppercase, options, fbs.writer()) catch unreachable;
996996 return fbs.pos;
......@@ -1050,7 +1050,7 @@ fn parseWithSign(
10501050 .Pos => math.add,
10511051 .Neg => math.sub,
10521052 };
1053
1053
10541054 var x: T = 0;
10551055
10561056 for (buf) |c| {
......@@ -1132,14 +1132,14 @@ pub const BufPrintError = error{
11321132 /// As much as possible was written to the buffer, but it was too small to fit all the printed bytes.
11331133 NoSpaceLeft,
11341134};
1135pub fn bufPrint(buf: []u8, comptime fmt: []const u8, args: var) BufPrintError![]u8 {
1135pub fn bufPrint(buf: []u8, comptime fmt: []const u8, args: anytype) BufPrintError![]u8 {
11361136 var fbs = std.io.fixedBufferStream(buf);
11371137 try format(fbs.writer(), fmt, args);
11381138 return fbs.getWritten();
11391139}
11401140
11411141// Count the characters needed for format. Useful for preallocating memory
1142pub fn count(comptime fmt: []const u8, args: var) u64 {
1142pub fn count(comptime fmt: []const u8, args: anytype) u64 {
11431143 var counting_writer = std.io.countingWriter(std.io.null_writer);
11441144 format(counting_writer.writer(), fmt, args) catch |err| switch (err) {};
11451145 return counting_writer.bytes_written;
......@@ -1147,7 +1147,7 @@ pub fn count(comptime fmt: []const u8, args: var) u64 {
11471147
11481148pub const AllocPrintError = error{OutOfMemory};
11491149
1150pub fn allocPrint(allocator: *mem.Allocator, comptime fmt: []const u8, args: var) AllocPrintError![]u8 {
1150pub fn allocPrint(allocator: *mem.Allocator, comptime fmt: []const u8, args: anytype) AllocPrintError![]u8 {
11511151 const size = math.cast(usize, count(fmt, args)) catch |err| switch (err) {
11521152 // Output too long. Can't possibly allocate enough memory to display it.
11531153 error.Overflow => return error.OutOfMemory,
......@@ -1158,7 +1158,7 @@ pub fn allocPrint(allocator: *mem.Allocator, comptime fmt: []const u8, args: var
11581158 };
11591159}
11601160
1161pub fn allocPrint0(allocator: *mem.Allocator, comptime fmt: []const u8, args: var) AllocPrintError![:0]u8 {
1161pub fn allocPrint0(allocator: *mem.Allocator, comptime fmt: []const u8, args: anytype) AllocPrintError![:0]u8 {
11621162 const result = try allocPrint(allocator, fmt ++ "\x00", args);
11631163 return result[0 .. result.len - 1 :0];
11641164}
......@@ -1184,7 +1184,7 @@ test "bufPrintInt" {
11841184 std.testing.expectEqualSlices(u8, "-42", bufPrintIntToSlice(buf, @as(i32, -42), 10, false, FormatOptions{ .width = 3 }));
11851185}
11861186
1187fn bufPrintIntToSlice(buf: []u8, value: var, base: u8, uppercase: bool, options: FormatOptions) []u8 {
1187fn bufPrintIntToSlice(buf: []u8, value: anytype, base: u8, uppercase: bool, options: FormatOptions) []u8 {
11881188 return buf[0..formatIntBuf(buf, value, base, uppercase, options)];
11891189}
11901190
......@@ -1452,7 +1452,7 @@ test "custom" {
14521452 self: SelfType,
14531453 comptime fmt: []const u8,
14541454 options: FormatOptions,
1455 writer: var,
1455 writer: anytype,
14561456 ) !void {
14571457 if (fmt.len == 0 or comptime std.mem.eql(u8, fmt, "p")) {
14581458 return std.fmt.format(writer, "({d:.3},{d:.3})", .{ self.x, self.y });
......@@ -1573,7 +1573,7 @@ test "bytes.hex" {
15731573 try testFmt("lowercase: 000ebabe\n", "lowercase: {x}\n", .{bytes_with_zeros});
15741574}
15751575
1576fn testFmt(expected: []const u8, comptime template: []const u8, args: var) !void {
1576fn testFmt(expected: []const u8, comptime template: []const u8, args: anytype) !void {
15771577 var buf: [100]u8 = undefined;
15781578 const result = try bufPrint(buf[0..], template, args);
15791579 if (mem.eql(u8, result, expected)) return;
......@@ -1669,7 +1669,7 @@ test "formatType max_depth" {
16691669 self: SelfType,
16701670 comptime fmt: []const u8,
16711671 options: FormatOptions,
1672 writer: var,
1672 writer: anytype,
16731673 ) !void {
16741674 if (fmt.len == 0) {
16751675 return std.fmt.format(writer, "({d:.3},{d:.3})", .{ self.x, self.y });
lib/std/fs/wasi.zig+1-1
......@@ -29,7 +29,7 @@ pub const PreopenType = union(PreopenTypeTag) {
2929 }
3030 }
3131
32 pub fn format(self: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, out_stream: var) !void {
32 pub fn format(self: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, out_stream: anytype) !void {
3333 try out_stream.print("PreopenType{{ ", .{});
3434 switch (self) {
3535 PreopenType.Dir => |path| try out_stream.print(".Dir = '{}'", .{path}),
lib/std/hash/auto_hash.zig+8-8
......@@ -21,7 +21,7 @@ pub const HashStrategy = enum {
2121};
2222
2323/// Helper function to hash a pointer and mutate the strategy if needed.
24pub fn hashPointer(hasher: var, key: var, comptime strat: HashStrategy) void {
24pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
2525 const info = @typeInfo(@TypeOf(key));
2626
2727 switch (info.Pointer.size) {
......@@ -53,7 +53,7 @@ pub fn hashPointer(hasher: var, key: var, comptime strat: HashStrategy) void {
5353}
5454
5555/// Helper function to hash a set of contiguous objects, from an array or slice.
56pub fn hashArray(hasher: var, key: var, comptime strat: HashStrategy) void {
56pub fn hashArray(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
5757 switch (strat) {
5858 .Shallow => {
5959 // TODO detect via a trait when Key has no padding bits to
......@@ -73,7 +73,7 @@ pub fn hashArray(hasher: var, key: var, comptime strat: HashStrategy) void {
7373
7474/// Provides generic hashing for any eligible type.
7575/// Strategy is provided to determine if pointers should be followed or not.
76pub fn hash(hasher: var, key: var, comptime strat: HashStrategy) void {
76pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
7777 const Key = @TypeOf(key);
7878 switch (@typeInfo(Key)) {
7979 .NoReturn,
......@@ -161,7 +161,7 @@ pub fn hash(hasher: var, key: var, comptime strat: HashStrategy) void {
161161/// Provides generic hashing for any eligible type.
162162/// Only hashes `key` itself, pointers are not followed.
163163/// Slices are rejected to avoid ambiguity on the user's intention.
164pub fn autoHash(hasher: var, key: var) void {
164pub fn autoHash(hasher: anytype, key: anytype) void {
165165 const Key = @TypeOf(key);
166166 if (comptime meta.trait.isSlice(Key)) {
167167 comptime assert(@hasDecl(std, "StringHashMap")); // detect when the following message needs updated
......@@ -181,28 +181,28 @@ pub fn autoHash(hasher: var, key: var) void {
181181const testing = std.testing;
182182const Wyhash = std.hash.Wyhash;
183183
184fn testHash(key: var) u64 {
184fn testHash(key: anytype) u64 {
185185 // Any hash could be used here, for testing autoHash.
186186 var hasher = Wyhash.init(0);
187187 hash(&hasher, key, .Shallow);
188188 return hasher.final();
189189}
190190
191fn testHashShallow(key: var) u64 {
191fn testHashShallow(key: anytype) u64 {
192192 // Any hash could be used here, for testing autoHash.
193193 var hasher = Wyhash.init(0);
194194 hash(&hasher, key, .Shallow);
195195 return hasher.final();
196196}
197197
198fn testHashDeep(key: var) u64 {
198fn testHashDeep(key: anytype) u64 {
199199 // Any hash could be used here, for testing autoHash.
200200 var hasher = Wyhash.init(0);
201201 hash(&hasher, key, .Deep);
202202 return hasher.final();
203203}
204204
205fn testHashDeepRecursive(key: var) u64 {
205fn testHashDeepRecursive(key: anytype) u64 {
206206 // Any hash could be used here, for testing autoHash.
207207 var hasher = Wyhash.init(0);
208208 hash(&hasher, key, .DeepRecursive);
lib/std/hash/benchmark.zig+2-2
......@@ -88,7 +88,7 @@ const Result = struct {
8888
8989const block_size: usize = 8 * 8192;
9090
91pub fn benchmarkHash(comptime H: var, bytes: usize) !Result {
91pub fn benchmarkHash(comptime H: anytype, bytes: usize) !Result {
9292 var h = blk: {
9393 if (H.init_u8s) |init| {
9494 break :blk H.ty.init(init);
......@@ -119,7 +119,7 @@ pub fn benchmarkHash(comptime H: var, bytes: usize) !Result {
119119 };
120120}
121121
122pub fn benchmarkHashSmallKeys(comptime H: var, key_size: usize, bytes: usize) !Result {
122pub fn benchmarkHashSmallKeys(comptime H: anytype, key_size: usize, bytes: usize) !Result {
123123 const key_count = bytes / key_size;
124124 var block: [block_size]u8 = undefined;
125125 prng.random.bytes(block[0..]);
lib/std/hash/cityhash.zig+1-1
......@@ -354,7 +354,7 @@ pub const CityHash64 = struct {
354354 }
355355};
356356
357fn SMHasherTest(comptime hash_fn: var, comptime hashbits: u32) u32 {
357fn SMHasherTest(comptime hash_fn: anytype, comptime hashbits: u32) u32 {
358358 const hashbytes = hashbits / 8;
359359 var key: [256]u8 = undefined;
360360 var hashes: [hashbytes * 256]u8 = undefined;
lib/std/hash/murmur.zig+1-1
......@@ -279,7 +279,7 @@ pub const Murmur3_32 = struct {
279279 }
280280};
281281
282fn SMHasherTest(comptime hash_fn: var, comptime hashbits: u32) u32 {
282fn SMHasherTest(comptime hash_fn: anytype, comptime hashbits: u32) u32 {
283283 const hashbytes = hashbits / 8;
284284 var key: [256]u8 = undefined;
285285 var hashes: [hashbytes * 256]u8 = undefined;
lib/std/heap.zig+17-14
......@@ -15,15 +15,20 @@ pub const ArenaAllocator = @import("heap/arena_allocator.zig").ArenaAllocator;
1515
1616const Allocator = mem.Allocator;
1717
18usingnamespace if (comptime @hasDecl(c, "malloc_size")) struct {
19 pub const supports_malloc_size = true;
20 pub const malloc_size = c.malloc_size;
21} else if (comptime @hasDecl(c, "malloc_usable_size")) struct {
22 pub const supports_malloc_size = true;
23 pub const malloc_size = c.malloc_usable_size;
24} else struct {
25 pub const supports_malloc_size = false;
26};
18usingnamespace if (comptime @hasDecl(c, "malloc_size"))
19 struct {
20 pub const supports_malloc_size = true;
21 pub const malloc_size = c.malloc_size;
22 }
23else if (comptime @hasDecl(c, "malloc_usable_size"))
24 struct {
25 pub const supports_malloc_size = true;
26 pub const malloc_size = c.malloc_usable_size;
27 }
28else
29 struct {
30 pub const supports_malloc_size = false;
31 };
2732
2833pub const c_allocator = &c_allocator_state;
2934var c_allocator_state = Allocator{
......@@ -151,8 +156,7 @@ const PageAllocator = struct {
151156 }
152157
153158 const maxDropLen = alignment - std.math.min(alignment, mem.page_size);
154 const allocLen = if (maxDropLen <= alignedLen - n) alignedLen
155 else mem.alignForward(alignedLen + maxDropLen, mem.page_size);
159 const allocLen = if (maxDropLen <= alignedLen - n) alignedLen else mem.alignForward(alignedLen + maxDropLen, mem.page_size);
156160 const slice = os.mmap(
157161 null,
158162 allocLen,
......@@ -331,8 +335,7 @@ const WasmPageAllocator = struct {
331335 fn alloc(allocator: *Allocator, len: usize, alignment: u29, len_align: u29) error{OutOfMemory}![]u8 {
332336 const page_count = nPages(len);
333337 const page_idx = try allocPages(page_count, alignment);
334 return @intToPtr([*]u8, page_idx * mem.page_size)
335 [0..alignPageAllocLen(page_count * mem.page_size, len, len_align)];
338 return @intToPtr([*]u8, page_idx * mem.page_size)[0..alignPageAllocLen(page_count * mem.page_size, len, len_align)];
336339 }
337340 fn allocPages(page_count: usize, alignment: u29) !usize {
338341 {
......@@ -452,7 +455,7 @@ pub const HeapAllocator = switch (builtin.os.tag) {
452455 fn resize(allocator: *Allocator, buf: []u8, new_size: usize, len_align: u29) error{OutOfMemory}!usize {
453456 const self = @fieldParentPtr(HeapAllocator, "allocator", allocator);
454457 if (new_size == 0) {
455 os.windows.HeapFree(self.heap_handle.?, 0, @intToPtr(*c_void ,getRecordPtr(buf).*));
458 os.windows.HeapFree(self.heap_handle.?, 0, @intToPtr(*c_void, getRecordPtr(buf).*));
456459 return 0;
457460 }
458461
lib/std/heap/logging_allocator.zig+2-2
......@@ -40,7 +40,7 @@ pub fn LoggingAllocator(comptime OutStreamType: type) type {
4040 if (new_len == 0) {
4141 self.out_stream.print("free : {}\n", .{buf.len}) catch {};
4242 } else if (new_len <= buf.len) {
43 self.out_stream.print("shrink: {} to {}\n", .{buf.len, new_len}) catch {};
43 self.out_stream.print("shrink: {} to {}\n", .{ buf.len, new_len }) catch {};
4444 } else {
4545 self.out_stream.print("expand: {} to {}", .{ buf.len, new_len }) catch {};
4646 }
......@@ -60,7 +60,7 @@ pub fn LoggingAllocator(comptime OutStreamType: type) type {
6060
6161pub fn loggingAllocator(
6262 parent_allocator: *Allocator,
63 out_stream: var,
63 out_stream: anytype,
6464) LoggingAllocator(@TypeOf(out_stream)) {
6565 return LoggingAllocator(@TypeOf(out_stream)).init(parent_allocator, out_stream);
6666}
lib/std/http/headers.zig+1-1
......@@ -348,7 +348,7 @@ pub const Headers = struct {
348348 self: Self,
349349 comptime fmt: []const u8,
350350 options: std.fmt.FormatOptions,
351 out_stream: var,
351 out_stream: anytype,
352352 ) !void {
353353 for (self.toSlice()) |entry| {
354354 try out_stream.writeAll(entry.name);
lib/std/io/bit_reader.zig+1-1
......@@ -170,7 +170,7 @@ pub fn BitReader(endian: builtin.Endian, comptime ReaderType: type) type {
170170
171171pub fn bitReader(
172172 comptime endian: builtin.Endian,
173 underlying_stream: var,
173 underlying_stream: anytype,
174174) BitReader(endian, @TypeOf(underlying_stream)) {
175175 return BitReader(endian, @TypeOf(underlying_stream)).init(underlying_stream);
176176}
lib/std/io/bit_writer.zig+2-2
......@@ -34,7 +34,7 @@ pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type {
3434 /// Write the specified number of bits to the stream from the least significant bits of
3535 /// the specified unsigned int value. Bits will only be written to the stream when there
3636 /// are enough to fill a byte.
37 pub fn writeBits(self: *Self, value: var, bits: usize) Error!void {
37 pub fn writeBits(self: *Self, value: anytype, bits: usize) Error!void {
3838 if (bits == 0) return;
3939
4040 const U = @TypeOf(value);
......@@ -145,7 +145,7 @@ pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type {
145145
146146pub fn bitWriter(
147147 comptime endian: builtin.Endian,
148 underlying_stream: var,
148 underlying_stream: anytype,
149149) BitWriter(endian, @TypeOf(underlying_stream)) {
150150 return BitWriter(endian, @TypeOf(underlying_stream)).init(underlying_stream);
151151}
lib/std/io/buffered_reader.zig+1-1
......@@ -48,7 +48,7 @@ pub fn BufferedReader(comptime buffer_size: usize, comptime ReaderType: type) ty
4848 };
4949}
5050
51pub fn bufferedReader(underlying_stream: var) BufferedReader(4096, @TypeOf(underlying_stream)) {
51pub fn bufferedReader(underlying_stream: anytype) BufferedReader(4096, @TypeOf(underlying_stream)) {
5252 return .{ .unbuffered_reader = underlying_stream };
5353}
5454
lib/std/io/buffered_writer.zig+1-1
......@@ -43,6 +43,6 @@ pub fn BufferedWriter(comptime buffer_size: usize, comptime WriterType: type) ty
4343 };
4444}
4545
46pub fn bufferedWriter(underlying_stream: var) BufferedWriter(4096, @TypeOf(underlying_stream)) {
46pub fn bufferedWriter(underlying_stream: anytype) BufferedWriter(4096, @TypeOf(underlying_stream)) {
4747 return .{ .unbuffered_writer = underlying_stream };
4848}
lib/std/io/counting_writer.zig+1-1
......@@ -32,7 +32,7 @@ pub fn CountingWriter(comptime WriterType: type) type {
3232 };
3333}
3434
35pub fn countingWriter(child_stream: var) CountingWriter(@TypeOf(child_stream)) {
35pub fn countingWriter(child_stream: anytype) CountingWriter(@TypeOf(child_stream)) {
3636 return .{ .bytes_written = 0, .child_stream = child_stream };
3737}
3838
lib/std/io/fixed_buffer_stream.zig+1-1
......@@ -127,7 +127,7 @@ pub fn FixedBufferStream(comptime Buffer: type) type {
127127 };
128128}
129129
130pub fn fixedBufferStream(buffer: var) FixedBufferStream(NonSentinelSpan(@TypeOf(buffer))) {
130pub fn fixedBufferStream(buffer: anytype) FixedBufferStream(NonSentinelSpan(@TypeOf(buffer))) {
131131 return .{ .buffer = mem.span(buffer), .pos = 0 };
132132}
133133
lib/std/io/multi_writer.zig+1-1
......@@ -43,7 +43,7 @@ pub fn MultiWriter(comptime Writers: type) type {
4343 };
4444}
4545
46pub fn multiWriter(streams: var) MultiWriter(@TypeOf(streams)) {
46pub fn multiWriter(streams: anytype) MultiWriter(@TypeOf(streams)) {
4747 return .{ .streams = streams };
4848}
4949
lib/std/io/peek_stream.zig+1-1
......@@ -80,7 +80,7 @@ pub fn PeekStream(
8080
8181pub fn peekStream(
8282 comptime lookahead: comptime_int,
83 underlying_stream: var,
83 underlying_stream: anytype,
8484) PeekStream(.{ .Static = lookahead }, @TypeOf(underlying_stream)) {
8585 return PeekStream(.{ .Static = lookahead }, @TypeOf(underlying_stream)).init(underlying_stream);
8686}
lib/std/io/serialization.zig+33-29
......@@ -16,14 +16,16 @@ pub const Packing = enum {
1616};
1717
1818/// Creates a deserializer that deserializes types from any stream.
19/// If `is_packed` is true, the data stream is treated as bit-packed,
20/// otherwise data is expected to be packed to the smallest byte.
21/// Types may implement a custom deserialization routine with a
22/// function named `deserialize` in the form of:
23/// pub fn deserialize(self: *Self, deserializer: var) !void
24/// which will be called when the deserializer is used to deserialize
25/// that type. It will pass a pointer to the type instance to deserialize
26/// into and a pointer to the deserializer struct.
19/// If `is_packed` is true, the data stream is treated as bit-packed,
20/// otherwise data is expected to be packed to the smallest byte.
21/// Types may implement a custom deserialization routine with a
22/// function named `deserialize` in the form of:
23/// ```
24/// pub fn deserialize(self: *Self, deserializer: anytype) !void
25/// ```
26/// which will be called when the deserializer is used to deserialize
27/// that type. It will pass a pointer to the type instance to deserialize
28/// into and a pointer to the deserializer struct.
2729pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing, comptime ReaderType: type) type {
2830 return struct {
2931 in_stream: if (packing == .Bit) io.BitReader(endian, ReaderType) else ReaderType,
......@@ -93,7 +95,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
9395 }
9496
9597 /// Deserializes data into the type pointed to by `ptr`
96 pub fn deserializeInto(self: *Self, ptr: var) !void {
98 pub fn deserializeInto(self: *Self, ptr: anytype) !void {
9799 const T = @TypeOf(ptr);
98100 comptime assert(trait.is(.Pointer)(T));
99101
......@@ -108,7 +110,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
108110 const C = comptime meta.Child(T);
109111 const child_type_id = @typeInfo(C);
110112
111 //custom deserializer: fn(self: *Self, deserializer: var) !void
113 //custom deserializer: fn(self: *Self, deserializer: anytype) !void
112114 if (comptime trait.hasFn("deserialize")(C)) return C.deserialize(ptr, self);
113115
114116 if (comptime trait.isPacked(C) and packing != .Bit) {
......@@ -190,24 +192,26 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
190192pub fn deserializer(
191193 comptime endian: builtin.Endian,
192194 comptime packing: Packing,
193 in_stream: var,
195 in_stream: anytype,
194196) Deserializer(endian, packing, @TypeOf(in_stream)) {
195197 return Deserializer(endian, packing, @TypeOf(in_stream)).init(in_stream);
196198}
197199
198200/// Creates a serializer that serializes types to any stream.
199/// If `is_packed` is true, the data will be bit-packed into the stream.
200/// Note that the you must call `serializer.flush()` when you are done
201/// writing bit-packed data in order ensure any unwritten bits are committed.
202/// If `is_packed` is false, data is packed to the smallest byte. In the case
203/// of packed structs, the struct will written bit-packed and with the specified
204/// endianess, after which data will resume being written at the next byte boundary.
205/// Types may implement a custom serialization routine with a
206/// function named `serialize` in the form of:
207/// pub fn serialize(self: Self, serializer: var) !void
208/// which will be called when the serializer is used to serialize that type. It will
209/// pass a const pointer to the type instance to be serialized and a pointer
210/// to the serializer struct.
201/// If `is_packed` is true, the data will be bit-packed into the stream.
202/// Note that the you must call `serializer.flush()` when you are done
203/// writing bit-packed data in order ensure any unwritten bits are committed.
204/// If `is_packed` is false, data is packed to the smallest byte. In the case
205/// of packed structs, the struct will written bit-packed and with the specified
206/// endianess, after which data will resume being written at the next byte boundary.
207/// Types may implement a custom serialization routine with a
208/// function named `serialize` in the form of:
209/// ```
210/// pub fn serialize(self: Self, serializer: anytype) !void
211/// ```
212/// which will be called when the serializer is used to serialize that type. It will
213/// pass a const pointer to the type instance to be serialized and a pointer
214/// to the serializer struct.
211215pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, comptime OutStreamType: type) type {
212216 return struct {
213217 out_stream: if (packing == .Bit) io.BitOutStream(endian, OutStreamType) else OutStreamType,
......@@ -229,7 +233,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
229233 if (packing == .Bit) return self.out_stream.flushBits();
230234 }
231235
232 fn serializeInt(self: *Self, value: var) Error!void {
236 fn serializeInt(self: *Self, value: anytype) Error!void {
233237 const T = @TypeOf(value);
234238 comptime assert(trait.is(.Int)(T) or trait.is(.Float)(T));
235239
......@@ -261,7 +265,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
261265 }
262266
263267 /// Serializes the passed value into the stream
264 pub fn serialize(self: *Self, value: var) Error!void {
268 pub fn serialize(self: *Self, value: anytype) Error!void {
265269 const T = comptime @TypeOf(value);
266270
267271 if (comptime trait.isIndexable(T)) {
......@@ -270,7 +274,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
270274 return;
271275 }
272276
273 //custom serializer: fn(self: Self, serializer: var) !void
277 //custom serializer: fn(self: Self, serializer: anytype) !void
274278 if (comptime trait.hasFn("serialize")(T)) return T.serialize(value, self);
275279
276280 if (comptime trait.isPacked(T) and packing != .Bit) {
......@@ -346,7 +350,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
346350pub fn serializer(
347351 comptime endian: builtin.Endian,
348352 comptime packing: Packing,
349 out_stream: var,
353 out_stream: anytype,
350354) Serializer(endian, packing, @TypeOf(out_stream)) {
351355 return Serializer(endian, packing, @TypeOf(out_stream)).init(out_stream);
352356}
......@@ -462,7 +466,7 @@ test "Serializer/Deserializer Int: Inf/NaN" {
462466 try testIntSerializerDeserializerInfNaN(.Little, .Bit);
463467}
464468
465fn testAlternateSerializer(self: var, _serializer: var) !void {
469fn testAlternateSerializer(self: anytype, _serializer: anytype) !void {
466470 try _serializer.serialize(self.f_f16);
467471}
468472
......@@ -503,7 +507,7 @@ fn testSerializerDeserializer(comptime endian: builtin.Endian, comptime packing:
503507 f_f16: f16,
504508 f_unused_u32: u32,
505509
506 pub fn deserialize(self: *@This(), _deserializer: var) !void {
510 pub fn deserialize(self: *@This(), _deserializer: anytype) !void {
507511 try _deserializer.deserializeInto(&self.f_f16);
508512 self.f_unused_u32 = 47;
509513 }
lib/std/io/writer.zig+1-1
......@@ -24,7 +24,7 @@ pub fn Writer(
2424 }
2525 }
2626
27 pub fn print(self: Self, comptime format: []const u8, args: var) Error!void {
27 pub fn print(self: Self, comptime format: []const u8, args: anytype) Error!void {
2828 return std.fmt.format(self, format, args);
2929 }
3030
lib/std/json.zig+8-8
......@@ -239,7 +239,7 @@ pub const StreamingParser = struct {
239239 NullLiteral3,
240240
241241 // Only call this function to generate array/object final state.
242 pub fn fromInt(x: var) State {
242 pub fn fromInt(x: anytype) State {
243243 debug.assert(x == 0 or x == 1);
244244 const T = @TagType(State);
245245 return @intToEnum(State, @intCast(T, x));
......@@ -1236,7 +1236,7 @@ pub const Value = union(enum) {
12361236 pub fn jsonStringify(
12371237 value: @This(),
12381238 options: StringifyOptions,
1239 out_stream: var,
1239 out_stream: anytype,
12401240 ) @TypeOf(out_stream).Error!void {
12411241 switch (value) {
12421242 .Null => try stringify(null, options, out_stream),
......@@ -2338,7 +2338,7 @@ pub const StringifyOptions = struct {
23382338
23392339 pub fn outputIndent(
23402340 whitespace: @This(),
2341 out_stream: var,
2341 out_stream: anytype,
23422342 ) @TypeOf(out_stream).Error!void {
23432343 var char: u8 = undefined;
23442344 var n_chars: usize = undefined;
......@@ -2380,7 +2380,7 @@ pub const StringifyOptions = struct {
23802380
23812381fn outputUnicodeEscape(
23822382 codepoint: u21,
2383 out_stream: var,
2383 out_stream: anytype,
23842384) !void {
23852385 if (codepoint <= 0xFFFF) {
23862386 // If the character is in the Basic Multilingual Plane (U+0000 through U+FFFF),
......@@ -2402,9 +2402,9 @@ fn outputUnicodeEscape(
24022402}
24032403
24042404pub fn stringify(
2405 value: var,
2405 value: anytype,
24062406 options: StringifyOptions,
2407 out_stream: var,
2407 out_stream: anytype,
24082408) @TypeOf(out_stream).Error!void {
24092409 const T = @TypeOf(value);
24102410 switch (@typeInfo(T)) {
......@@ -2584,7 +2584,7 @@ pub fn stringify(
25842584 unreachable;
25852585}
25862586
2587fn teststringify(expected: []const u8, value: var, options: StringifyOptions) !void {
2587fn teststringify(expected: []const u8, value: anytype, options: StringifyOptions) !void {
25882588 const ValidationOutStream = struct {
25892589 const Self = @This();
25902590 pub const OutStream = std.io.OutStream(*Self, Error, write);
......@@ -2758,7 +2758,7 @@ test "stringify struct with custom stringifier" {
27582758 pub fn jsonStringify(
27592759 value: Self,
27602760 options: StringifyOptions,
2761 out_stream: var,
2761 out_stream: anytype,
27622762 ) !void {
27632763 try out_stream.writeAll("[\"something special\",");
27642764 try stringify(42, options, out_stream);
lib/std/json/write_stream.zig+3-3
......@@ -152,7 +152,7 @@ pub fn WriteStream(comptime OutStream: type, comptime max_depth: usize) type {
152152 self: *Self,
153153 /// An integer, float, or `std.math.BigInt`. Emitted as a bare number if it fits losslessly
154154 /// in a IEEE 754 double float, otherwise emitted as a string to the full precision.
155 value: var,
155 value: anytype,
156156 ) !void {
157157 assert(self.state[self.state_index] == State.Value);
158158 switch (@typeInfo(@TypeOf(value))) {
......@@ -215,7 +215,7 @@ pub fn WriteStream(comptime OutStream: type, comptime max_depth: usize) type {
215215 self.state_index -= 1;
216216 }
217217
218 fn stringify(self: *Self, value: var) !void {
218 fn stringify(self: *Self, value: anytype) !void {
219219 try std.json.stringify(value, std.json.StringifyOptions{
220220 .whitespace = self.whitespace,
221221 }, self.stream);
......@@ -224,7 +224,7 @@ pub fn WriteStream(comptime OutStream: type, comptime max_depth: usize) type {
224224}
225225
226226pub fn writeStream(
227 out_stream: var,
227 out_stream: anytype,
228228 comptime max_depth: usize,
229229) WriteStream(@TypeOf(out_stream), max_depth) {
230230 return WriteStream(@TypeOf(out_stream), max_depth).init(out_stream);
lib/std/log.zig+10-10
......@@ -22,7 +22,7 @@ const root = @import("root");
2222//! comptime level: std.log.Level,
2323//! comptime scope: @TypeOf(.EnumLiteral),
2424//! comptime format: []const u8,
25//! args: var,
25//! args: anytype,
2626//! ) void {
2727//! // Ignore all non-critical logging from sources other than
2828//! // .my_project and .nice_library
......@@ -101,7 +101,7 @@ fn log(
101101 comptime message_level: Level,
102102 comptime scope: @Type(.EnumLiteral),
103103 comptime format: []const u8,
104 args: var,
104 args: anytype,
105105) void {
106106 if (@enumToInt(message_level) <= @enumToInt(level)) {
107107 if (@hasDecl(root, "log")) {
......@@ -120,7 +120,7 @@ fn log(
120120pub fn emerg(
121121 comptime scope: @Type(.EnumLiteral),
122122 comptime format: []const u8,
123 args: var,
123 args: anytype,
124124) void {
125125 @setCold(true);
126126 log(.emerg, scope, format, args);
......@@ -131,7 +131,7 @@ pub fn emerg(
131131pub fn alert(
132132 comptime scope: @Type(.EnumLiteral),
133133 comptime format: []const u8,
134 args: var,
134 args: anytype,
135135) void {
136136 @setCold(true);
137137 log(.alert, scope, format, args);
......@@ -143,7 +143,7 @@ pub fn alert(
143143pub fn crit(
144144 comptime scope: @Type(.EnumLiteral),
145145 comptime format: []const u8,
146 args: var,
146 args: anytype,
147147) void {
148148 @setCold(true);
149149 log(.crit, scope, format, args);
......@@ -154,7 +154,7 @@ pub fn crit(
154154pub fn err(
155155 comptime scope: @Type(.EnumLiteral),
156156 comptime format: []const u8,
157 args: var,
157 args: anytype,
158158) void {
159159 @setCold(true);
160160 log(.err, scope, format, args);
......@@ -166,7 +166,7 @@ pub fn err(
166166pub fn warn(
167167 comptime scope: @Type(.EnumLiteral),
168168 comptime format: []const u8,
169 args: var,
169 args: anytype,
170170) void {
171171 log(.warn, scope, format, args);
172172}
......@@ -176,7 +176,7 @@ pub fn warn(
176176pub fn notice(
177177 comptime scope: @Type(.EnumLiteral),
178178 comptime format: []const u8,
179 args: var,
179 args: anytype,
180180) void {
181181 log(.notice, scope, format, args);
182182}
......@@ -186,7 +186,7 @@ pub fn notice(
186186pub fn info(
187187 comptime scope: @Type(.EnumLiteral),
188188 comptime format: []const u8,
189 args: var,
189 args: anytype,
190190) void {
191191 log(.info, scope, format, args);
192192}
......@@ -196,7 +196,7 @@ pub fn info(
196196pub fn debug(
197197 comptime scope: @Type(.EnumLiteral),
198198 comptime format: []const u8,
199 args: var,
199 args: anytype,
200200) void {
201201 log(.debug, scope, format, args);
202202}
lib/std/math.zig+18-18
......@@ -104,7 +104,7 @@ pub fn approxEq(comptime T: type, x: T, y: T, epsilon: T) bool {
104104}
105105
106106// TODO: Hide the following in an internal module.
107pub fn forceEval(value: var) void {
107pub fn forceEval(value: anytype) void {
108108 const T = @TypeOf(value);
109109 switch (T) {
110110 f16 => {
......@@ -259,7 +259,7 @@ pub fn Min(comptime A: type, comptime B: type) type {
259259
260260/// Returns the smaller number. When one of the parameter's type's full range fits in the other,
261261/// the return type is the smaller type.
262pub fn min(x: var, y: var) Min(@TypeOf(x), @TypeOf(y)) {
262pub fn min(x: anytype, y: anytype) Min(@TypeOf(x), @TypeOf(y)) {
263263 const Result = Min(@TypeOf(x), @TypeOf(y));
264264 if (x < y) {
265265 // TODO Zig should allow this as an implicit cast because x is immutable and in this
......@@ -310,7 +310,7 @@ test "math.min" {
310310 }
311311}
312312
313pub fn max(x: var, y: var) @TypeOf(x, y) {
313pub fn max(x: anytype, y: anytype) @TypeOf(x, y) {
314314 return if (x > y) x else y;
315315}
316316
......@@ -318,7 +318,7 @@ test "math.max" {
318318 testing.expect(max(@as(i32, -1), @as(i32, 2)) == 2);
319319}
320320
321pub fn clamp(val: var, lower: var, upper: var) @TypeOf(val, lower, upper) {
321pub fn clamp(val: anytype, lower: anytype, upper: anytype) @TypeOf(val, lower, upper) {
322322 assert(lower <= upper);
323323 return max(lower, min(val, upper));
324324}
......@@ -354,7 +354,7 @@ pub fn sub(comptime T: type, a: T, b: T) (error{Overflow}!T) {
354354 return if (@subWithOverflow(T, a, b, &answer)) error.Overflow else answer;
355355}
356356
357pub fn negate(x: var) !@TypeOf(x) {
357pub fn negate(x: anytype) !@TypeOf(x) {
358358 return sub(@TypeOf(x), 0, x);
359359}
360360
......@@ -365,7 +365,7 @@ pub fn shlExact(comptime T: type, a: T, shift_amt: Log2Int(T)) !T {
365365
366366/// Shifts left. Overflowed bits are truncated.
367367/// A negative shift amount results in a right shift.
368pub fn shl(comptime T: type, a: T, shift_amt: var) T {
368pub fn shl(comptime T: type, a: T, shift_amt: anytype) T {
369369 const abs_shift_amt = absCast(shift_amt);
370370 const casted_shift_amt = if (abs_shift_amt >= T.bit_count) return 0 else @intCast(Log2Int(T), abs_shift_amt);
371371
......@@ -391,7 +391,7 @@ test "math.shl" {
391391
392392/// Shifts right. Overflowed bits are truncated.
393393/// A negative shift amount results in a left shift.
394pub fn shr(comptime T: type, a: T, shift_amt: var) T {
394pub fn shr(comptime T: type, a: T, shift_amt: anytype) T {
395395 const abs_shift_amt = absCast(shift_amt);
396396 const casted_shift_amt = if (abs_shift_amt >= T.bit_count) return 0 else @intCast(Log2Int(T), abs_shift_amt);
397397
......@@ -419,7 +419,7 @@ test "math.shr" {
419419
420420/// Rotates right. Only unsigned values can be rotated.
421421/// Negative shift values results in shift modulo the bit count.
422pub fn rotr(comptime T: type, x: T, r: var) T {
422pub fn rotr(comptime T: type, x: T, r: anytype) T {
423423 if (T.is_signed) {
424424 @compileError("cannot rotate signed integer");
425425 } else {
......@@ -438,7 +438,7 @@ test "math.rotr" {
438438
439439/// Rotates left. Only unsigned values can be rotated.
440440/// Negative shift values results in shift modulo the bit count.
441pub fn rotl(comptime T: type, x: T, r: var) T {
441pub fn rotl(comptime T: type, x: T, r: anytype) T {
442442 if (T.is_signed) {
443443 @compileError("cannot rotate signed integer");
444444 } else {
......@@ -541,7 +541,7 @@ fn testOverflow() void {
541541 testing.expect((shlExact(i32, 0b11, 4) catch unreachable) == 0b110000);
542542}
543543
544pub fn absInt(x: var) !@TypeOf(x) {
544pub fn absInt(x: anytype) !@TypeOf(x) {
545545 const T = @TypeOf(x);
546546 comptime assert(@typeInfo(T) == .Int); // must pass an integer to absInt
547547 comptime assert(T.is_signed); // must pass a signed integer to absInt
......@@ -689,7 +689,7 @@ fn testRem() void {
689689
690690/// Returns the absolute value of the integer parameter.
691691/// Result is an unsigned integer.
692pub fn absCast(x: var) switch (@typeInfo(@TypeOf(x))) {
692pub fn absCast(x: anytype) switch (@typeInfo(@TypeOf(x))) {
693693 .ComptimeInt => comptime_int,
694694 .Int => |intInfo| std.meta.Int(false, intInfo.bits),
695695 else => @compileError("absCast only accepts integers"),
......@@ -724,7 +724,7 @@ test "math.absCast" {
724724
725725/// Returns the negation of the integer parameter.
726726/// Result is a signed integer.
727pub fn negateCast(x: var) !std.meta.Int(true, @TypeOf(x).bit_count) {
727pub fn negateCast(x: anytype) !std.meta.Int(true, @TypeOf(x).bit_count) {
728728 if (@TypeOf(x).is_signed) return negate(x);
729729
730730 const int = std.meta.Int(true, @TypeOf(x).bit_count);
......@@ -747,7 +747,7 @@ test "math.negateCast" {
747747
748748/// Cast an integer to a different integer type. If the value doesn't fit,
749749/// return an error.
750pub fn cast(comptime T: type, x: var) (error{Overflow}!T) {
750pub fn cast(comptime T: type, x: anytype) (error{Overflow}!T) {
751751 comptime assert(@typeInfo(T) == .Int); // must pass an integer
752752 comptime assert(@typeInfo(@TypeOf(x)) == .Int); // must pass an integer
753753 if (maxInt(@TypeOf(x)) > maxInt(T) and x > maxInt(T)) {
......@@ -772,7 +772,7 @@ test "math.cast" {
772772pub const AlignCastError = error{UnalignedMemory};
773773
774774/// Align cast a pointer but return an error if it's the wrong alignment
775pub fn alignCast(comptime alignment: u29, ptr: var) AlignCastError!@TypeOf(@alignCast(alignment, ptr)) {
775pub fn alignCast(comptime alignment: u29, ptr: anytype) AlignCastError!@TypeOf(@alignCast(alignment, ptr)) {
776776 const addr = @ptrToInt(ptr);
777777 if (addr % alignment != 0) {
778778 return error.UnalignedMemory;
......@@ -780,7 +780,7 @@ pub fn alignCast(comptime alignment: u29, ptr: var) AlignCastError!@TypeOf(@alig
780780 return @alignCast(alignment, ptr);
781781}
782782
783pub fn isPowerOfTwo(v: var) bool {
783pub fn isPowerOfTwo(v: anytype) bool {
784784 assert(v != 0);
785785 return (v & (v - 1)) == 0;
786786}
......@@ -897,7 +897,7 @@ test "std.math.log2_int_ceil" {
897897 testing.expect(log2_int_ceil(u32, 10) == 4);
898898}
899899
900pub fn lossyCast(comptime T: type, value: var) T {
900pub fn lossyCast(comptime T: type, value: anytype) T {
901901 switch (@typeInfo(@TypeOf(value))) {
902902 .Int => return @intToFloat(T, value),
903903 .Float => return @floatCast(T, value),
......@@ -1031,7 +1031,7 @@ pub const Order = enum {
10311031};
10321032
10331033/// Given two numbers, this function returns the order they are with respect to each other.
1034pub fn order(a: var, b: var) Order {
1034pub fn order(a: anytype, b: anytype) Order {
10351035 if (a == b) {
10361036 return .eq;
10371037 } else if (a < b) {
......@@ -1062,7 +1062,7 @@ pub const CompareOperator = enum {
10621062/// This function does the same thing as comparison operators, however the
10631063/// operator is a runtime-known enum value. Works on any operands that
10641064/// support comparison operators.
1065pub fn compare(a: var, op: CompareOperator, b: var) bool {
1065pub fn compare(a: anytype, op: CompareOperator, b: anytype) bool {
10661066 return switch (op) {
10671067 .lt => a < b,
10681068 .lte => a <= b,
lib/std/math/acos.zig+1-1
......@@ -12,7 +12,7 @@ const expect = std.testing.expect;
1212///
1313/// Special cases:
1414/// - acos(x) = nan if x < -1 or x > 1
15pub fn acos(x: var) @TypeOf(x) {
15pub fn acos(x: anytype) @TypeOf(x) {
1616 const T = @TypeOf(x);
1717 return switch (T) {
1818 f32 => acos32(x),
lib/std/math/acosh.zig+1-1
......@@ -14,7 +14,7 @@ const expect = std.testing.expect;
1414/// Special cases:
1515/// - acosh(x) = snan if x < 1
1616/// - acosh(nan) = nan
17pub fn acosh(x: var) @TypeOf(x) {
17pub fn acosh(x: anytype) @TypeOf(x) {
1818 const T = @TypeOf(x);
1919 return switch (T) {
2020 f32 => acosh32(x),
lib/std/math/asin.zig+1-1
......@@ -13,7 +13,7 @@ const expect = std.testing.expect;
1313/// Special Cases:
1414/// - asin(+-0) = +-0
1515/// - asin(x) = nan if x < -1 or x > 1
16pub fn asin(x: var) @TypeOf(x) {
16pub fn asin(x: anytype) @TypeOf(x) {
1717 const T = @TypeOf(x);
1818 return switch (T) {
1919 f32 => asin32(x),
lib/std/math/asinh.zig+1-1
......@@ -15,7 +15,7 @@ const maxInt = std.math.maxInt;
1515/// - asinh(+-0) = +-0
1616/// - asinh(+-inf) = +-inf
1717/// - asinh(nan) = nan
18pub fn asinh(x: var) @TypeOf(x) {
18pub fn asinh(x: anytype) @TypeOf(x) {
1919 const T = @TypeOf(x);
2020 return switch (T) {
2121 f32 => asinh32(x),
lib/std/math/atan.zig+1-1
......@@ -13,7 +13,7 @@ const expect = std.testing.expect;
1313/// Special Cases:
1414/// - atan(+-0) = +-0
1515/// - atan(+-inf) = +-pi/2
16pub fn atan(x: var) @TypeOf(x) {
16pub fn atan(x: anytype) @TypeOf(x) {
1717 const T = @TypeOf(x);
1818 return switch (T) {
1919 f32 => atan32(x),
lib/std/math/atanh.zig+1-1
......@@ -15,7 +15,7 @@ const maxInt = std.math.maxInt;
1515/// - atanh(+-1) = +-inf with signal
1616/// - atanh(x) = nan if |x| > 1 with signal
1717/// - atanh(nan) = nan
18pub fn atanh(x: var) @TypeOf(x) {
18pub fn atanh(x: anytype) @TypeOf(x) {
1919 const T = @TypeOf(x);
2020 return switch (T) {
2121 f32 => atanh_32(x),
lib/std/math/big/int.zig+10-10
......@@ -12,7 +12,7 @@ const assert = std.debug.assert;
1212
1313/// Returns the number of limbs needed to store `scalar`, which must be a
1414/// primitive integer value.
15pub fn calcLimbLen(scalar: var) usize {
15pub fn calcLimbLen(scalar: anytype) usize {
1616 const T = @TypeOf(scalar);
1717 switch (@typeInfo(T)) {
1818 .Int => |info| {
......@@ -110,7 +110,7 @@ pub const Mutable = struct {
110110 /// `value` is a primitive integer type.
111111 /// Asserts the value fits within the provided `limbs_buffer`.
112112 /// Note: `calcLimbLen` can be used to figure out how big an array to allocate for `limbs_buffer`.
113 pub fn init(limbs_buffer: []Limb, value: var) Mutable {
113 pub fn init(limbs_buffer: []Limb, value: anytype) Mutable {
114114 limbs_buffer[0] = 0;
115115 var self: Mutable = .{
116116 .limbs = limbs_buffer,
......@@ -169,7 +169,7 @@ pub const Mutable = struct {
169169 /// Asserts the value fits within the limbs buffer.
170170 /// Note: `calcLimbLen` can be used to figure out how big the limbs buffer
171171 /// needs to be to store a specific value.
172 pub fn set(self: *Mutable, value: var) void {
172 pub fn set(self: *Mutable, value: anytype) void {
173173 const T = @TypeOf(value);
174174
175175 switch (@typeInfo(T)) {
......@@ -281,7 +281,7 @@ pub const Mutable = struct {
281281 ///
282282 /// Asserts the result fits in `r`. An upper bound on the number of limbs needed by
283283 /// r is `math.max(a.limbs.len, calcLimbLen(scalar)) + 1`.
284 pub fn addScalar(r: *Mutable, a: Const, scalar: var) void {
284 pub fn addScalar(r: *Mutable, a: Const, scalar: anytype) void {
285285 var limbs: [calcLimbLen(scalar)]Limb = undefined;
286286 const operand = init(&limbs, scalar).toConst();
287287 return add(r, a, operand);
......@@ -1058,7 +1058,7 @@ pub const Const = struct {
10581058 self: Const,
10591059 comptime fmt: []const u8,
10601060 options: std.fmt.FormatOptions,
1061 out_stream: var,
1061 out_stream: anytype,
10621062 ) !void {
10631063 comptime var radix = 10;
10641064 comptime var uppercase = false;
......@@ -1261,7 +1261,7 @@ pub const Const = struct {
12611261 }
12621262
12631263 /// Same as `order` but the right-hand operand is a primitive integer.
1264 pub fn orderAgainstScalar(lhs: Const, scalar: var) math.Order {
1264 pub fn orderAgainstScalar(lhs: Const, scalar: anytype) math.Order {
12651265 var limbs: [calcLimbLen(scalar)]Limb = undefined;
12661266 const rhs = Mutable.init(&limbs, scalar);
12671267 return order(lhs, rhs.toConst());
......@@ -1333,7 +1333,7 @@ pub const Managed = struct {
13331333 /// Creates a new `Managed` with value `value`.
13341334 ///
13351335 /// This is identical to an `init`, followed by a `set`.
1336 pub fn initSet(allocator: *Allocator, value: var) !Managed {
1336 pub fn initSet(allocator: *Allocator, value: anytype) !Managed {
13371337 var s = try Managed.init(allocator);
13381338 try s.set(value);
13391339 return s;
......@@ -1496,7 +1496,7 @@ pub const Managed = struct {
14961496 }
14971497
14981498 /// Sets an Managed to value. Value must be an primitive integer type.
1499 pub fn set(self: *Managed, value: var) Allocator.Error!void {
1499 pub fn set(self: *Managed, value: anytype) Allocator.Error!void {
15001500 try self.ensureCapacity(calcLimbLen(value));
15011501 var m = self.toMutable();
15021502 m.set(value);
......@@ -1549,7 +1549,7 @@ pub const Managed = struct {
15491549 self: Managed,
15501550 comptime fmt: []const u8,
15511551 options: std.fmt.FormatOptions,
1552 out_stream: var,
1552 out_stream: anytype,
15531553 ) !void {
15541554 return self.toConst().format(fmt, options, out_stream);
15551555 }
......@@ -1607,7 +1607,7 @@ pub const Managed = struct {
16071607 /// scalar is a primitive integer type.
16081608 ///
16091609 /// Returns an error if memory could not be allocated.
1610 pub fn addScalar(r: *Managed, a: Const, scalar: var) Allocator.Error!void {
1610 pub fn addScalar(r: *Managed, a: Const, scalar: anytype) Allocator.Error!void {
16111611 try r.ensureCapacity(math.max(a.limbs.len, calcLimbLen(scalar)) + 1);
16121612 var m = r.toMutable();
16131613 m.addScalar(a, scalar);
lib/std/math/big/rational.zig+2-2
......@@ -43,7 +43,7 @@ pub const Rational = struct {
4343 }
4444
4545 /// Set a Rational from a primitive integer type.
46 pub fn setInt(self: *Rational, a: var) !void {
46 pub fn setInt(self: *Rational, a: anytype) !void {
4747 try self.p.set(a);
4848 try self.q.set(1);
4949 }
......@@ -280,7 +280,7 @@ pub const Rational = struct {
280280 }
281281
282282 /// Set a rational from an integer ratio.
283 pub fn setRatio(self: *Rational, p: var, q: var) !void {
283 pub fn setRatio(self: *Rational, p: anytype, q: anytype) !void {
284284 try self.p.set(p);
285285 try self.q.set(q);
286286
lib/std/math/cbrt.zig+1-1
......@@ -14,7 +14,7 @@ const expect = std.testing.expect;
1414/// - cbrt(+-0) = +-0
1515/// - cbrt(+-inf) = +-inf
1616/// - cbrt(nan) = nan
17pub fn cbrt(x: var) @TypeOf(x) {
17pub fn cbrt(x: anytype) @TypeOf(x) {
1818 const T = @TypeOf(x);
1919 return switch (T) {
2020 f32 => cbrt32(x),
lib/std/math/ceil.zig+1-1
......@@ -15,7 +15,7 @@ const expect = std.testing.expect;
1515/// - ceil(+-0) = +-0
1616/// - ceil(+-inf) = +-inf
1717/// - ceil(nan) = nan
18pub fn ceil(x: var) @TypeOf(x) {
18pub fn ceil(x: anytype) @TypeOf(x) {
1919 const T = @TypeOf(x);
2020 return switch (T) {
2121 f32 => ceil32(x),
lib/std/math/complex/abs.zig+1-1
......@@ -5,7 +5,7 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77/// Returns the absolute value (modulus) of z.
8pub fn abs(z: var) @TypeOf(z.re) {
8pub fn abs(z: anytype) @TypeOf(z.re) {
99 const T = @TypeOf(z.re);
1010 return math.hypot(T, z.re, z.im);
1111}
lib/std/math/complex/acos.zig+1-1
......@@ -5,7 +5,7 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77/// Returns the arc-cosine of z.
8pub fn acos(z: var) Complex(@TypeOf(z.re)) {
8pub fn acos(z: anytype) Complex(@TypeOf(z.re)) {
99 const T = @TypeOf(z.re);
1010 const q = cmath.asin(z);
1111 return Complex(T).new(@as(T, math.pi) / 2 - q.re, -q.im);
lib/std/math/complex/acosh.zig+1-1
......@@ -5,7 +5,7 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77/// Returns the hyperbolic arc-cosine of z.
8pub fn acosh(z: var) Complex(@TypeOf(z.re)) {
8pub fn acosh(z: anytype) Complex(@TypeOf(z.re)) {
99 const T = @TypeOf(z.re);
1010 const q = cmath.acos(z);
1111 return Complex(T).new(-q.im, q.re);
lib/std/math/complex/arg.zig+1-1
......@@ -5,7 +5,7 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77/// Returns the angular component (in radians) of z.
8pub fn arg(z: var) @TypeOf(z.re) {
8pub fn arg(z: anytype) @TypeOf(z.re) {
99 const T = @TypeOf(z.re);
1010 return math.atan2(T, z.im, z.re);
1111}
lib/std/math/complex/asin.zig+1-1
......@@ -5,7 +5,7 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77// Returns the arc-sine of z.
8pub fn asin(z: var) Complex(@TypeOf(z.re)) {
8pub fn asin(z: anytype) Complex(@TypeOf(z.re)) {
99 const T = @TypeOf(z.re);
1010 const x = z.re;
1111 const y = z.im;
lib/std/math/complex/asinh.zig+1-1
......@@ -5,7 +5,7 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77/// Returns the hyperbolic arc-sine of z.
8pub fn asinh(z: var) Complex(@TypeOf(z.re)) {
8pub fn asinh(z: anytype) Complex(@TypeOf(z.re)) {
99 const T = @TypeOf(z.re);
1010 const q = Complex(T).new(-z.im, z.re);
1111 const r = cmath.asin(q);
lib/std/math/complex/atan.zig+1-1
......@@ -12,7 +12,7 @@ const cmath = math.complex;
1212const Complex = cmath.Complex;
1313
1414/// Returns the arc-tangent of z.
15pub fn atan(z: var) @TypeOf(z) {
15pub fn atan(z: anytype) @TypeOf(z) {
1616 const T = @TypeOf(z.re);
1717 return switch (T) {
1818 f32 => atan32(z),
lib/std/math/complex/atanh.zig+1-1
......@@ -5,7 +5,7 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77/// Returns the hyperbolic arc-tangent of z.
8pub fn atanh(z: var) Complex(@TypeOf(z.re)) {
8pub fn atanh(z: anytype) Complex(@TypeOf(z.re)) {
99 const T = @TypeOf(z.re);
1010 const q = Complex(T).new(-z.im, z.re);
1111 const r = cmath.atan(q);
lib/std/math/complex/conj.zig+1-1
......@@ -5,7 +5,7 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77/// Returns the complex conjugate of z.
8pub fn conj(z: var) Complex(@TypeOf(z.re)) {
8pub fn conj(z: anytype) Complex(@TypeOf(z.re)) {
99 const T = @TypeOf(z.re);
1010 return Complex(T).new(z.re, -z.im);
1111}
lib/std/math/complex/cos.zig+1-1
......@@ -5,7 +5,7 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77/// Returns the cosine of z.
8pub fn cos(z: var) Complex(@TypeOf(z.re)) {
8pub fn cos(z: anytype) Complex(@TypeOf(z.re)) {
99 const T = @TypeOf(z.re);
1010 const p = Complex(T).new(-z.im, z.re);
1111 return cmath.cosh(p);
lib/std/math/complex/cosh.zig+1-1
......@@ -14,7 +14,7 @@ const Complex = cmath.Complex;
1414const ldexp_cexp = @import("ldexp.zig").ldexp_cexp;
1515
1616/// Returns the hyperbolic arc-cosine of z.
17pub fn cosh(z: var) Complex(@TypeOf(z.re)) {
17pub fn cosh(z: anytype) Complex(@TypeOf(z.re)) {
1818 const T = @TypeOf(z.re);
1919 return switch (T) {
2020 f32 => cosh32(z),
lib/std/math/complex/exp.zig+1-1
......@@ -14,7 +14,7 @@ const Complex = cmath.Complex;
1414const ldexp_cexp = @import("ldexp.zig").ldexp_cexp;
1515
1616/// Returns e raised to the power of z (e^z).
17pub fn exp(z: var) @TypeOf(z) {
17pub fn exp(z: anytype) @TypeOf(z) {
1818 const T = @TypeOf(z.re);
1919
2020 return switch (T) {
lib/std/math/complex/ldexp.zig+1-1
......@@ -11,7 +11,7 @@ const cmath = math.complex;
1111const Complex = cmath.Complex;
1212
1313/// Returns exp(z) scaled to avoid overflow.
14pub fn ldexp_cexp(z: var, expt: i32) @TypeOf(z) {
14pub fn ldexp_cexp(z: anytype, expt: i32) @TypeOf(z) {
1515 const T = @TypeOf(z.re);
1616
1717 return switch (T) {
lib/std/math/complex/log.zig+1-1
......@@ -5,7 +5,7 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77/// Returns the natural logarithm of z.
8pub fn log(z: var) Complex(@TypeOf(z.re)) {
8pub fn log(z: anytype) Complex(@TypeOf(z.re)) {
99 const T = @TypeOf(z.re);
1010 const r = cmath.abs(z);
1111 const phi = cmath.arg(z);
lib/std/math/complex/proj.zig+1-1
......@@ -5,7 +5,7 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77/// Returns the projection of z onto the riemann sphere.
8pub fn proj(z: var) Complex(@TypeOf(z.re)) {
8pub fn proj(z: anytype) Complex(@TypeOf(z.re)) {
99 const T = @TypeOf(z.re);
1010
1111 if (math.isInf(z.re) or math.isInf(z.im)) {
lib/std/math/complex/sin.zig+1-1
......@@ -5,7 +5,7 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77/// Returns the sine of z.
8pub fn sin(z: var) Complex(@TypeOf(z.re)) {
8pub fn sin(z: anytype) Complex(@TypeOf(z.re)) {
99 const T = @TypeOf(z.re);
1010 const p = Complex(T).new(-z.im, z.re);
1111 const q = cmath.sinh(p);
lib/std/math/complex/sinh.zig+1-1
......@@ -14,7 +14,7 @@ const Complex = cmath.Complex;
1414const ldexp_cexp = @import("ldexp.zig").ldexp_cexp;
1515
1616/// Returns the hyperbolic sine of z.
17pub fn sinh(z: var) @TypeOf(z) {
17pub fn sinh(z: anytype) @TypeOf(z) {
1818 const T = @TypeOf(z.re);
1919 return switch (T) {
2020 f32 => sinh32(z),
lib/std/math/complex/sqrt.zig+1-1
......@@ -12,7 +12,7 @@ const Complex = cmath.Complex;
1212
1313/// Returns the square root of z. The real and imaginary parts of the result have the same sign
1414/// as the imaginary part of z.
15pub fn sqrt(z: var) @TypeOf(z) {
15pub fn sqrt(z: anytype) @TypeOf(z) {
1616 const T = @TypeOf(z.re);
1717
1818 return switch (T) {
lib/std/math/complex/tan.zig+1-1
......@@ -5,7 +5,7 @@ const cmath = math.complex;
55const Complex = cmath.Complex;
66
77/// Returns the tanget of z.
8pub fn tan(z: var) Complex(@TypeOf(z.re)) {
8pub fn tan(z: anytype) Complex(@TypeOf(z.re)) {
99 const T = @TypeOf(z.re);
1010 const q = Complex(T).new(-z.im, z.re);
1111 const r = cmath.tanh(q);
lib/std/math/complex/tanh.zig+1-1
......@@ -12,7 +12,7 @@ const cmath = math.complex;
1212const Complex = cmath.Complex;
1313
1414/// Returns the hyperbolic tangent of z.
15pub fn tanh(z: var) @TypeOf(z) {
15pub fn tanh(z: anytype) @TypeOf(z) {
1616 const T = @TypeOf(z.re);
1717 return switch (T) {
1818 f32 => tanh32(z),
lib/std/math/cos.zig+1-1
......@@ -13,7 +13,7 @@ const expect = std.testing.expect;
1313/// Special Cases:
1414/// - cos(+-inf) = nan
1515/// - cos(nan) = nan
16pub fn cos(x: var) @TypeOf(x) {
16pub fn cos(x: anytype) @TypeOf(x) {
1717 const T = @TypeOf(x);
1818 return switch (T) {
1919 f32 => cos_(f32, x),
lib/std/math/cosh.zig+1-1
......@@ -17,7 +17,7 @@ const maxInt = std.math.maxInt;
1717/// - cosh(+-0) = 1
1818/// - cosh(+-inf) = +inf
1919/// - cosh(nan) = nan
20pub fn cosh(x: var) @TypeOf(x) {
20pub fn cosh(x: anytype) @TypeOf(x) {
2121 const T = @TypeOf(x);
2222 return switch (T) {
2323 f32 => cosh32(x),
lib/std/math/exp.zig+1-1
......@@ -14,7 +14,7 @@ const builtin = @import("builtin");
1414/// Special Cases:
1515/// - exp(+inf) = +inf
1616/// - exp(nan) = nan
17pub fn exp(x: var) @TypeOf(x) {
17pub fn exp(x: anytype) @TypeOf(x) {
1818 const T = @TypeOf(x);
1919 return switch (T) {
2020 f32 => exp32(x),
lib/std/math/exp2.zig+1-1
......@@ -13,7 +13,7 @@ const expect = std.testing.expect;
1313/// Special Cases:
1414/// - exp2(+inf) = +inf
1515/// - exp2(nan) = nan
16pub fn exp2(x: var) @TypeOf(x) {
16pub fn exp2(x: anytype) @TypeOf(x) {
1717 const T = @TypeOf(x);
1818 return switch (T) {
1919 f32 => exp2_32(x),
lib/std/math/expm1.zig+1-1
......@@ -18,7 +18,7 @@ const expect = std.testing.expect;
1818/// - expm1(+inf) = +inf
1919/// - expm1(-inf) = -1
2020/// - expm1(nan) = nan
21pub fn expm1(x: var) @TypeOf(x) {
21pub fn expm1(x: anytype) @TypeOf(x) {
2222 const T = @TypeOf(x);
2323 return switch (T) {
2424 f32 => expm1_32(x),
lib/std/math/expo2.zig+1-1
......@@ -7,7 +7,7 @@
77const math = @import("../math.zig");
88
99/// Returns exp(x) / 2 for x >= log(maxFloat(T)).
10pub fn expo2(x: var) @TypeOf(x) {
10pub fn expo2(x: anytype) @TypeOf(x) {
1111 const T = @TypeOf(x);
1212 return switch (T) {
1313 f32 => expo2f(x),
lib/std/math/fabs.zig+1-1
......@@ -14,7 +14,7 @@ const maxInt = std.math.maxInt;
1414/// Special Cases:
1515/// - fabs(+-inf) = +inf
1616/// - fabs(nan) = nan
17pub fn fabs(x: var) @TypeOf(x) {
17pub fn fabs(x: anytype) @TypeOf(x) {
1818 const T = @TypeOf(x);
1919 return switch (T) {
2020 f16 => fabs16(x),
lib/std/math/floor.zig+1-1
......@@ -15,7 +15,7 @@ const math = std.math;
1515/// - floor(+-0) = +-0
1616/// - floor(+-inf) = +-inf
1717/// - floor(nan) = nan
18pub fn floor(x: var) @TypeOf(x) {
18pub fn floor(x: anytype) @TypeOf(x) {
1919 const T = @TypeOf(x);
2020 return switch (T) {
2121 f16 => floor16(x),
lib/std/math/frexp.zig+1-1
......@@ -24,7 +24,7 @@ pub const frexp64_result = frexp_result(f64);
2424/// - frexp(+-0) = +-0, 0
2525/// - frexp(+-inf) = +-inf, 0
2626/// - frexp(nan) = nan, undefined
27pub fn frexp(x: var) frexp_result(@TypeOf(x)) {
27pub fn frexp(x: anytype) frexp_result(@TypeOf(x)) {
2828 const T = @TypeOf(x);
2929 return switch (T) {
3030 f32 => frexp32(x),
lib/std/math/ilogb.zig+1-1
......@@ -16,7 +16,7 @@ const minInt = std.math.minInt;
1616/// - ilogb(+-inf) = maxInt(i32)
1717/// - ilogb(0) = maxInt(i32)
1818/// - ilogb(nan) = maxInt(i32)
19pub fn ilogb(x: var) i32 {
19pub fn ilogb(x: anytype) i32 {
2020 const T = @TypeOf(x);
2121 return switch (T) {
2222 f32 => ilogb32(x),
lib/std/math/isfinite.zig+1-1
......@@ -4,7 +4,7 @@ const expect = std.testing.expect;
44const maxInt = std.math.maxInt;
55
66/// Returns whether x is a finite value.
7pub fn isFinite(x: var) bool {
7pub fn isFinite(x: anytype) bool {
88 const T = @TypeOf(x);
99 switch (T) {
1010 f16 => {
lib/std/math/isinf.zig+3-3
......@@ -4,7 +4,7 @@ const expect = std.testing.expect;
44const maxInt = std.math.maxInt;
55
66/// Returns whether x is an infinity, ignoring sign.
7pub fn isInf(x: var) bool {
7pub fn isInf(x: anytype) bool {
88 const T = @TypeOf(x);
99 switch (T) {
1010 f16 => {
......@@ -30,7 +30,7 @@ pub fn isInf(x: var) bool {
3030}
3131
3232/// Returns whether x is an infinity with a positive sign.
33pub fn isPositiveInf(x: var) bool {
33pub fn isPositiveInf(x: anytype) bool {
3434 const T = @TypeOf(x);
3535 switch (T) {
3636 f16 => {
......@@ -52,7 +52,7 @@ pub fn isPositiveInf(x: var) bool {
5252}
5353
5454/// Returns whether x is an infinity with a negative sign.
55pub fn isNegativeInf(x: var) bool {
55pub fn isNegativeInf(x: anytype) bool {
5656 const T = @TypeOf(x);
5757 switch (T) {
5858 f16 => {
lib/std/math/isnan.zig+2-2
......@@ -4,12 +4,12 @@ const expect = std.testing.expect;
44const maxInt = std.math.maxInt;
55
66/// Returns whether x is a nan.
7pub fn isNan(x: var) bool {
7pub fn isNan(x: anytype) bool {
88 return x != x;
99}
1010
1111/// Returns whether x is a signalling nan.
12pub fn isSignalNan(x: var) bool {
12pub fn isSignalNan(x: anytype) bool {
1313 // Note: A signalling nan is identical to a standard nan right now but may have a different bit
1414 // representation in the future when required.
1515 return isNan(x);
lib/std/math/isnormal.zig+1-1
......@@ -4,7 +4,7 @@ const expect = std.testing.expect;
44const maxInt = std.math.maxInt;
55
66// Returns whether x has a normalized representation (i.e. integer part of mantissa is 1).
7pub fn isNormal(x: var) bool {
7pub fn isNormal(x: anytype) bool {
88 const T = @TypeOf(x);
99 switch (T) {
1010 f16 => {
lib/std/math/ln.zig+1-1
......@@ -15,7 +15,7 @@ const expect = std.testing.expect;
1515/// - ln(0) = -inf
1616/// - ln(x) = nan if x < 0
1717/// - ln(nan) = nan
18pub fn ln(x: var) @TypeOf(x) {
18pub fn ln(x: anytype) @TypeOf(x) {
1919 const T = @TypeOf(x);
2020 switch (@typeInfo(T)) {
2121 .ComptimeFloat => {
lib/std/math/log10.zig+1-1
......@@ -16,7 +16,7 @@ const maxInt = std.math.maxInt;
1616/// - log10(0) = -inf
1717/// - log10(x) = nan if x < 0
1818/// - log10(nan) = nan
19pub fn log10(x: var) @TypeOf(x) {
19pub fn log10(x: anytype) @TypeOf(x) {
2020 const T = @TypeOf(x);
2121 switch (@typeInfo(T)) {
2222 .ComptimeFloat => {
lib/std/math/log1p.zig+1-1
......@@ -17,7 +17,7 @@ const expect = std.testing.expect;
1717/// - log1p(-1) = -inf
1818/// - log1p(x) = nan if x < -1
1919/// - log1p(nan) = nan
20pub fn log1p(x: var) @TypeOf(x) {
20pub fn log1p(x: anytype) @TypeOf(x) {
2121 const T = @TypeOf(x);
2222 return switch (T) {
2323 f32 => log1p_32(x),
lib/std/math/log2.zig+1-1
......@@ -16,7 +16,7 @@ const maxInt = std.math.maxInt;
1616/// - log2(0) = -inf
1717/// - log2(x) = nan if x < 0
1818/// - log2(nan) = nan
19pub fn log2(x: var) @TypeOf(x) {
19pub fn log2(x: anytype) @TypeOf(x) {
2020 const T = @TypeOf(x);
2121 switch (@typeInfo(T)) {
2222 .ComptimeFloat => {
lib/std/math/modf.zig+1-1
......@@ -24,7 +24,7 @@ pub const modf64_result = modf_result(f64);
2424/// Special Cases:
2525/// - modf(+-inf) = +-inf, nan
2626/// - modf(nan) = nan, nan
27pub fn modf(x: var) modf_result(@TypeOf(x)) {
27pub fn modf(x: anytype) modf_result(@TypeOf(x)) {
2828 const T = @TypeOf(x);
2929 return switch (T) {
3030 f32 => modf32(x),
lib/std/math/round.zig+1-1
......@@ -15,7 +15,7 @@ const math = std.math;
1515/// - round(+-0) = +-0
1616/// - round(+-inf) = +-inf
1717/// - round(nan) = nan
18pub fn round(x: var) @TypeOf(x) {
18pub fn round(x: anytype) @TypeOf(x) {
1919 const T = @TypeOf(x);
2020 return switch (T) {
2121 f32 => round32(x),
lib/std/math/scalbn.zig+1-1
......@@ -9,7 +9,7 @@ const math = std.math;
99const expect = std.testing.expect;
1010
1111/// Returns x * 2^n.
12pub fn scalbn(x: var, n: i32) @TypeOf(x) {
12pub fn scalbn(x: anytype, n: i32) @TypeOf(x) {
1313 const T = @TypeOf(x);
1414 return switch (T) {
1515 f32 => scalbn32(x, n),
lib/std/math/signbit.zig+1-1
......@@ -3,7 +3,7 @@ const math = std.math;
33const expect = std.testing.expect;
44
55/// Returns whether x is negative or negative 0.
6pub fn signbit(x: var) bool {
6pub fn signbit(x: anytype) bool {
77 const T = @TypeOf(x);
88 return switch (T) {
99 f16 => signbit16(x),
lib/std/math/sin.zig+1-1
......@@ -14,7 +14,7 @@ const expect = std.testing.expect;
1414/// - sin(+-0) = +-0
1515/// - sin(+-inf) = nan
1616/// - sin(nan) = nan
17pub fn sin(x: var) @TypeOf(x) {
17pub fn sin(x: anytype) @TypeOf(x) {
1818 const T = @TypeOf(x);
1919 return switch (T) {
2020 f32 => sin_(T, x),
lib/std/math/sinh.zig+1-1
......@@ -17,7 +17,7 @@ const maxInt = std.math.maxInt;
1717/// - sinh(+-0) = +-0
1818/// - sinh(+-inf) = +-inf
1919/// - sinh(nan) = nan
20pub fn sinh(x: var) @TypeOf(x) {
20pub fn sinh(x: anytype) @TypeOf(x) {
2121 const T = @TypeOf(x);
2222 return switch (T) {
2323 f32 => sinh32(x),
lib/std/math/sqrt.zig+1-1
......@@ -13,7 +13,7 @@ const maxInt = std.math.maxInt;
1313/// - sqrt(x) = nan if x < 0
1414/// - sqrt(nan) = nan
1515/// TODO Decide if all this logic should be implemented directly in the @sqrt bultin function.
16pub fn sqrt(x: var) Sqrt(@TypeOf(x)) {
16pub fn sqrt(x: anytype) Sqrt(@TypeOf(x)) {
1717 const T = @TypeOf(x);
1818 switch (@typeInfo(T)) {
1919 .Float, .ComptimeFloat => return @sqrt(x),
lib/std/math/tan.zig+1-1
......@@ -14,7 +14,7 @@ const expect = std.testing.expect;
1414/// - tan(+-0) = +-0
1515/// - tan(+-inf) = nan
1616/// - tan(nan) = nan
17pub fn tan(x: var) @TypeOf(x) {
17pub fn tan(x: anytype) @TypeOf(x) {
1818 const T = @TypeOf(x);
1919 return switch (T) {
2020 f32 => tan_(f32, x),
lib/std/math/tanh.zig+1-1
......@@ -17,7 +17,7 @@ const maxInt = std.math.maxInt;
1717/// - sinh(+-0) = +-0
1818/// - sinh(+-inf) = +-1
1919/// - sinh(nan) = nan
20pub fn tanh(x: var) @TypeOf(x) {
20pub fn tanh(x: anytype) @TypeOf(x) {
2121 const T = @TypeOf(x);
2222 return switch (T) {
2323 f32 => tanh32(x),
lib/std/math/trunc.zig+1-1
......@@ -15,7 +15,7 @@ const maxInt = std.math.maxInt;
1515/// - trunc(+-0) = +-0
1616/// - trunc(+-inf) = +-inf
1717/// - trunc(nan) = nan
18pub fn trunc(x: var) @TypeOf(x) {
18pub fn trunc(x: anytype) @TypeOf(x) {
1919 const T = @TypeOf(x);
2020 return switch (T) {
2121 f32 => trunc32(x),
lib/std/mem.zig+87-86
......@@ -122,7 +122,7 @@ pub const Allocator = struct {
122122 assert(resized_len >= new_byte_count);
123123 @memset(old_mem.ptr + new_byte_count, undefined, resized_len - new_byte_count);
124124 return old_mem.ptr[0..resized_len];
125 } else |_| { }
125 } else |_| {}
126126 }
127127 if (new_byte_count <= old_mem.len and new_alignment <= old_alignment) {
128128 return error.OutOfMemory;
......@@ -156,7 +156,7 @@ pub const Allocator = struct {
156156
157157 /// `ptr` should be the return value of `create`, or otherwise
158158 /// have the same address and alignment property.
159 pub fn destroy(self: *Allocator, ptr: var) void {
159 pub fn destroy(self: *Allocator, ptr: anytype) void {
160160 const T = @TypeOf(ptr).Child;
161161 if (@sizeOf(T) == 0) return;
162162 const non_const_ptr = @intToPtr([*]u8, @ptrToInt(ptr));
......@@ -225,7 +225,7 @@ pub const Allocator = struct {
225225 return self.allocAdvanced(T, alignment, n, .exact);
226226 }
227227
228 const Exact = enum {exact,at_least};
228 const Exact = enum { exact, at_least };
229229 pub fn allocAdvanced(
230230 self: *Allocator,
231231 comptime T: type,
......@@ -272,7 +272,7 @@ pub const Allocator = struct {
272272 /// in `std.ArrayList.shrink`.
273273 /// If you need guaranteed success, call `shrink`.
274274 /// If `new_n` is 0, this is the same as `free` and it always succeeds.
275 pub fn realloc(self: *Allocator, old_mem: var, new_n: usize) t: {
275 pub fn realloc(self: *Allocator, old_mem: anytype, new_n: usize) t: {
276276 const Slice = @typeInfo(@TypeOf(old_mem)).Pointer;
277277 break :t Error![]align(Slice.alignment) Slice.child;
278278 } {
......@@ -280,7 +280,7 @@ pub const Allocator = struct {
280280 return self.reallocAdvanced(old_mem, old_alignment, new_n, .exact);
281281 }
282282
283 pub fn reallocAtLeast(self: *Allocator, old_mem: var, new_n: usize) t: {
283 pub fn reallocAtLeast(self: *Allocator, old_mem: anytype, new_n: usize) t: {
284284 const Slice = @typeInfo(@TypeOf(old_mem)).Pointer;
285285 break :t Error![]align(Slice.alignment) Slice.child;
286286 } {
......@@ -291,7 +291,7 @@ pub const Allocator = struct {
291291 // Deprecated: use `reallocAdvanced`
292292 pub fn alignedRealloc(
293293 self: *Allocator,
294 old_mem: var,
294 old_mem: anytype,
295295 comptime new_alignment: u29,
296296 new_n: usize,
297297 ) Error![]align(new_alignment) @typeInfo(@TypeOf(old_mem)).Pointer.child {
......@@ -303,7 +303,7 @@ pub const Allocator = struct {
303303 /// allocation.
304304 pub fn reallocAdvanced(
305305 self: *Allocator,
306 old_mem: var,
306 old_mem: anytype,
307307 comptime new_alignment: u29,
308308 new_n: usize,
309309 exact: Exact,
......@@ -321,8 +321,7 @@ pub const Allocator = struct {
321321 const old_byte_slice = mem.sliceAsBytes(old_mem);
322322 const byte_count = math.mul(usize, @sizeOf(T), new_n) catch return Error.OutOfMemory;
323323 // Note: can't set shrunk memory to undefined as memory shouldn't be modified on realloc failure
324 const new_byte_slice = try self.reallocBytes(old_byte_slice, Slice.alignment, byte_count, new_alignment,
325 if (exact == .exact) @as(u29, 0) else @sizeOf(T));
324 const new_byte_slice = try self.reallocBytes(old_byte_slice, Slice.alignment, byte_count, new_alignment, if (exact == .exact) @as(u29, 0) else @sizeOf(T));
326325 return mem.bytesAsSlice(T, @alignCast(new_alignment, new_byte_slice));
327326 }
328327
......@@ -331,7 +330,7 @@ pub const Allocator = struct {
331330 /// Shrink always succeeds, and `new_n` must be <= `old_mem.len`.
332331 /// Returned slice has same alignment as old_mem.
333332 /// Shrinking to 0 is the same as calling `free`.
334 pub fn shrink(self: *Allocator, old_mem: var, new_n: usize) t: {
333 pub fn shrink(self: *Allocator, old_mem: anytype, new_n: usize) t: {
335334 const Slice = @typeInfo(@TypeOf(old_mem)).Pointer;
336335 break :t []align(Slice.alignment) Slice.child;
337336 } {
......@@ -344,7 +343,7 @@ pub const Allocator = struct {
344343 /// allocation.
345344 pub fn alignedShrink(
346345 self: *Allocator,
347 old_mem: var,
346 old_mem: anytype,
348347 comptime new_alignment: u29,
349348 new_n: usize,
350349 ) []align(new_alignment) @typeInfo(@TypeOf(old_mem)).Pointer.child {
......@@ -368,7 +367,7 @@ pub const Allocator = struct {
368367
369368 /// Free an array allocated with `alloc`. To free a single item,
370369 /// see `destroy`.
371 pub fn free(self: *Allocator, memory: var) void {
370 pub fn free(self: *Allocator, memory: anytype) void {
372371 const Slice = @typeInfo(@TypeOf(memory)).Pointer;
373372 const bytes = mem.sliceAsBytes(memory);
374373 const bytes_len = bytes.len + if (Slice.sentinel != null) @sizeOf(Slice.child) else 0;
......@@ -396,67 +395,69 @@ pub const Allocator = struct {
396395
397396/// Detects and asserts if the std.mem.Allocator interface is violated by the caller
398397/// or the allocator.
399pub fn ValidationAllocator(comptime T: type) type { return struct {
400 const Self = @This();
401 allocator: Allocator,
402 underlying_allocator: T,
403 pub fn init(allocator: T) @This() {
404 return .{
405 .allocator = .{
406 .allocFn = alloc,
407 .resizeFn = resize,
408 },
409 .underlying_allocator = allocator,
410 };
411 }
412 fn getUnderlyingAllocatorPtr(self: *@This()) *Allocator {
413 if (T == *Allocator) return self.underlying_allocator;
414 if (*T == *Allocator) return &self.underlying_allocator;
415 return &self.underlying_allocator.allocator;
416 }
417 pub fn alloc(allocator: *Allocator, n: usize, ptr_align: u29, len_align: u29) Allocator.Error![]u8 {
418 assert(n > 0);
419 assert(mem.isValidAlign(ptr_align));
420 if (len_align != 0) {
421 assert(mem.isAlignedAnyAlign(n, len_align));
422 assert(n >= len_align);
423 }
424
425 const self = @fieldParentPtr(@This(), "allocator", allocator);
426 const result = try self.getUnderlyingAllocatorPtr().callAllocFn(n, ptr_align, len_align);
427 assert(mem.isAligned(@ptrToInt(result.ptr), ptr_align));
428 if (len_align == 0) {
429 assert(result.len == n);
430 } else {
431 assert(result.len >= n);
432 assert(mem.isAlignedAnyAlign(result.len, len_align));
398pub fn ValidationAllocator(comptime T: type) type {
399 return struct {
400 const Self = @This();
401 allocator: Allocator,
402 underlying_allocator: T,
403 pub fn init(allocator: T) @This() {
404 return .{
405 .allocator = .{
406 .allocFn = alloc,
407 .resizeFn = resize,
408 },
409 .underlying_allocator = allocator,
410 };
433411 }
434 return result;
435 }
436 pub fn resize(allocator: *Allocator, buf: []u8, new_len: usize, len_align: u29) Allocator.Error!usize {
437 assert(buf.len > 0);
438 if (len_align != 0) {
439 assert(mem.isAlignedAnyAlign(new_len, len_align));
440 assert(new_len >= len_align);
412 fn getUnderlyingAllocatorPtr(self: *@This()) *Allocator {
413 if (T == *Allocator) return self.underlying_allocator;
414 if (*T == *Allocator) return &self.underlying_allocator;
415 return &self.underlying_allocator.allocator;
441416 }
442 const self = @fieldParentPtr(@This(), "allocator", allocator);
443 const result = try self.getUnderlyingAllocatorPtr().callResizeFn(buf, new_len, len_align);
444 if (len_align == 0) {
445 assert(result == new_len);
446 } else {
447 assert(result >= new_len);
448 assert(mem.isAlignedAnyAlign(result, len_align));
417 pub fn alloc(allocator: *Allocator, n: usize, ptr_align: u29, len_align: u29) Allocator.Error![]u8 {
418 assert(n > 0);
419 assert(mem.isValidAlign(ptr_align));
420 if (len_align != 0) {
421 assert(mem.isAlignedAnyAlign(n, len_align));
422 assert(n >= len_align);
423 }
424
425 const self = @fieldParentPtr(@This(), "allocator", allocator);
426 const result = try self.getUnderlyingAllocatorPtr().callAllocFn(n, ptr_align, len_align);
427 assert(mem.isAligned(@ptrToInt(result.ptr), ptr_align));
428 if (len_align == 0) {
429 assert(result.len == n);
430 } else {
431 assert(result.len >= n);
432 assert(mem.isAlignedAnyAlign(result.len, len_align));
433 }
434 return result;
449435 }
450 return result;
451 }
452 pub usingnamespace if (T == *Allocator or !@hasDecl(T, "reset")) struct {} else struct {
453 pub fn reset(self: *Self) void {
454 self.underlying_allocator.reset();
436 pub fn resize(allocator: *Allocator, buf: []u8, new_len: usize, len_align: u29) Allocator.Error!usize {
437 assert(buf.len > 0);
438 if (len_align != 0) {
439 assert(mem.isAlignedAnyAlign(new_len, len_align));
440 assert(new_len >= len_align);
441 }
442 const self = @fieldParentPtr(@This(), "allocator", allocator);
443 const result = try self.getUnderlyingAllocatorPtr().callResizeFn(buf, new_len, len_align);
444 if (len_align == 0) {
445 assert(result == new_len);
446 } else {
447 assert(result >= new_len);
448 assert(mem.isAlignedAnyAlign(result, len_align));
449 }
450 return result;
455451 }
452 pub usingnamespace if (T == *Allocator or !@hasDecl(T, "reset")) struct {} else struct {
453 pub fn reset(self: *Self) void {
454 self.underlying_allocator.reset();
455 }
456 };
456457 };
457};}
458}
458459
459pub fn validationWrap(allocator: var) ValidationAllocator(@TypeOf(allocator)) {
460pub fn validationWrap(allocator: anytype) ValidationAllocator(@TypeOf(allocator)) {
460461 return ValidationAllocator(@TypeOf(allocator)).init(allocator);
461462}
462463
......@@ -465,14 +466,14 @@ pub fn validationWrap(allocator: var) ValidationAllocator(@TypeOf(allocator)) {
465466/// than the `len` that was requsted. This function should only be used by allocators
466467/// that are unaffected by `len_align`.
467468pub fn alignAllocLen(full_len: usize, alloc_len: usize, len_align: u29) usize {
468 assert(alloc_len > 0);
469 assert(alloc_len >= len_align);
470 assert(full_len >= alloc_len);
471 if (len_align == 0)
472 return alloc_len;
473 const adjusted = alignBackwardAnyAlign(full_len, len_align);
474 assert(adjusted >= alloc_len);
475 return adjusted;
469 assert(alloc_len > 0);
470 assert(alloc_len >= len_align);
471 assert(full_len >= alloc_len);
472 if (len_align == 0)
473 return alloc_len;
474 const adjusted = alignBackwardAnyAlign(full_len, len_align);
475 assert(adjusted >= alloc_len);
476 return adjusted;
476477}
477478
478479var failAllocator = Allocator{
......@@ -695,7 +696,7 @@ test "mem.secureZero" {
695696/// Initializes all fields of the struct with their default value, or zero values if no default value is present.
696697/// If the field is present in the provided initial values, it will have that value instead.
697698/// Structs are initialized recursively.
698pub fn zeroInit(comptime T: type, init: var) T {
699pub fn zeroInit(comptime T: type, init: anytype) T {
699700 comptime const Init = @TypeOf(init);
700701
701702 switch (@typeInfo(T)) {
......@@ -895,7 +896,7 @@ test "Span" {
895896///
896897/// When there is both a sentinel and an array length or slice length, the
897898/// length value is used instead of the sentinel.
898pub fn span(ptr: var) Span(@TypeOf(ptr)) {
899pub fn span(ptr: anytype) Span(@TypeOf(ptr)) {
899900 if (@typeInfo(@TypeOf(ptr)) == .Optional) {
900901 if (ptr) |non_null| {
901902 return span(non_null);
......@@ -923,7 +924,7 @@ test "span" {
923924/// Same as `span`, except when there is both a sentinel and an array
924925/// length or slice length, scans the memory for the sentinel value
925926/// rather than using the length.
926pub fn spanZ(ptr: var) Span(@TypeOf(ptr)) {
927pub fn spanZ(ptr: anytype) Span(@TypeOf(ptr)) {
927928 if (@typeInfo(@TypeOf(ptr)) == .Optional) {
928929 if (ptr) |non_null| {
929930 return spanZ(non_null);
......@@ -952,7 +953,7 @@ test "spanZ" {
952953/// or a slice, and returns the length.
953954/// In the case of a sentinel-terminated array, it uses the array length.
954955/// For C pointers it assumes it is a pointer-to-many with a 0 sentinel.
955pub fn len(value: var) usize {
956pub fn len(value: anytype) usize {
956957 return switch (@typeInfo(@TypeOf(value))) {
957958 .Array => |info| info.len,
958959 .Vector => |info| info.len,
......@@ -1000,7 +1001,7 @@ test "len" {
10001001/// In the case of a sentinel-terminated array, it scans the array
10011002/// for a sentinel and uses that for the length, rather than using the array length.
10021003/// For C pointers it assumes it is a pointer-to-many with a 0 sentinel.
1003pub fn lenZ(ptr: var) usize {
1004pub fn lenZ(ptr: anytype) usize {
10041005 return switch (@typeInfo(@TypeOf(ptr))) {
10051006 .Array => |info| if (info.sentinel) |sentinel|
10061007 indexOfSentinel(info.child, sentinel, &ptr)
......@@ -2031,7 +2032,7 @@ fn AsBytesReturnType(comptime P: type) type {
20312032}
20322033
20332034/// Given a pointer to a single item, returns a slice of the underlying bytes, preserving constness.
2034pub fn asBytes(ptr: var) AsBytesReturnType(@TypeOf(ptr)) {
2035pub fn asBytes(ptr: anytype) AsBytesReturnType(@TypeOf(ptr)) {
20352036 const P = @TypeOf(ptr);
20362037 return @ptrCast(AsBytesReturnType(P), ptr);
20372038}
......@@ -2071,7 +2072,7 @@ test "asBytes" {
20712072}
20722073
20732074///Given any value, returns a copy of its bytes in an array.
2074pub fn toBytes(value: var) [@sizeOf(@TypeOf(value))]u8 {
2075pub fn toBytes(value: anytype) [@sizeOf(@TypeOf(value))]u8 {
20752076 return asBytes(&value).*;
20762077}
20772078
......@@ -2106,7 +2107,7 @@ fn BytesAsValueReturnType(comptime T: type, comptime B: type) type {
21062107
21072108///Given a pointer to an array of bytes, returns a pointer to a value of the specified type
21082109/// backed by those bytes, preserving constness.
2109pub fn bytesAsValue(comptime T: type, bytes: var) BytesAsValueReturnType(T, @TypeOf(bytes)) {
2110pub fn bytesAsValue(comptime T: type, bytes: anytype) BytesAsValueReturnType(T, @TypeOf(bytes)) {
21102111 return @ptrCast(BytesAsValueReturnType(T, @TypeOf(bytes)), bytes);
21112112}
21122113
......@@ -2149,7 +2150,7 @@ test "bytesAsValue" {
21492150
21502151///Given a pointer to an array of bytes, returns a value of the specified type backed by a
21512152/// copy of those bytes.
2152pub fn bytesToValue(comptime T: type, bytes: var) T {
2153pub fn bytesToValue(comptime T: type, bytes: anytype) T {
21532154 return bytesAsValue(T, bytes).*;
21542155}
21552156test "bytesToValue" {
......@@ -2177,7 +2178,7 @@ fn BytesAsSliceReturnType(comptime T: type, comptime bytesType: type) type {
21772178 return if (trait.isConstPtr(bytesType)) []align(alignment) const T else []align(alignment) T;
21782179}
21792180
2180pub fn bytesAsSlice(comptime T: type, bytes: var) BytesAsSliceReturnType(T, @TypeOf(bytes)) {
2181pub fn bytesAsSlice(comptime T: type, bytes: anytype) BytesAsSliceReturnType(T, @TypeOf(bytes)) {
21812182 // let's not give an undefined pointer to @ptrCast
21822183 // it may be equal to zero and fail a null check
21832184 if (bytes.len == 0) {
......@@ -2256,7 +2257,7 @@ fn SliceAsBytesReturnType(comptime sliceType: type) type {
22562257 return if (trait.isConstPtr(sliceType)) []align(alignment) const u8 else []align(alignment) u8;
22572258}
22582259
2259pub fn sliceAsBytes(slice: var) SliceAsBytesReturnType(@TypeOf(slice)) {
2260pub fn sliceAsBytes(slice: anytype) SliceAsBytesReturnType(@TypeOf(slice)) {
22602261 const Slice = @TypeOf(slice);
22612262
22622263 // let's not give an undefined pointer to @ptrCast
lib/std/meta.zig+5-5
......@@ -9,7 +9,7 @@ pub const trait = @import("meta/trait.zig");
99
1010const TypeInfo = builtin.TypeInfo;
1111
12pub fn tagName(v: var) []const u8 {
12pub fn tagName(v: anytype) []const u8 {
1313 const T = @TypeOf(v);
1414 switch (@typeInfo(T)) {
1515 .ErrorSet => return @errorName(v),
......@@ -430,7 +430,7 @@ test "std.meta.TagType" {
430430}
431431
432432///Returns the active tag of a tagged union
433pub fn activeTag(u: var) @TagType(@TypeOf(u)) {
433pub fn activeTag(u: anytype) @TagType(@TypeOf(u)) {
434434 const T = @TypeOf(u);
435435 return @as(@TagType(T), u);
436436}
......@@ -480,7 +480,7 @@ test "std.meta.TagPayloadType" {
480480
481481/// Compares two of any type for equality. Containers are compared on a field-by-field basis,
482482/// where possible. Pointers are not followed.
483pub fn eql(a: var, b: @TypeOf(a)) bool {
483pub fn eql(a: anytype, b: @TypeOf(a)) bool {
484484 const T = @TypeOf(a);
485485
486486 switch (@typeInfo(T)) {
......@@ -627,7 +627,7 @@ test "intToEnum with error return" {
627627
628628pub const IntToEnumError = error{InvalidEnumTag};
629629
630pub fn intToEnum(comptime Tag: type, tag_int: var) IntToEnumError!Tag {
630pub fn intToEnum(comptime Tag: type, tag_int: anytype) IntToEnumError!Tag {
631631 inline for (@typeInfo(Tag).Enum.fields) |f| {
632632 const this_tag_value = @field(Tag, f.name);
633633 if (tag_int == @enumToInt(this_tag_value)) {
......@@ -696,7 +696,7 @@ pub fn Vector(comptime len: u32, comptime child: type) type {
696696
697697/// Given a type and value, cast the value to the type as c would.
698698/// This is for translate-c and is not intended for general use.
699pub fn cast(comptime DestType: type, target: var) DestType {
699pub fn cast(comptime DestType: type, target: anytype) DestType {
700700 const TargetType = @TypeOf(target);
701701 switch (@typeInfo(DestType)) {
702702 .Pointer => {
lib/std/meta/trait.zig+4-4
......@@ -9,7 +9,7 @@ const meta = @import("../meta.zig");
99
1010pub const TraitFn = fn (type) bool;
1111
12pub fn multiTrait(comptime traits: var) TraitFn {
12pub fn multiTrait(comptime traits: anytype) TraitFn {
1313 const Closure = struct {
1414 pub fn trait(comptime T: type) bool {
1515 inline for (traits) |t|
......@@ -342,7 +342,7 @@ test "std.meta.trait.isContainer" {
342342 testing.expect(!isContainer(u8));
343343}
344344
345pub fn hasDecls(comptime T: type, comptime names: var) bool {
345pub fn hasDecls(comptime T: type, comptime names: anytype) bool {
346346 inline for (names) |name| {
347347 if (!@hasDecl(T, name))
348348 return false;
......@@ -368,7 +368,7 @@ test "std.meta.trait.hasDecls" {
368368 testing.expect(!hasDecls(TestStruct2, tuple));
369369}
370370
371pub fn hasFields(comptime T: type, comptime names: var) bool {
371pub fn hasFields(comptime T: type, comptime names: anytype) bool {
372372 inline for (names) |name| {
373373 if (!@hasField(T, name))
374374 return false;
......@@ -394,7 +394,7 @@ test "std.meta.trait.hasFields" {
394394 testing.expect(!hasFields(TestStruct2, .{ "a", "b", "useless" }));
395395}
396396
397pub fn hasFunctions(comptime T: type, comptime names: var) bool {
397pub fn hasFunctions(comptime T: type, comptime names: anytype) bool {
398398 inline for (names) |name| {
399399 if (!hasFn(name)(T))
400400 return false;
lib/std/net.zig+3-3
......@@ -427,7 +427,7 @@ pub const Address = extern union {
427427 self: Address,
428428 comptime fmt: []const u8,
429429 options: std.fmt.FormatOptions,
430 out_stream: var,
430 out_stream: anytype,
431431 ) !void {
432432 switch (self.any.family) {
433433 os.AF_INET => {
......@@ -1404,8 +1404,8 @@ fn resMSendRc(
14041404
14051405fn dnsParse(
14061406 r: []const u8,
1407 ctx: var,
1408 comptime callback: var,
1407 ctx: anytype,
1408 comptime callback: anytype,
14091409) !void {
14101410 // This implementation is ported from musl libc.
14111411 // A more idiomatic "ziggy" implementation would be welcome.
lib/std/os.zig+1-1
......@@ -4068,7 +4068,7 @@ pub fn nanosleep(seconds: u64, nanoseconds: u64) void {
40684068}
40694069
40704070pub fn dl_iterate_phdr(
4071 context: var,
4071 context: anytype,
40724072 comptime Error: type,
40734073 comptime callback: fn (info: *dl_phdr_info, size: usize, context: @TypeOf(context)) Error!void,
40744074) Error!void {
lib/std/os/uefi.zig+1-1
......@@ -28,7 +28,7 @@ pub const Guid = extern struct {
2828 self: @This(),
2929 comptime f: []const u8,
3030 options: std.fmt.FormatOptions,
31 out_stream: var,
31 out_stream: anytype,
3232 ) Errors!void {
3333 if (f.len == 0) {
3434 return std.fmt.format(out_stream, "{x:0>8}-{x:0>4}-{x:0>4}-{x:0>2}{x:0>2}-{x:0>12}", .{
lib/std/progress.zig+2-2
......@@ -224,7 +224,7 @@ pub const Progress = struct {
224224 self.prev_refresh_timestamp = self.timer.read();
225225 }
226226
227 pub fn log(self: *Progress, comptime format: []const u8, args: var) void {
227 pub fn log(self: *Progress, comptime format: []const u8, args: anytype) void {
228228 const file = self.terminal orelse return;
229229 self.refresh();
230230 file.outStream().print(format, args) catch {
......@@ -234,7 +234,7 @@ pub const Progress = struct {
234234 self.columns_written = 0;
235235 }
236236
237 fn bufWrite(self: *Progress, end: *usize, comptime format: []const u8, args: var) void {
237 fn bufWrite(self: *Progress, end: *usize, comptime format: []const u8, args: anytype) void {
238238 if (std.fmt.bufPrint(self.output_buffer[end.*..], format, args)) |written| {
239239 const amt = written.len;
240240 end.* += amt;
lib/std/segmented_list.zig+2-2
......@@ -122,7 +122,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
122122 self.* = undefined;
123123 }
124124
125 pub fn at(self: var, i: usize) AtType(@TypeOf(self)) {
125 pub fn at(self: anytype, i: usize) AtType(@TypeOf(self)) {
126126 assert(i < self.len);
127127 return self.uncheckedAt(i);
128128 }
......@@ -241,7 +241,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
241241 }
242242 }
243243
244 pub fn uncheckedAt(self: var, index: usize) AtType(@TypeOf(self)) {
244 pub fn uncheckedAt(self: anytype, index: usize) AtType(@TypeOf(self)) {
245245 if (index < prealloc_item_count) {
246246 return &self.prealloc_segment[index];
247247 }
lib/std/sort.zig+19-19
......@@ -9,7 +9,7 @@ pub fn binarySearch(
99 comptime T: type,
1010 key: T,
1111 items: []const T,
12 context: var,
12 context: anytype,
1313 comptime compareFn: fn (context: @TypeOf(context), lhs: T, rhs: T) math.Order,
1414) ?usize {
1515 var left: usize = 0;
......@@ -76,7 +76,7 @@ test "binarySearch" {
7676pub fn insertionSort(
7777 comptime T: type,
7878 items: []T,
79 context: var,
79 context: anytype,
8080 comptime lessThan: fn (context: @TypeOf(context), lhs: T, rhs: T) bool,
8181) void {
8282 var i: usize = 1;
......@@ -182,7 +182,7 @@ const Pull = struct {
182182pub fn sort(
183183 comptime T: type,
184184 items: []T,
185 context: var,
185 context: anytype,
186186 comptime lessThan: fn (context: @TypeOf(context), lhs: T, rhs: T) bool,
187187) void {
188188 // Implementation ported from https://github.com/BonzaiThePenguin/WikiSort/blob/master/WikiSort.c
......@@ -813,7 +813,7 @@ fn mergeInPlace(
813813 items: []T,
814814 A_arg: Range,
815815 B_arg: Range,
816 context: var,
816 context: anytype,
817817 comptime lessThan: fn (@TypeOf(context), T, T) bool,
818818) void {
819819 if (A_arg.length() == 0 or B_arg.length() == 0) return;
......@@ -862,7 +862,7 @@ fn mergeInternal(
862862 items: []T,
863863 A: Range,
864864 B: Range,
865 context: var,
865 context: anytype,
866866 comptime lessThan: fn (@TypeOf(context), T, T) bool,
867867 buffer: Range,
868868) void {
......@@ -906,7 +906,7 @@ fn findFirstForward(
906906 items: []T,
907907 value: T,
908908 range: Range,
909 context: var,
909 context: anytype,
910910 comptime lessThan: fn (@TypeOf(context), T, T) bool,
911911 unique: usize,
912912) usize {
......@@ -928,7 +928,7 @@ fn findFirstBackward(
928928 items: []T,
929929 value: T,
930930 range: Range,
931 context: var,
931 context: anytype,
932932 comptime lessThan: fn (@TypeOf(context), T, T) bool,
933933 unique: usize,
934934) usize {
......@@ -950,7 +950,7 @@ fn findLastForward(
950950 items: []T,
951951 value: T,
952952 range: Range,
953 context: var,
953 context: anytype,
954954 comptime lessThan: fn (@TypeOf(context), T, T) bool,
955955 unique: usize,
956956) usize {
......@@ -972,7 +972,7 @@ fn findLastBackward(
972972 items: []T,
973973 value: T,
974974 range: Range,
975 context: var,
975 context: anytype,
976976 comptime lessThan: fn (@TypeOf(context), T, T) bool,
977977 unique: usize,
978978) usize {
......@@ -994,7 +994,7 @@ fn binaryFirst(
994994 items: []T,
995995 value: T,
996996 range: Range,
997 context: var,
997 context: anytype,
998998 comptime lessThan: fn (@TypeOf(context), T, T) bool,
999999) usize {
10001000 var curr = range.start;
......@@ -1017,7 +1017,7 @@ fn binaryLast(
10171017 items: []T,
10181018 value: T,
10191019 range: Range,
1020 context: var,
1020 context: anytype,
10211021 comptime lessThan: fn (@TypeOf(context), T, T) bool,
10221022) usize {
10231023 var curr = range.start;
......@@ -1040,7 +1040,7 @@ fn mergeInto(
10401040 from: []T,
10411041 A: Range,
10421042 B: Range,
1043 context: var,
1043 context: anytype,
10441044 comptime lessThan: fn (@TypeOf(context), T, T) bool,
10451045 into: []T,
10461046) void {
......@@ -1078,7 +1078,7 @@ fn mergeExternal(
10781078 items: []T,
10791079 A: Range,
10801080 B: Range,
1081 context: var,
1081 context: anytype,
10821082 comptime lessThan: fn (@TypeOf(context), T, T) bool,
10831083 cache: []T,
10841084) void {
......@@ -1112,7 +1112,7 @@ fn mergeExternal(
11121112fn swap(
11131113 comptime T: type,
11141114 items: []T,
1115 context: var,
1115 context: anytype,
11161116 comptime lessThan: fn (@TypeOf(context), lhs: T, rhs: T) bool,
11171117 order: *[8]u8,
11181118 x: usize,
......@@ -1358,7 +1358,7 @@ fn fuzzTest(rng: *std.rand.Random) !void {
13581358pub fn argMin(
13591359 comptime T: type,
13601360 items: []const T,
1361 context: var,
1361 context: anytype,
13621362 comptime lessThan: fn (@TypeOf(context), lhs: T, rhs: T) bool,
13631363) ?usize {
13641364 if (items.len == 0) {
......@@ -1390,7 +1390,7 @@ test "argMin" {
13901390pub fn min(
13911391 comptime T: type,
13921392 items: []const T,
1393 context: var,
1393 context: anytype,
13941394 comptime lessThan: fn (context: @TypeOf(context), lhs: T, rhs: T) bool,
13951395) ?T {
13961396 const i = argMin(T, items, context, lessThan) orelse return null;
......@@ -1410,7 +1410,7 @@ test "min" {
14101410pub fn argMax(
14111411 comptime T: type,
14121412 items: []const T,
1413 context: var,
1413 context: anytype,
14141414 comptime lessThan: fn (context: @TypeOf(context), lhs: T, rhs: T) bool,
14151415) ?usize {
14161416 if (items.len == 0) {
......@@ -1442,7 +1442,7 @@ test "argMax" {
14421442pub fn max(
14431443 comptime T: type,
14441444 items: []const T,
1445 context: var,
1445 context: anytype,
14461446 comptime lessThan: fn (context: @TypeOf(context), lhs: T, rhs: T) bool,
14471447) ?T {
14481448 const i = argMax(T, items, context, lessThan) orelse return null;
......@@ -1462,7 +1462,7 @@ test "max" {
14621462pub fn isSorted(
14631463 comptime T: type,
14641464 items: []const T,
1465 context: var,
1465 context: anytype,
14661466 comptime lessThan: fn (context: @TypeOf(context), lhs: T, rhs: T) bool,
14671467) bool {
14681468 var i: usize = 1;
lib/std/special/build_runner.zig+2-2
......@@ -135,7 +135,7 @@ fn runBuild(builder: *Builder) anyerror!void {
135135 }
136136}
137137
138fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {
138fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void {
139139 // run the build script to collect the options
140140 if (!already_ran_build) {
141141 builder.setInstallPrefix(null);
......@@ -202,7 +202,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {
202202 );
203203}
204204
205fn usageAndErr(builder: *Builder, already_ran_build: bool, out_stream: var) void {
205fn usageAndErr(builder: *Builder, already_ran_build: bool, out_stream: anytype) void {
206206 usage(builder, already_ran_build, out_stream) catch {};
207207 process.exit(1);
208208}
lib/std/special/test_runner.zig+2-2
......@@ -79,9 +79,9 @@ pub fn log(
7979 comptime message_level: std.log.Level,
8080 comptime scope: @Type(.EnumLiteral),
8181 comptime format: []const u8,
82 args: var,
82 args: anytype,
8383) void {
8484 if (@enumToInt(message_level) <= @enumToInt(std.testing.log_level)) {
85 std.debug.print("[{}] ({}): " ++ format, .{@tagName(scope), @tagName(message_level)} ++ args);
85 std.debug.print("[{}] ({}): " ++ format, .{ @tagName(scope), @tagName(message_level) } ++ args);
8686 }
8787}
lib/std/target.zig+6-13
......@@ -108,23 +108,16 @@ pub const Target = struct {
108108 self: WindowsVersion,
109109 comptime fmt: []const u8,
110110 options: std.fmt.FormatOptions,
111 out_stream: var,
111 out_stream: anytype,
112112 ) !void {
113 if (fmt.len > 0 and fmt[0] == 's') {
114 if (
115 @enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.win10_19h1)
116 ) {
113 if (fmt.len > 0 and fmt[0] == 's') {
114 if (@enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.win10_19h1)) {
117115 try std.fmt.format(out_stream, ".{}", .{@tagName(self)});
118116 } else {
119 try std.fmt.format(out_stream,
120 "@intToEnum(Target.Os.WindowsVersion, {})",
121 .{ @enumToInt(self) }
122 );
117 try std.fmt.format(out_stream, "@intToEnum(Target.Os.WindowsVersion, {})", .{@enumToInt(self)});
123118 }
124119 } else {
125 if (
126 @enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.win10_19h1)
127 ) {
120 if (@enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.win10_19h1)) {
128121 try std.fmt.format(out_stream, "WindowsVersion.{}", .{@tagName(self)});
129122 } else {
130123 try std.fmt.format(out_stream, "WindowsVersion(", .{@typeName(@This())});
......@@ -1198,7 +1191,7 @@ pub const Target = struct {
11981191 pub fn standardDynamicLinkerPath(self: Target) DynamicLinker {
11991192 var result: DynamicLinker = .{};
12001193 const S = struct {
1201 fn print(r: *DynamicLinker, comptime fmt: []const u8, args: var) DynamicLinker {
1194 fn print(r: *DynamicLinker, comptime fmt: []const u8, args: anytype) DynamicLinker {
12021195 r.max_byte = @intCast(u8, (std.fmt.bufPrint(&r.buffer, fmt, args) catch unreachable).len - 1);
12031196 return r.*;
12041197 }
lib/std/testing.zig+2-2
......@@ -19,7 +19,7 @@ pub var log_level = std.log.Level.warn;
1919
2020/// This function is intended to be used only in tests. It prints diagnostics to stderr
2121/// and then aborts when actual_error_union is not expected_error.
22pub fn expectError(expected_error: anyerror, actual_error_union: var) void {
22pub fn expectError(expected_error: anyerror, actual_error_union: anytype) void {
2323 if (actual_error_union) |actual_payload| {
2424 std.debug.panic("expected error.{}, found {}", .{ @errorName(expected_error), actual_payload });
2525 } else |actual_error| {
......@@ -36,7 +36,7 @@ pub fn expectError(expected_error: anyerror, actual_error_union: var) void {
3636/// equal, prints diagnostics to stderr to show exactly how they are not equal,
3737/// then aborts.
3838/// The types must match exactly.
39pub fn expectEqual(expected: var, actual: @TypeOf(expected)) void {
39pub fn expectEqual(expected: anytype, actual: @TypeOf(expected)) void {
4040 switch (@typeInfo(@TypeOf(actual))) {
4141 .NoReturn,
4242 .BoundFn,
lib/std/thread.zig+1-1
......@@ -143,7 +143,7 @@ pub const Thread = struct {
143143 /// fn startFn(@TypeOf(context)) T
144144 /// where T is u8, noreturn, void, or !void
145145 /// caller must call wait on the returned thread
146 pub fn spawn(context: var, comptime startFn: var) SpawnError!*Thread {
146 pub fn spawn(context: anytype, comptime startFn: anytype) SpawnError!*Thread {
147147 if (builtin.single_threaded) @compileError("cannot spawn thread when building in single-threaded mode");
148148 // TODO compile-time call graph analysis to determine stack upper bound
149149 // https://github.com/ziglang/zig/issues/157
lib/std/zig/ast.zig+20-20
......@@ -29,7 +29,7 @@ pub const Tree = struct {
2929 self.arena.promote(self.gpa).deinit();
3030 }
3131
32 pub fn renderError(self: *Tree, parse_error: *const Error, stream: var) !void {
32 pub fn renderError(self: *Tree, parse_error: *const Error, stream: anytype) !void {
3333 return parse_error.render(self.token_ids, stream);
3434 }
3535
......@@ -167,7 +167,7 @@ pub const Error = union(enum) {
167167 DeclBetweenFields: DeclBetweenFields,
168168 InvalidAnd: InvalidAnd,
169169
170 pub fn render(self: *const Error, tokens: []const Token.Id, stream: var) !void {
170 pub fn render(self: *const Error, tokens: []const Token.Id, stream: anytype) !void {
171171 switch (self.*) {
172172 .InvalidToken => |*x| return x.render(tokens, stream),
173173 .ExpectedContainerMembers => |*x| return x.render(tokens, stream),
......@@ -322,7 +322,7 @@ pub const Error = union(enum) {
322322 pub const ExpectedCall = struct {
323323 node: *Node,
324324
325 pub fn render(self: *const ExpectedCall, tokens: []const Token.Id, stream: var) !void {
325 pub fn render(self: *const ExpectedCall, tokens: []const Token.Id, stream: anytype) !void {
326326 return stream.print("expected " ++ @tagName(Node.Id.Call) ++ ", found {}", .{
327327 @tagName(self.node.id),
328328 });
......@@ -332,7 +332,7 @@ pub const Error = union(enum) {
332332 pub const ExpectedCallOrFnProto = struct {
333333 node: *Node,
334334
335 pub fn render(self: *const ExpectedCallOrFnProto, tokens: []const Token.Id, stream: var) !void {
335 pub fn render(self: *const ExpectedCallOrFnProto, tokens: []const Token.Id, stream: anytype) !void {
336336 return stream.print("expected " ++ @tagName(Node.Id.Call) ++ " or " ++
337337 @tagName(Node.Id.FnProto) ++ ", found {}", .{@tagName(self.node.id)});
338338 }
......@@ -342,7 +342,7 @@ pub const Error = union(enum) {
342342 token: TokenIndex,
343343 expected_id: Token.Id,
344344
345 pub fn render(self: *const ExpectedToken, tokens: []const Token.Id, stream: var) !void {
345 pub fn render(self: *const ExpectedToken, tokens: []const Token.Id, stream: anytype) !void {
346346 const found_token = tokens[self.token];
347347 switch (found_token) {
348348 .Invalid => {
......@@ -360,7 +360,7 @@ pub const Error = union(enum) {
360360 token: TokenIndex,
361361 end_id: Token.Id,
362362
363 pub fn render(self: *const ExpectedCommaOrEnd, tokens: []const Token.Id, stream: var) !void {
363 pub fn render(self: *const ExpectedCommaOrEnd, tokens: []const Token.Id, stream: anytype) !void {
364364 const actual_token = tokens[self.token];
365365 return stream.print("expected ',' or '{}', found '{}'", .{
366366 self.end_id.symbol(),
......@@ -375,7 +375,7 @@ pub const Error = union(enum) {
375375
376376 token: TokenIndex,
377377
378 pub fn render(self: *const ThisError, tokens: []const Token.Id, stream: var) !void {
378 pub fn render(self: *const ThisError, tokens: []const Token.Id, stream: anytype) !void {
379379 const actual_token = tokens[self.token];
380380 return stream.print(msg, .{actual_token.symbol()});
381381 }
......@@ -388,7 +388,7 @@ pub const Error = union(enum) {
388388
389389 token: TokenIndex,
390390
391 pub fn render(self: *const ThisError, tokens: []const Token.Id, stream: var) !void {
391 pub fn render(self: *const ThisError, tokens: []const Token.Id, stream: anytype) !void {
392392 return stream.writeAll(msg);
393393 }
394394 };
......@@ -434,7 +434,7 @@ pub const Node = struct {
434434 Suspend,
435435
436436 // Type expressions
437 VarType,
437 AnyType,
438438 ErrorType,
439439 FnProto,
440440 AnyFrameType,
......@@ -993,7 +993,7 @@ pub const Node = struct {
993993 param_type: ParamType,
994994
995995 pub const ParamType = union(enum) {
996 var_type: *Node,
996 any_type: *Node,
997997 var_args: TokenIndex,
998998 type_expr: *Node,
999999 };
......@@ -1004,7 +1004,7 @@ pub const Node = struct {
10041004 if (i < 1) {
10051005 switch (self.param_type) {
10061006 .var_args => return null,
1007 .var_type, .type_expr => |node| return node,
1007 .any_type, .type_expr => |node| return node,
10081008 }
10091009 }
10101010 i -= 1;
......@@ -1018,14 +1018,14 @@ pub const Node = struct {
10181018 if (self.name_token) |name_token| return name_token;
10191019 switch (self.param_type) {
10201020 .var_args => |tok| return tok,
1021 .var_type, .type_expr => |node| return node.firstToken(),
1021 .any_type, .type_expr => |node| return node.firstToken(),
10221022 }
10231023 }
10241024
10251025 pub fn lastToken(self: *const ParamDecl) TokenIndex {
10261026 switch (self.param_type) {
10271027 .var_args => |tok| return tok,
1028 .var_type, .type_expr => |node| return node.lastToken(),
1028 .any_type, .type_expr => |node| return node.lastToken(),
10291029 }
10301030 }
10311031 };
......@@ -1052,12 +1052,12 @@ pub const Node = struct {
10521052 const params_len: usize = if (self.params_len == 0)
10531053 0
10541054 else switch (self.paramsConst()[self.params_len - 1].param_type) {
1055 .var_type, .type_expr => self.params_len,
1055 .any_type, .type_expr => self.params_len,
10561056 .var_args => self.params_len - 1,
10571057 };
10581058 if (i < params_len) {
10591059 switch (self.paramsConst()[i].param_type) {
1060 .var_type => |n| return n,
1060 .any_type => |n| return n,
10611061 .var_args => unreachable,
10621062 .type_expr => |n| return n,
10631063 }
......@@ -2732,19 +2732,19 @@ pub const Node = struct {
27322732 }
27332733 };
27342734
2735 pub const VarType = struct {
2736 base: Node = Node{ .id = .VarType },
2735 pub const AnyType = struct {
2736 base: Node = Node{ .id = .AnyType },
27372737 token: TokenIndex,
27382738
2739 pub fn iterate(self: *const VarType, index: usize) ?*Node {
2739 pub fn iterate(self: *const AnyType, index: usize) ?*Node {
27402740 return null;
27412741 }
27422742
2743 pub fn firstToken(self: *const VarType) TokenIndex {
2743 pub fn firstToken(self: *const AnyType) TokenIndex {
27442744 return self.token;
27452745 }
27462746
2747 pub fn lastToken(self: *const VarType) TokenIndex {
2747 pub fn lastToken(self: *const AnyType) TokenIndex {
27482748 return self.token;
27492749 }
27502750 };
lib/std/zig/parse.zig+12-11
......@@ -488,7 +488,7 @@ const Parser = struct {
488488 return p.parseUse();
489489 }
490490
491 /// FnProto <- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_var / TypeExpr)
491 /// FnProto <- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (Keyword_anytype / TypeExpr)
492492 fn parseFnProto(p: *Parser) !?*Node {
493493 // TODO: Remove once extern/async fn rewriting is
494494 var is_async = false;
......@@ -519,7 +519,7 @@ const Parser = struct {
519519 const callconv_expr = try p.parseCallconv();
520520 const exclamation_token = p.eatToken(.Bang);
521521
522 const return_type_expr = (try p.parseVarType()) orelse
522 const return_type_expr = (try p.parseAnyType()) orelse
523523 try p.expectNodeRecoverable(parseTypeExpr, .{
524524 // most likely the user forgot to specify the return type.
525525 // Mark return type as invalid and try to continue.
......@@ -618,9 +618,9 @@ const Parser = struct {
618618 var align_expr: ?*Node = null;
619619 var type_expr: ?*Node = null;
620620 if (p.eatToken(.Colon)) |_| {
621 if (p.eatToken(.Keyword_var)) |var_tok| {
622 const node = try p.arena.allocator.create(Node.VarType);
623 node.* = .{ .token = var_tok };
621 if (p.eatToken(.Keyword_anytype) orelse p.eatToken(.Keyword_var)) |anytype_tok| {
622 const node = try p.arena.allocator.create(Node.AnyType);
623 node.* = .{ .token = anytype_tok };
624624 type_expr = &node.base;
625625 } else {
626626 type_expr = try p.expectNode(parseTypeExpr, .{
......@@ -2022,13 +2022,13 @@ const Parser = struct {
20222022 }
20232023
20242024 /// ParamType
2025 /// <- KEYWORD_var
2025 /// <- Keyword_anytype
20262026 /// / DOT3
20272027 /// / TypeExpr
20282028 fn parseParamType(p: *Parser) !?Node.FnProto.ParamDecl.ParamType {
20292029 // TODO cast from tuple to error union is broken
20302030 const P = Node.FnProto.ParamDecl.ParamType;
2031 if (try p.parseVarType()) |node| return P{ .var_type = node };
2031 if (try p.parseAnyType()) |node| return P{ .any_type = node };
20322032 if (p.eatToken(.Ellipsis3)) |token| return P{ .var_args = token };
20332033 if (try p.parseTypeExpr()) |node| return P{ .type_expr = node };
20342034 return null;
......@@ -2955,7 +2955,7 @@ const Parser = struct {
29552955
29562956 const NodeParseFn = fn (p: *Parser) Error!?*Node;
29572957
2958 fn ListParseFn(comptime E: type, comptime nodeParseFn: var) ParseFn([]E) {
2958 fn ListParseFn(comptime E: type, comptime nodeParseFn: anytype) ParseFn([]E) {
29592959 return struct {
29602960 pub fn parse(p: *Parser) ![]E {
29612961 var list = std.ArrayList(E).init(p.gpa);
......@@ -3057,9 +3057,10 @@ const Parser = struct {
30573057 return &node.base;
30583058 }
30593059
3060 fn parseVarType(p: *Parser) !?*Node {
3061 const token = p.eatToken(.Keyword_var) orelse return null;
3062 const node = try p.arena.allocator.create(Node.VarType);
3060 fn parseAnyType(p: *Parser) !?*Node {
3061 const token = p.eatToken(.Keyword_anytype) orelse
3062 p.eatToken(.Keyword_var) orelse return null; // TODO remove in next release cycle
3063 const node = try p.arena.allocator.create(Node.AnyType);
30633064 node.* = .{
30643065 .token = token,
30653066 };
lib/std/zig/parser_test.zig+21-5
......@@ -422,10 +422,10 @@ test "zig fmt: asm expression with comptime content" {
422422 );
423423}
424424
425test "zig fmt: var struct field" {
425test "zig fmt: anytype struct field" {
426426 try testCanonical(
427427 \\pub const Pointer = struct {
428 \\ sentinel: var,
428 \\ sentinel: anytype,
429429 \\};
430430 \\
431431 );
......@@ -1932,7 +1932,7 @@ test "zig fmt: preserve spacing" {
19321932test "zig fmt: return types" {
19331933 try testCanonical(
19341934 \\pub fn main() !void {}
1935 \\pub fn main() var {}
1935 \\pub fn main() anytype {}
19361936 \\pub fn main() i32 {}
19371937 \\
19381938 );
......@@ -2140,9 +2140,9 @@ test "zig fmt: call expression" {
21402140 );
21412141}
21422142
2143test "zig fmt: var type" {
2143test "zig fmt: anytype type" {
21442144 try testCanonical(
2145 \\fn print(args: var) var {}
2145 \\fn print(args: anytype) anytype {}
21462146 \\
21472147 );
21482148}
......@@ -3180,6 +3180,22 @@ test "zig fmt: convert extern fn proto into callconv(.C)" {
31803180 );
31813181}
31823182
3183test "zig fmt: convert var to anytype" {
3184 // TODO remove in next release cycle
3185 try testTransform(
3186 \\pub fn main(
3187 \\ a: var,
3188 \\ bar: var,
3189 \\) void {}
3190 ,
3191 \\pub fn main(
3192 \\ a: anytype,
3193 \\ bar: anytype,
3194 \\) void {}
3195 \\
3196 );
3197}
3198
31833199const std = @import("std");
31843200const mem = std.mem;
31853201const warn = std.debug.warn;
lib/std/zig/render.zig+28-22
......@@ -12,7 +12,7 @@ pub const Error = error{
1212};
1313
1414/// Returns whether anything changed
15pub fn render(allocator: *mem.Allocator, stream: var, tree: *ast.Tree) (@TypeOf(stream).Error || Error)!bool {
15pub fn render(allocator: *mem.Allocator, stream: anytype, tree: *ast.Tree) (@TypeOf(stream).Error || Error)!bool {
1616 // cannot render an invalid tree
1717 std.debug.assert(tree.errors.len == 0);
1818
......@@ -64,7 +64,7 @@ pub fn render(allocator: *mem.Allocator, stream: var, tree: *ast.Tree) (@TypeOf(
6464
6565fn renderRoot(
6666 allocator: *mem.Allocator,
67 stream: var,
67 stream: anytype,
6868 tree: *ast.Tree,
6969) (@TypeOf(stream).Error || Error)!void {
7070 // render all the line comments at the beginning of the file
......@@ -191,13 +191,13 @@ fn renderRoot(
191191 }
192192}
193193
194fn renderExtraNewline(tree: *ast.Tree, stream: var, start_col: *usize, node: *ast.Node) @TypeOf(stream).Error!void {
194fn renderExtraNewline(tree: *ast.Tree, stream: anytype, start_col: *usize, node: *ast.Node) @TypeOf(stream).Error!void {
195195 return renderExtraNewlineToken(tree, stream, start_col, node.firstToken());
196196}
197197
198198fn renderExtraNewlineToken(
199199 tree: *ast.Tree,
200 stream: var,
200 stream: anytype,
201201 start_col: *usize,
202202 first_token: ast.TokenIndex,
203203) @TypeOf(stream).Error!void {
......@@ -218,11 +218,11 @@ fn renderExtraNewlineToken(
218218 }
219219}
220220
221fn renderTopLevelDecl(allocator: *mem.Allocator, stream: var, tree: *ast.Tree, indent: usize, start_col: *usize, decl: *ast.Node) (@TypeOf(stream).Error || Error)!void {
221fn renderTopLevelDecl(allocator: *mem.Allocator, stream: anytype, tree: *ast.Tree, indent: usize, start_col: *usize, decl: *ast.Node) (@TypeOf(stream).Error || Error)!void {
222222 try renderContainerDecl(allocator, stream, tree, indent, start_col, decl, .Newline);
223223}
224224
225fn renderContainerDecl(allocator: *mem.Allocator, stream: var, tree: *ast.Tree, indent: usize, start_col: *usize, decl: *ast.Node, space: Space) (@TypeOf(stream).Error || Error)!void {
225fn renderContainerDecl(allocator: *mem.Allocator, stream: anytype, tree: *ast.Tree, indent: usize, start_col: *usize, decl: *ast.Node, space: Space) (@TypeOf(stream).Error || Error)!void {
226226 switch (decl.id) {
227227 .FnProto => {
228228 const fn_proto = @fieldParentPtr(ast.Node.FnProto, "base", decl);
......@@ -358,7 +358,7 @@ fn renderContainerDecl(allocator: *mem.Allocator, stream: var, tree: *ast.Tree,
358358
359359fn renderExpression(
360360 allocator: *mem.Allocator,
361 stream: var,
361 stream: anytype,
362362 tree: *ast.Tree,
363363 indent: usize,
364364 start_col: *usize,
......@@ -1179,9 +1179,15 @@ fn renderExpression(
11791179 const error_type = @fieldParentPtr(ast.Node.ErrorType, "base", base);
11801180 return renderToken(tree, stream, error_type.token, indent, start_col, space);
11811181 },
1182 .VarType => {
1183 const var_type = @fieldParentPtr(ast.Node.VarType, "base", base);
1184 return renderToken(tree, stream, var_type.token, indent, start_col, space);
1182 .AnyType => {
1183 const any_type = @fieldParentPtr(ast.Node.AnyType, "base", base);
1184 if (mem.eql(u8, tree.tokenSlice(any_type.token), "var")) {
1185 // TODO remove in next release cycle
1186 try stream.writeAll("anytype");
1187 if (space == .Comma) try stream.writeAll(",\n");
1188 return;
1189 }
1190 return renderToken(tree, stream, any_type.token, indent, start_col, space);
11851191 },
11861192 .ContainerDecl => {
11871193 const container_decl = @fieldParentPtr(ast.Node.ContainerDecl, "base", base);
......@@ -2053,7 +2059,7 @@ fn renderExpression(
20532059
20542060fn renderAsmOutput(
20552061 allocator: *mem.Allocator,
2056 stream: var,
2062 stream: anytype,
20572063 tree: *ast.Tree,
20582064 indent: usize,
20592065 start_col: *usize,
......@@ -2081,7 +2087,7 @@ fn renderAsmOutput(
20812087
20822088fn renderAsmInput(
20832089 allocator: *mem.Allocator,
2084 stream: var,
2090 stream: anytype,
20852091 tree: *ast.Tree,
20862092 indent: usize,
20872093 start_col: *usize,
......@@ -2099,7 +2105,7 @@ fn renderAsmInput(
20992105
21002106fn renderVarDecl(
21012107 allocator: *mem.Allocator,
2102 stream: var,
2108 stream: anytype,
21032109 tree: *ast.Tree,
21042110 indent: usize,
21052111 start_col: *usize,
......@@ -2171,7 +2177,7 @@ fn renderVarDecl(
21712177
21722178fn renderParamDecl(
21732179 allocator: *mem.Allocator,
2174 stream: var,
2180 stream: anytype,
21752181 tree: *ast.Tree,
21762182 indent: usize,
21772183 start_col: *usize,
......@@ -2192,13 +2198,13 @@ fn renderParamDecl(
21922198 }
21932199 switch (param_decl.param_type) {
21942200 .var_args => |token| try renderToken(tree, stream, token, indent, start_col, space),
2195 .var_type, .type_expr => |node| try renderExpression(allocator, stream, tree, indent, start_col, node, space),
2201 .any_type, .type_expr => |node| try renderExpression(allocator, stream, tree, indent, start_col, node, space),
21962202 }
21972203}
21982204
21992205fn renderStatement(
22002206 allocator: *mem.Allocator,
2201 stream: var,
2207 stream: anytype,
22022208 tree: *ast.Tree,
22032209 indent: usize,
22042210 start_col: *usize,
......@@ -2236,7 +2242,7 @@ const Space = enum {
22362242
22372243fn renderTokenOffset(
22382244 tree: *ast.Tree,
2239 stream: var,
2245 stream: anytype,
22402246 token_index: ast.TokenIndex,
22412247 indent: usize,
22422248 start_col: *usize,
......@@ -2434,7 +2440,7 @@ fn renderTokenOffset(
24342440
24352441fn renderToken(
24362442 tree: *ast.Tree,
2437 stream: var,
2443 stream: anytype,
24382444 token_index: ast.TokenIndex,
24392445 indent: usize,
24402446 start_col: *usize,
......@@ -2445,8 +2451,8 @@ fn renderToken(
24452451
24462452fn renderDocComments(
24472453 tree: *ast.Tree,
2448 stream: var,
2449 node: var,
2454 stream: anytype,
2455 node: anytype,
24502456 indent: usize,
24512457 start_col: *usize,
24522458) (@TypeOf(stream).Error || Error)!void {
......@@ -2456,7 +2462,7 @@ fn renderDocComments(
24562462
24572463fn renderDocCommentsToken(
24582464 tree: *ast.Tree,
2459 stream: var,
2465 stream: anytype,
24602466 comment: *ast.Node.DocComment,
24612467 first_token: ast.TokenIndex,
24622468 indent: usize,
......@@ -2532,7 +2538,7 @@ const FindByteOutStream = struct {
25322538 }
25332539};
25342540
2535fn copyFixingWhitespace(stream: var, slice: []const u8) @TypeOf(stream).Error!void {
2541fn copyFixingWhitespace(stream: anytype, slice: []const u8) @TypeOf(stream).Error!void {
25362542 for (slice) |byte| switch (byte) {
25372543 '\t' => try stream.writeAll(" "),
25382544 '\r' => {},
lib/std/zig/string_literal.zig+1-1
......@@ -125,7 +125,7 @@ test "parse" {
125125}
126126
127127/// Writes a Zig-syntax escaped string literal to the stream. Includes the double quotes.
128pub fn render(utf8: []const u8, out_stream: var) !void {
128pub fn render(utf8: []const u8, out_stream: anytype) !void {
129129 try out_stream.writeByte('"');
130130 for (utf8) |byte| switch (byte) {
131131 '\n' => try out_stream.writeAll("\\n"),
lib/std/zig/system.zig+4-4
......@@ -130,7 +130,7 @@ pub const NativePaths = struct {
130130 return self.appendArray(&self.include_dirs, s);
131131 }
132132
133 pub fn addIncludeDirFmt(self: *NativePaths, comptime fmt: []const u8, args: var) !void {
133 pub fn addIncludeDirFmt(self: *NativePaths, comptime fmt: []const u8, args: anytype) !void {
134134 const item = try std.fmt.allocPrint0(self.include_dirs.allocator, fmt, args);
135135 errdefer self.include_dirs.allocator.free(item);
136136 try self.include_dirs.append(item);
......@@ -140,7 +140,7 @@ pub const NativePaths = struct {
140140 return self.appendArray(&self.lib_dirs, s);
141141 }
142142
143 pub fn addLibDirFmt(self: *NativePaths, comptime fmt: []const u8, args: var) !void {
143 pub fn addLibDirFmt(self: *NativePaths, comptime fmt: []const u8, args: anytype) !void {
144144 const item = try std.fmt.allocPrint0(self.lib_dirs.allocator, fmt, args);
145145 errdefer self.lib_dirs.allocator.free(item);
146146 try self.lib_dirs.append(item);
......@@ -150,7 +150,7 @@ pub const NativePaths = struct {
150150 return self.appendArray(&self.warnings, s);
151151 }
152152
153 pub fn addWarningFmt(self: *NativePaths, comptime fmt: []const u8, args: var) !void {
153 pub fn addWarningFmt(self: *NativePaths, comptime fmt: []const u8, args: anytype) !void {
154154 const item = try std.fmt.allocPrint0(self.warnings.allocator, fmt, args);
155155 errdefer self.warnings.allocator.free(item);
156156 try self.warnings.append(item);
......@@ -887,7 +887,7 @@ pub const NativeTargetInfo = struct {
887887 abi: Target.Abi,
888888 };
889889
890 pub fn elfInt(is_64: bool, need_bswap: bool, int_32: var, int_64: var) @TypeOf(int_64) {
890 pub fn elfInt(is_64: bool, need_bswap: bool, int_32: anytype, int_64: anytype) @TypeOf(int_64) {
891891 if (is_64) {
892892 if (need_bswap) {
893893 return @byteSwap(@TypeOf(int_64), int_64);
lib/std/zig/tokenizer.zig+4-1
......@@ -15,6 +15,7 @@ pub const Token = struct {
1515 .{ "allowzero", .Keyword_allowzero },
1616 .{ "and", .Keyword_and },
1717 .{ "anyframe", .Keyword_anyframe },
18 .{ "anytype", .Keyword_anytype },
1819 .{ "asm", .Keyword_asm },
1920 .{ "async", .Keyword_async },
2021 .{ "await", .Keyword_await },
......@@ -140,6 +141,8 @@ pub const Token = struct {
140141 Keyword_align,
141142 Keyword_allowzero,
142143 Keyword_and,
144 Keyword_anyframe,
145 Keyword_anytype,
143146 Keyword_asm,
144147 Keyword_async,
145148 Keyword_await,
......@@ -168,7 +171,6 @@ pub const Token = struct {
168171 Keyword_or,
169172 Keyword_orelse,
170173 Keyword_packed,
171 Keyword_anyframe,
172174 Keyword_pub,
173175 Keyword_resume,
174176 Keyword_return,
......@@ -263,6 +265,7 @@ pub const Token = struct {
263265 .Keyword_allowzero => "allowzero",
264266 .Keyword_and => "and",
265267 .Keyword_anyframe => "anyframe",
268 .Keyword_anytype => "anytype",
266269 .Keyword_asm => "asm",
267270 .Keyword_async => "async",
268271 .Keyword_await => "await",
src-self-hosted/Module.zig+6-6
......@@ -1132,7 +1132,7 @@ fn astGenAndAnalyzeDecl(self: *Module, decl: *Decl) !bool {
11321132 const param_types = try fn_type_scope.arena.alloc(*zir.Inst, param_decls.len);
11331133 for (param_decls) |param_decl, i| {
11341134 const param_type_node = switch (param_decl.param_type) {
1135 .var_type => |node| return self.failNode(&fn_type_scope.base, node, "TODO implement anytype parameter", .{}),
1135 .any_type => |node| return self.failNode(&fn_type_scope.base, node, "TODO implement anytype parameter", .{}),
11361136 .var_args => |tok| return self.failTok(&fn_type_scope.base, tok, "TODO implement var args", .{}),
11371137 .type_expr => |node| node,
11381138 };
......@@ -3575,7 +3575,7 @@ fn coerceArrayPtrToSlice(self: *Module, scope: *Scope, dest_type: Type, inst: *I
35753575 return self.fail(scope, inst.src, "TODO implement coerceArrayPtrToSlice runtime instruction", .{});
35763576}
35773577
3578fn fail(self: *Module, scope: *Scope, src: usize, comptime format: []const u8, args: var) InnerError {
3578fn fail(self: *Module, scope: *Scope, src: usize, comptime format: []const u8, args: anytype) InnerError {
35793579 @setCold(true);
35803580 const err_msg = try ErrorMsg.create(self.gpa, src, format, args);
35813581 return self.failWithOwnedErrorMsg(scope, src, err_msg);
......@@ -3586,7 +3586,7 @@ fn failTok(
35863586 scope: *Scope,
35873587 token_index: ast.TokenIndex,
35883588 comptime format: []const u8,
3589 args: var,
3589 args: anytype,
35903590) InnerError {
35913591 @setCold(true);
35923592 const src = scope.tree().token_locs[token_index].start;
......@@ -3598,7 +3598,7 @@ fn failNode(
35983598 scope: *Scope,
35993599 ast_node: *ast.Node,
36003600 comptime format: []const u8,
3601 args: var,
3601 args: anytype,
36023602) InnerError {
36033603 @setCold(true);
36043604 const src = scope.tree().token_locs[ast_node.firstToken()].start;
......@@ -3662,7 +3662,7 @@ pub const ErrorMsg = struct {
36623662 byte_offset: usize,
36633663 msg: []const u8,
36643664
3665 pub fn create(gpa: *Allocator, byte_offset: usize, comptime format: []const u8, args: var) !*ErrorMsg {
3665 pub fn create(gpa: *Allocator, byte_offset: usize, comptime format: []const u8, args: anytype) !*ErrorMsg {
36663666 const self = try gpa.create(ErrorMsg);
36673667 errdefer gpa.destroy(self);
36683668 self.* = try init(gpa, byte_offset, format, args);
......@@ -3675,7 +3675,7 @@ pub const ErrorMsg = struct {
36753675 gpa.destroy(self);
36763676 }
36773677
3678 pub fn init(gpa: *Allocator, byte_offset: usize, comptime format: []const u8, args: var) !ErrorMsg {
3678 pub fn init(gpa: *Allocator, byte_offset: usize, comptime format: []const u8, args: anytype) !ErrorMsg {
36793679 return ErrorMsg{
36803680 .byte_offset = byte_offset,
36813681 .msg = try std.fmt.allocPrint(gpa, format, args),
src-self-hosted/codegen.zig+11-10
......@@ -230,7 +230,7 @@ pub fn generateSymbol(
230230 }
231231}
232232
233const InnerError = error {
233const InnerError = error{
234234 OutOfMemory,
235235 CodegenFail,
236236};
......@@ -673,9 +673,9 @@ const Function = struct {
673673 try self.genX8664BinMathCode(inst.base.src, dst_mcv, src_mcv, 7, 0x38);
674674 const info = inst.args.lhs.ty.intInfo(self.target.*);
675675 if (info.signed) {
676 return MCValue{.compare_flags_signed = inst.args.op};
676 return MCValue{ .compare_flags_signed = inst.args.op };
677677 } else {
678 return MCValue{.compare_flags_unsigned = inst.args.op};
678 return MCValue{ .compare_flags_unsigned = inst.args.op };
679679 }
680680 },
681681 else => return self.fail(inst.base.src, "TODO implement cmp for {}", .{self.target.cpu.arch}),
......@@ -721,7 +721,7 @@ const Function = struct {
721721 }
722722
723723 fn genX86CondBr(self: *Function, inst: *ir.Inst.CondBr, opcode: u8, comptime arch: std.Target.Cpu.Arch) !MCValue {
724 self.code.appendSliceAssumeCapacity(&[_]u8{0x0f, opcode});
724 self.code.appendSliceAssumeCapacity(&[_]u8{ 0x0f, opcode });
725725 const reloc = Reloc{ .rel32 = self.code.items.len };
726726 self.code.items.len += 4;
727727 try self.genBody(inst.args.true_body, arch);
......@@ -1081,10 +1081,12 @@ const Function = struct {
10811081 switch (mcv) {
10821082 .immediate => |imm| {
10831083 // This immediate is unsigned.
1084 const U = @Type(.{ .Int = .{
1085 .bits = ti.bits - @boolToInt(ti.is_signed),
1086 .is_signed = false,
1087 }});
1084 const U = @Type(.{
1085 .Int = .{
1086 .bits = ti.bits - @boolToInt(ti.is_signed),
1087 .is_signed = false,
1088 },
1089 });
10881090 if (imm >= std.math.maxInt(U)) {
10891091 return self.copyToNewRegister(inst);
10901092 }
......@@ -1094,7 +1096,6 @@ const Function = struct {
10941096 return mcv;
10951097 }
10961098
1097
10981099 fn genTypedValue(self: *Function, src: usize, typed_value: TypedValue) !MCValue {
10991100 const ptr_bits = self.target.cpu.arch.ptrBitWidth();
11001101 const ptr_bytes: u64 = @divExact(ptr_bits, 8);
......@@ -1121,7 +1122,7 @@ const Function = struct {
11211122 }
11221123 }
11231124
1124 fn fail(self: *Function, src: usize, comptime format: []const u8, args: var) error{ CodegenFail, OutOfMemory } {
1125 fn fail(self: *Function, src: usize, comptime format: []const u8, args: anytype) error{ CodegenFail, OutOfMemory } {
11251126 @setCold(true);
11261127 assert(self.err_msg == null);
11271128 self.err_msg = try ErrorMsg.create(self.bin_file.allocator, src, format, args);
src-self-hosted/dep_tokenizer.zig+13-13
......@@ -299,12 +299,12 @@ pub const Tokenizer = struct {
299299 return null;
300300 }
301301
302 fn errorf(self: *Tokenizer, comptime fmt: []const u8, args: var) Error {
302 fn errorf(self: *Tokenizer, comptime fmt: []const u8, args: anytype) Error {
303303 self.error_text = try std.fmt.allocPrintZ(&self.arena.allocator, fmt, args);
304304 return Error.InvalidInput;
305305 }
306306
307 fn errorPosition(self: *Tokenizer, position: usize, bytes: []const u8, comptime fmt: []const u8, args: var) Error {
307 fn errorPosition(self: *Tokenizer, position: usize, bytes: []const u8, comptime fmt: []const u8, args: anytype) Error {
308308 var buffer = try std.ArrayListSentineled(u8, 0).initSize(&self.arena.allocator, 0);
309309 try buffer.outStream().print(fmt, args);
310310 try buffer.appendSlice(" '");
......@@ -316,7 +316,7 @@ pub const Tokenizer = struct {
316316 return Error.InvalidInput;
317317 }
318318
319 fn errorIllegalChar(self: *Tokenizer, position: usize, char: u8, comptime fmt: []const u8, args: var) Error {
319 fn errorIllegalChar(self: *Tokenizer, position: usize, char: u8, comptime fmt: []const u8, args: anytype) Error {
320320 var buffer = try std.ArrayListSentineled(u8, 0).initSize(&self.arena.allocator, 0);
321321 try buffer.appendSlice("illegal char ");
322322 try printUnderstandableChar(&buffer, char);
......@@ -883,7 +883,7 @@ fn depTokenizer(input: []const u8, expect: []const u8) !void {
883883 testing.expect(false);
884884}
885885
886fn printSection(out: var, label: []const u8, bytes: []const u8) !void {
886fn printSection(out: anytype, label: []const u8, bytes: []const u8) !void {
887887 try printLabel(out, label, bytes);
888888 try hexDump(out, bytes);
889889 try printRuler(out);
......@@ -891,7 +891,7 @@ fn printSection(out: var, label: []const u8, bytes: []const u8) !void {
891891 try out.write("\n");
892892}
893893
894fn printLabel(out: var, label: []const u8, bytes: []const u8) !void {
894fn printLabel(out: anytype, label: []const u8, bytes: []const u8) !void {
895895 var buf: [80]u8 = undefined;
896896 var text = try std.fmt.bufPrint(buf[0..], "{} {} bytes ", .{ label, bytes.len });
897897 try out.write(text);
......@@ -903,7 +903,7 @@ fn printLabel(out: var, label: []const u8, bytes: []const u8) !void {
903903 try out.write("\n");
904904}
905905
906fn printRuler(out: var) !void {
906fn printRuler(out: anytype) !void {
907907 var i: usize = 0;
908908 const end = 79;
909909 while (i < 79) : (i += 1) {
......@@ -912,7 +912,7 @@ fn printRuler(out: var) !void {
912912 try out.write("\n");
913913}
914914
915fn hexDump(out: var, bytes: []const u8) !void {
915fn hexDump(out: anytype, bytes: []const u8) !void {
916916 const n16 = bytes.len >> 4;
917917 var line: usize = 0;
918918 var offset: usize = 0;
......@@ -959,7 +959,7 @@ fn hexDump(out: var, bytes: []const u8) !void {
959959 try out.write("\n");
960960}
961961
962fn hexDump16(out: var, offset: usize, bytes: []const u8) !void {
962fn hexDump16(out: anytype, offset: usize, bytes: []const u8) !void {
963963 try printDecValue(out, offset, 8);
964964 try out.write(":");
965965 try out.write(" ");
......@@ -977,19 +977,19 @@ fn hexDump16(out: var, offset: usize, bytes: []const u8) !void {
977977 try out.write("|\n");
978978}
979979
980fn printDecValue(out: var, value: u64, width: u8) !void {
980fn printDecValue(out: anytype, value: u64, width: u8) !void {
981981 var buffer: [20]u8 = undefined;
982982 const len = std.fmt.formatIntBuf(buffer[0..], value, 10, false, width);
983983 try out.write(buffer[0..len]);
984984}
985985
986fn printHexValue(out: var, value: u64, width: u8) !void {
986fn printHexValue(out: anytype, value: u64, width: u8) !void {
987987 var buffer: [16]u8 = undefined;
988988 const len = std.fmt.formatIntBuf(buffer[0..], value, 16, false, width);
989989 try out.write(buffer[0..len]);
990990}
991991
992fn printCharValues(out: var, bytes: []const u8) !void {
992fn printCharValues(out: anytype, bytes: []const u8) !void {
993993 for (bytes) |b| {
994994 try out.write(&[_]u8{printable_char_tab[b]});
995995 }
......@@ -1020,13 +1020,13 @@ comptime {
10201020// output: must be a function that takes a `self` idiom parameter
10211021// and a bytes parameter
10221022// context: must be that self
1023fn makeOutput(comptime output: var, context: var) Output(output, @TypeOf(context)) {
1023fn makeOutput(comptime output: anytype, context: anytype) Output(output, @TypeOf(context)) {
10241024 return Output(output, @TypeOf(context)){
10251025 .context = context,
10261026 };
10271027}
10281028
1029fn Output(comptime output_func: var, comptime Context: type) type {
1029fn Output(comptime output_func: anytype, comptime Context: type) type {
10301030 return struct {
10311031 context: Context,
10321032
src-self-hosted/ir.zig+1-1
......@@ -13,7 +13,7 @@ const codegen = @import("codegen.zig");
1313pub const Inst = struct {
1414 tag: Tag,
1515 /// Each bit represents the index of an `Inst` parameter in the `args` field.
16 /// If a bit is set, it marks the end of the lifetime of the corresponding
16 /// If a bit is set, it marks the end of the lifetime of the corresponding
1717 /// instruction parameter. For example, 0b000_00101 means that the first and
1818 /// third `Inst` parameters' lifetimes end after this instruction, and will
1919 /// not have any more following references.
src-self-hosted/libc_installation.zig+2-2
......@@ -37,7 +37,7 @@ pub const LibCInstallation = struct {
3737 pub fn parse(
3838 allocator: *Allocator,
3939 libc_file: []const u8,
40 stderr: var,
40 stderr: anytype,
4141 ) !LibCInstallation {
4242 var self: LibCInstallation = .{};
4343
......@@ -115,7 +115,7 @@ pub const LibCInstallation = struct {
115115 return self;
116116 }
117117
118 pub fn render(self: LibCInstallation, out: var) !void {
118 pub fn render(self: LibCInstallation, out: anytype) !void {
119119 @setEvalBranchQuota(4000);
120120 const include_dir = self.include_dir orelse "";
121121 const sys_include_dir = self.sys_include_dir orelse "";
src-self-hosted/link.zig+4-4
......@@ -244,7 +244,7 @@ pub const File = struct {
244244 need_noreturn: bool = false,
245245 error_msg: *Module.ErrorMsg = undefined,
246246
247 pub fn fail(self: *C, src: usize, comptime format: []const u8, args: var) !void {
247 pub fn fail(self: *C, src: usize, comptime format: []const u8, args: anytype) !void {
248248 self.error_msg = try Module.ErrorMsg.create(self.allocator, src, format, args);
249249 return error.CGenFailure;
250250 }
......@@ -1167,10 +1167,10 @@ pub const File = struct {
11671167 try self.offset_table_free_list.ensureCapacity(self.allocator, self.local_symbols.items.len);
11681168
11691169 if (self.local_symbol_free_list.popOrNull()) |i| {
1170 std.log.debug(.link, "reusing symbol index {} for {}\n", .{i, decl.name});
1170 std.log.debug(.link, "reusing symbol index {} for {}\n", .{ i, decl.name });
11711171 decl.link.local_sym_index = i;
11721172 } else {
1173 std.log.debug(.link, "allocating symbol index {} for {}\n", .{self.local_symbols.items.len, decl.name});
1173 std.log.debug(.link, "allocating symbol index {} for {}\n", .{ self.local_symbols.items.len, decl.name });
11741174 decl.link.local_sym_index = @intCast(u32, self.local_symbols.items.len);
11751175 _ = self.local_symbols.addOneAssumeCapacity();
11761176 }
......@@ -1657,7 +1657,7 @@ fn openBinFileInner(allocator: *Allocator, file: fs.File, options: Options) !Fil
16571657}
16581658
16591659/// Saturating multiplication
1660fn satMul(a: var, b: var) @TypeOf(a, b) {
1660fn satMul(a: anytype, b: anytype) @TypeOf(a, b) {
16611661 const T = @TypeOf(a, b);
16621662 return std.math.mul(T, a, b) catch std.math.maxInt(T);
16631663}
src-self-hosted/liveness.zig+1-1
......@@ -135,5 +135,5 @@ fn analyzeInst(arena: *std.mem.Allocator, table: *std.AutoHashMap(*ir.Inst, void
135135 }
136136 }
137137
138 std.log.debug(.liveness, "analyze {}: 0b{b}\n", .{inst.base.tag, inst.base.deaths});
138 std.log.debug(.liveness, "analyze {}: 0b{b}\n", .{ inst.base.tag, inst.base.deaths });
139139}
src-self-hosted/main.zig+1-1
......@@ -42,7 +42,7 @@ pub fn log(
4242 comptime level: std.log.Level,
4343 comptime scope: @TypeOf(.EnumLiteral),
4444 comptime format: []const u8,
45 args: var,
45 args: anytype,
4646) void {
4747 if (@enumToInt(level) > @enumToInt(std.log.level))
4848 return;
src-self-hosted/print_targets.zig+1-1
......@@ -62,7 +62,7 @@ pub fn cmdTargets(
6262 allocator: *Allocator,
6363 args: []const []const u8,
6464 /// Output stream
65 stdout: var,
65 stdout: anytype,
6666 native_target: Target,
6767) !void {
6868 const available_glibcs = blk: {
src-self-hosted/translate_c.zig+13-14
......@@ -1117,7 +1117,7 @@ fn transEnumDecl(c: *Context, enum_decl: *const ZigClangEnumDecl) Error!?*ast.No
11171117 return transCreateNodeIdentifier(c, name);
11181118}
11191119
1120fn createAlias(c: *Context, alias: var) !void {
1120fn createAlias(c: *Context, alias: anytype) !void {
11211121 const node = try transCreateNodeVarDecl(c, true, true, alias.alias);
11221122 node.eq_token = try appendToken(c, .Equal, "=");
11231123 node.init_node = try transCreateNodeIdentifier(c, alias.name);
......@@ -2161,7 +2161,7 @@ fn transCreateNodeArrayType(
21612161 rp: RestorePoint,
21622162 source_loc: ZigClangSourceLocation,
21632163 ty: *const ZigClangType,
2164 len: var,
2164 len: anytype,
21652165) TransError!*ast.Node {
21662166 var node = try transCreateNodePrefixOp(
21672167 rp.c,
......@@ -4187,7 +4187,7 @@ fn transCreateNodeBoolLiteral(c: *Context, value: bool) !*ast.Node {
41874187 return &node.base;
41884188}
41894189
4190fn transCreateNodeInt(c: *Context, int: var) !*ast.Node {
4190fn transCreateNodeInt(c: *Context, int: anytype) !*ast.Node {
41914191 const token = try appendTokenFmt(c, .IntegerLiteral, "{}", .{int});
41924192 const node = try c.arena.create(ast.Node.IntegerLiteral);
41934193 node.* = .{
......@@ -4196,7 +4196,7 @@ fn transCreateNodeInt(c: *Context, int: var) !*ast.Node {
41964196 return &node.base;
41974197}
41984198
4199fn transCreateNodeFloat(c: *Context, int: var) !*ast.Node {
4199fn transCreateNodeFloat(c: *Context, int: anytype) !*ast.Node {
42004200 const token = try appendTokenFmt(c, .FloatLiteral, "{}", .{int});
42014201 const node = try c.arena.create(ast.Node.FloatLiteral);
42024202 node.* = .{
......@@ -4907,22 +4907,22 @@ fn finishTransFnProto(
49074907
49084908fn revertAndWarn(
49094909 rp: RestorePoint,
4910 err: var,
4910 err: anytype,
49114911 source_loc: ZigClangSourceLocation,
49124912 comptime format: []const u8,
4913 args: var,
4913 args: anytype,
49144914) (@TypeOf(err) || error{OutOfMemory}) {
49154915 rp.activate();
49164916 try emitWarning(rp.c, source_loc, format, args);
49174917 return err;
49184918}
49194919
4920fn emitWarning(c: *Context, loc: ZigClangSourceLocation, comptime format: []const u8, args: var) !void {
4920fn emitWarning(c: *Context, loc: ZigClangSourceLocation, comptime format: []const u8, args: anytype) !void {
49214921 const args_prefix = .{c.locStr(loc)};
49224922 _ = try appendTokenFmt(c, .LineComment, "// {}: warning: " ++ format, args_prefix ++ args);
49234923}
49244924
4925pub fn failDecl(c: *Context, loc: ZigClangSourceLocation, name: []const u8, comptime format: []const u8, args: var) !void {
4925pub fn failDecl(c: *Context, loc: ZigClangSourceLocation, name: []const u8, comptime format: []const u8, args: anytype) !void {
49264926 // pub const name = @compileError(msg);
49274927 const pub_tok = try appendToken(c, .Keyword_pub, "pub");
49284928 const const_tok = try appendToken(c, .Keyword_const, "const");
......@@ -4973,7 +4973,7 @@ fn appendToken(c: *Context, token_id: Token.Id, bytes: []const u8) !ast.TokenInd
49734973 return appendTokenFmt(c, token_id, "{}", .{bytes});
49744974}
49754975
4976fn appendTokenFmt(c: *Context, token_id: Token.Id, comptime format: []const u8, args: var) !ast.TokenIndex {
4976fn appendTokenFmt(c: *Context, token_id: Token.Id, comptime format: []const u8, args: anytype) !ast.TokenIndex {
49774977 assert(token_id != .Invalid);
49784978
49794979 try c.token_ids.ensureCapacity(c.gpa, c.token_ids.items.len + 1);
......@@ -5215,10 +5215,9 @@ fn transMacroFnDefine(c: *Context, it: *CTokenList.Iterator, source: []const u8,
52155215 const param_name_tok = try appendIdentifier(c, mangled_name);
52165216 _ = try appendToken(c, .Colon, ":");
52175217
5218 const token_index = try appendToken(c, .Keyword_var, "var");
5219 const identifier = try c.arena.create(ast.Node.Identifier);
5220 identifier.* = .{
5221 .token = token_index,
5218 const any_type = try c.arena.create(ast.Node.AnyType);
5219 any_type.* = .{
5220 .token = try appendToken(c, .Keyword_anytype, "anytype"),
52225221 };
52235222
52245223 (try fn_params.addOne()).* = .{
......@@ -5226,7 +5225,7 @@ fn transMacroFnDefine(c: *Context, it: *CTokenList.Iterator, source: []const u8,
52265225 .comptime_token = null,
52275226 .noalias_token = null,
52285227 .name_token = param_name_tok,
5229 .param_type = .{ .type_expr = &identifier.base },
5228 .param_type = .{ .any_type = &any_type.base },
52305229 };
52315230
52325231 if (it.peek().?.id != .Comma)
src-self-hosted/type.zig+1-2
......@@ -277,7 +277,7 @@ pub const Type = extern union {
277277 self: Type,
278278 comptime fmt: []const u8,
279279 options: std.fmt.FormatOptions,
280 out_stream: var,
280 out_stream: anytype,
281281 ) @TypeOf(out_stream).Error!void {
282282 comptime assert(fmt.len == 0);
283283 var ty = self;
......@@ -591,7 +591,6 @@ pub const Type = extern union {
591591
592592 .anyerror => return 2, // TODO revisit this when we have the concept of the error tag type
593593
594
595594 .int_signed, .int_unsigned => {
596595 const bits: u16 = if (self.cast(Payload.IntSigned)) |pl|
597596 pl.bits
src-self-hosted/value.zig+1-1
......@@ -227,7 +227,7 @@ pub const Value = extern union {
227227 self: Value,
228228 comptime fmt: []const u8,
229229 options: std.fmt.FormatOptions,
230 out_stream: var,
230 out_stream: anytype,
231231 ) !void {
232232 comptime assert(fmt.len == 0);
233233 var val = self;
src-self-hosted/zir.zig+6-7
......@@ -655,7 +655,7 @@ pub const Module = struct {
655655
656656 /// The allocator is used for temporary storage, but this function always returns
657657 /// with no resources allocated.
658 pub fn writeToStream(self: Module, allocator: *Allocator, stream: var) !void {
658 pub fn writeToStream(self: Module, allocator: *Allocator, stream: anytype) !void {
659659 var write = Writer{
660660 .module = &self,
661661 .inst_table = InstPtrTable.init(allocator),
......@@ -686,7 +686,6 @@ pub const Module = struct {
686686 try stream.writeByte('\n');
687687 }
688688 }
689
690689};
691690
692691const InstPtrTable = std.AutoHashMap(*Inst, struct { inst: *Inst, index: ?usize, name: []const u8 });
......@@ -700,7 +699,7 @@ const Writer = struct {
700699
701700 fn writeInstToStream(
702701 self: *Writer,
703 stream: var,
702 stream: anytype,
704703 inst: *Inst,
705704 ) (@TypeOf(stream).Error || error{OutOfMemory})!void {
706705 // TODO I tried implementing this with an inline for loop and hit a compiler bug
......@@ -746,7 +745,7 @@ const Writer = struct {
746745
747746 fn writeInstToStreamGeneric(
748747 self: *Writer,
749 stream: var,
748 stream: anytype,
750749 comptime inst_tag: Inst.Tag,
751750 base: *Inst,
752751 ) (@TypeOf(stream).Error || error{OutOfMemory})!void {
......@@ -783,7 +782,7 @@ const Writer = struct {
783782 try stream.writeByte(')');
784783 }
785784
786 fn writeParamToStream(self: *Writer, stream: var, param: var) !void {
785 fn writeParamToStream(self: *Writer, stream: anytype, param: anytype) !void {
787786 if (@typeInfo(@TypeOf(param)) == .Enum) {
788787 return stream.writeAll(@tagName(param));
789788 }
......@@ -829,7 +828,7 @@ const Writer = struct {
829828 }
830829 }
831830
832 fn writeInstParamToStream(self: *Writer, stream: var, inst: *Inst) !void {
831 fn writeInstParamToStream(self: *Writer, stream: anytype, inst: *Inst) !void {
833832 if (self.inst_table.get(inst)) |info| {
834833 if (info.index) |i| {
835834 try stream.print("%{}", .{info.index});
......@@ -1062,7 +1061,7 @@ const Parser = struct {
10621061 }
10631062 }
10641063
1065 fn fail(self: *Parser, comptime format: []const u8, args: var) InnerError {
1064 fn fail(self: *Parser, comptime format: []const u8, args: anytype) InnerError {
10661065 @setCold(true);
10671066 self.error_msg = ErrorMsg{
10681067 .byte_offset = self.i,
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+10-10
......@@ -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 }
......@@ -1511,13 +1511,13 @@ ZigType *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
15111511 }
15121512 for (; i < fn_type_id->param_count; i += 1) {
15131513 const char *comma_str = (i == 0) ? "" : ",";
1514 buf_appendf(&fn_type->name, "%svar", comma_str);
1514 buf_appendf(&fn_type->name, "%sanytype", comma_str);
15151515 }
15161516 buf_append_str(&fn_type->name, ")");
15171517 if (fn_type_id->cc != CallingConventionUnspecified) {
15181518 buf_appendf(&fn_type->name, " callconv(.%s)", calling_convention_name(fn_type_id->cc));
15191519 }
1520 buf_append_str(&fn_type->name, " var");
1520 buf_append_str(&fn_type->name, " anytype");
15211521
15221522 fn_type->data.fn.fn_type_id = *fn_type_id;
15231523 fn_type->data.fn.is_generic = true;
......@@ -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,
test/compile_errors.zig+17-17
......@@ -42,7 +42,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
4242 \\fn foo() Foo {
4343 \\ return .{ .x = 42 };
4444 \\}
45 \\fn bar(val: var) Foo {
45 \\fn bar(val: anytype) Foo {
4646 \\ return .{ .x = val };
4747 \\}
4848 \\export fn entry() void {
......@@ -1034,7 +1034,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
10341034 \\ storev(&v[i], 42);
10351035 \\}
10361036 \\
1037 \\fn storev(ptr: var, val: i32) void {
1037 \\fn storev(ptr: anytype, val: i32) void {
10381038 \\ ptr.* = val;
10391039 \\}
10401040 , &[_][]const u8{
......@@ -1049,7 +1049,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
10491049 \\ var x = loadv(&v[i]);
10501050 \\}
10511051 \\
1052 \\fn loadv(ptr: var) i32 {
1052 \\fn loadv(ptr: anytype) i32 {
10531053 \\ return ptr.*;
10541054 \\}
10551055 , &[_][]const u8{
......@@ -1832,7 +1832,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
18321832 \\ while (true) {}
18331833 \\}
18341834 , &[_][]const u8{
1835 "error: expected type 'fn([]const u8, ?*std.builtin.StackTrace) noreturn', found 'fn([]const u8,var) var'",
1835 "error: expected type 'fn([]const u8, ?*std.builtin.StackTrace) noreturn', found 'fn([]const u8,anytype) anytype'",
18361836 "note: only one of the functions is generic",
18371837 });
18381838
......@@ -2032,11 +2032,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
20322032 });
20332033
20342034 cases.add("export generic function",
2035 \\export fn foo(num: var) i32 {
2035 \\export fn foo(num: anytype) i32 {
20362036 \\ return 0;
20372037 \\}
20382038 , &[_][]const u8{
2039 "tmp.zig:1:15: error: parameter of type 'var' not allowed in function with calling convention 'C'",
2039 "tmp.zig:1:15: error: parameter of type 'anytype' not allowed in function with calling convention 'C'",
20402040 });
20412041
20422042 cases.add("C pointer to c_void",
......@@ -2836,7 +2836,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
28362836 });
28372837
28382838 cases.add("missing parameter name of generic function",
2839 \\fn dump(var) void {}
2839 \\fn dump(anytype) void {}
28402840 \\export fn entry() void {
28412841 \\ var a: u8 = 9;
28422842 \\ dump(a);
......@@ -2859,13 +2859,13 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
28592859 });
28602860
28612861 cases.add("generic fn as parameter without comptime keyword",
2862 \\fn f(_: fn (var) void) void {}
2863 \\fn g(_: var) void {}
2862 \\fn f(_: fn (anytype) void) void {}
2863 \\fn g(_: anytype) void {}
28642864 \\export fn entry() void {
28652865 \\ f(g);
28662866 \\}
28672867 , &[_][]const u8{
2868 "tmp.zig:1:9: error: parameter of type 'fn(var) var' must be declared comptime",
2868 "tmp.zig:1:9: error: parameter of type 'fn(anytype) anytype' must be declared comptime",
28692869 });
28702870
28712871 cases.add("optional pointer to void in extern struct",
......@@ -3165,7 +3165,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
31653165
31663166 cases.add("var makes structs required to be comptime known",
31673167 \\export fn entry() void {
3168 \\ const S = struct{v: var};
3168 \\ const S = struct{v: anytype};
31693169 \\ var s = S{.v=@as(i32, 10)};
31703170 \\}
31713171 , &[_][]const u8{
......@@ -6072,10 +6072,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
60726072 });
60736073
60746074 cases.add("calling a generic function only known at runtime",
6075 \\var foos = [_]fn(var) void { foo1, foo2 };
6075 \\var foos = [_]fn(anytype) void { foo1, foo2 };
60766076 \\
6077 \\fn foo1(arg: var) void {}
6078 \\fn foo2(arg: var) void {}
6077 \\fn foo1(arg: anytype) void {}
6078 \\fn foo2(arg: anytype) void {}
60796079 \\
60806080 \\pub fn main() !void {
60816081 \\ foos[0](true);
......@@ -6920,12 +6920,12 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
69206920 });
69216921
69226922 cases.add("getting return type of generic function",
6923 \\fn generic(a: var) void {}
6923 \\fn generic(a: anytype) void {}
69246924 \\comptime {
69256925 \\ _ = @TypeOf(generic).ReturnType;
69266926 \\}
69276927 , &[_][]const u8{
6928 "tmp.zig:3:25: error: ReturnType has not been resolved because 'fn(var) var' is generic",
6928 "tmp.zig:3:25: error: ReturnType has not been resolved because 'fn(anytype) anytype' is generic",
69296929 });
69306930
69316931 cases.add("unsupported modifier at start of asm output constraint",
......@@ -7493,7 +7493,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
74937493 });
74947494
74957495 cases.add("issue #5221: invalid struct init type referenced by @typeInfo and passed into function",
7496 \\fn ignore(comptime param: var) void {}
7496 \\fn ignore(comptime param: anytype) void {}
74977497 \\
74987498 \\export fn foo() void {
74997499 \\ const MyStruct = struct {
test/stage1/behavior/async_fn.zig+5-5
......@@ -1016,7 +1016,7 @@ test "@asyncCall using the result location inside the frame" {
10161016
10171017test "@TypeOf an async function call of generic fn with error union type" {
10181018 const S = struct {
1019 fn func(comptime x: var) anyerror!i32 {
1019 fn func(comptime x: anytype) anyerror!i32 {
10201020 const T = @TypeOf(async func(x));
10211021 comptime expect(T == @TypeOf(@frame()).Child);
10221022 return undefined;
......@@ -1032,7 +1032,7 @@ test "using @TypeOf on a generic function call" {
10321032
10331033 var buf: [100]u8 align(16) = undefined;
10341034
1035 fn amain(x: var) void {
1035 fn amain(x: anytype) void {
10361036 if (x == 0) {
10371037 global_ok = true;
10381038 return;
......@@ -1057,7 +1057,7 @@ test "recursive call of await @asyncCall with struct return type" {
10571057
10581058 var buf: [100]u8 align(16) = undefined;
10591059
1060 fn amain(x: var) Foo {
1060 fn amain(x: anytype) Foo {
10611061 if (x == 0) {
10621062 global_ok = true;
10631063 return Foo{ .x = 1, .y = 2, .z = 3 };
......@@ -1336,7 +1336,7 @@ test "async function passed 0-bit arg after non-0-bit arg" {
13361336 bar(1, .{}) catch unreachable;
13371337 }
13381338
1339 fn bar(x: i32, args: var) anyerror!void {
1339 fn bar(x: i32, args: anytype) anyerror!void {
13401340 global_frame = @frame();
13411341 suspend;
13421342 global_int = x;
......@@ -1357,7 +1357,7 @@ test "async function passed align(16) arg after align(8) arg" {
13571357 bar(10, .{a}) catch unreachable;
13581358 }
13591359
1360 fn bar(x: u64, args: var) anyerror!void {
1360 fn bar(x: u64, args: anytype) anyerror!void {
13611361 expect(x == 10);
13621362 global_frame = @frame();
13631363 suspend;
test/stage1/behavior/bitcast.zig+2-2
......@@ -171,7 +171,7 @@ test "nested bitcast" {
171171
172172test "bitcast passed as tuple element" {
173173 const S = struct {
174 fn foo(args: var) void {
174 fn foo(args: anytype) void {
175175 comptime expect(@TypeOf(args[0]) == f32);
176176 expect(args[0] == 12.34);
177177 }
......@@ -181,7 +181,7 @@ test "bitcast passed as tuple element" {
181181
182182test "triple level result location with bitcast sandwich passed as tuple element" {
183183 const S = struct {
184 fn foo(args: var) void {
184 fn foo(args: anytype) void {
185185 comptime expect(@TypeOf(args[0]) == f64);
186186 expect(args[0] > 12.33 and args[0] < 12.35);
187187 }
test/stage1/behavior/bugs/2114.zig+1-1
......@@ -2,7 +2,7 @@ const std = @import("std");
22const expect = std.testing.expect;
33const math = std.math;
44
5fn ctz(x: var) usize {
5fn ctz(x: anytype) usize {
66 return @ctz(@TypeOf(x), x);
77}
88
test/stage1/behavior/bugs/3742.zig+1-1
......@@ -23,7 +23,7 @@ pub fn isCommand(comptime T: type) bool {
2323}
2424
2525pub const ArgSerializer = struct {
26 pub fn serializeCommand(command: var) void {
26 pub fn serializeCommand(command: anytype) void {
2727 const CmdT = @TypeOf(command);
2828
2929 if (comptime isCommand(CmdT)) {
test/stage1/behavior/bugs/4328.zig+4-4
......@@ -17,11 +17,11 @@ const S = extern struct {
1717
1818test "Extern function calls in @TypeOf" {
1919 const Test = struct {
20 fn test_fn_1(a: var, b: var) @TypeOf(printf("%d %s\n", a, b)) {
20 fn test_fn_1(a: anytype, b: anytype) @TypeOf(printf("%d %s\n", a, b)) {
2121 return 0;
2222 }
2323
24 fn test_fn_2(a: var) @TypeOf((S{ .state = 0 }).s_do_thing(a)) {
24 fn test_fn_2(a: anytype) @TypeOf((S{ .state = 0 }).s_do_thing(a)) {
2525 return 1;
2626 }
2727
......@@ -56,7 +56,7 @@ test "Extern function calls, dereferences and field access in @TypeOf" {
5656 return .{ .dummy_field = 0 };
5757 }
5858
59 fn test_fn_2(a: var) @TypeOf(fopen("test", "r").*.dummy_field) {
59 fn test_fn_2(a: anytype) @TypeOf(fopen("test", "r").*.dummy_field) {
6060 return 255;
6161 }
6262
......@@ -68,4 +68,4 @@ test "Extern function calls, dereferences and field access in @TypeOf" {
6868
6969 Test.doTheTest();
7070 comptime Test.doTheTest();
71}
\ No newline at end of file
71}
test/stage1/behavior/bugs/4769_a.zig+1-1
......@@ -1 +1 @@
1//
\ No newline at end of file
1//
test/stage1/behavior/bugs/4769_b.zig+1-1
......@@ -1 +1 @@
1//!
\ No newline at end of file
1//!
test/stage1/behavior/byval_arg_var.zig+2-2
......@@ -13,11 +13,11 @@ fn start() void {
1313 foo("string literal");
1414}
1515
16fn foo(x: var) void {
16fn foo(x: anytype) void {
1717 bar(x);
1818}
1919
20fn bar(x: var) void {
20fn bar(x: anytype) void {
2121 result = x;
2222}
2323
test/stage1/behavior/call.zig+1-1
......@@ -57,7 +57,7 @@ test "tuple parameters" {
5757
5858test "comptime call with bound function as parameter" {
5959 const S = struct {
60 fn ReturnType(func: var) type {
60 fn ReturnType(func: anytype) type {
6161 return switch (@typeInfo(@TypeOf(func))) {
6262 .BoundFn => |info| info,
6363 else => unreachable,
test/stage1/behavior/enum.zig+1-1
......@@ -208,7 +208,7 @@ test "@tagName non-exhaustive enum" {
208208 comptime expect(mem.eql(u8, testEnumTagNameBare(NonExhaustive.B), "B"));
209209}
210210
211fn testEnumTagNameBare(n: var) []const u8 {
211fn testEnumTagNameBare(n: anytype) []const u8 {
212212 return @tagName(n);
213213}
214214
test/stage1/behavior/error.zig+1-1
......@@ -227,7 +227,7 @@ test "error: Infer error set from literals" {
227227 _ = comptime intLiteral("n") catch |err| handleErrors(err);
228228}
229229
230fn handleErrors(err: var) noreturn {
230fn handleErrors(err: anytype) noreturn {
231231 switch (err) {
232232 error.T => {},
233233 }
test/stage1/behavior/eval.zig+4-5
......@@ -670,10 +670,10 @@ fn loopNTimes(comptime n: usize) void {
670670}
671671
672672test "variable inside inline loop that has different types on different iterations" {
673 testVarInsideInlineLoop(.{true, @as(u32, 42)});
673 testVarInsideInlineLoop(.{ true, @as(u32, 42) });
674674}
675675
676fn testVarInsideInlineLoop(args: var) void {
676fn testVarInsideInlineLoop(args: anytype) void {
677677 comptime var i = 0;
678678 inline while (i < args.len) : (i += 1) {
679679 const x = args[i];
......@@ -814,17 +814,16 @@ test "two comptime calls with array default initialized to undefined" {
814814 dynamic_linker: DynamicLinker = DynamicLinker{},
815815
816816 pub fn parse() void {
817 var result: CrossTarget = .{ };
817 var result: CrossTarget = .{};
818818 result.getCpuArch();
819819 }
820820
821 pub fn getCpuArch(self: CrossTarget) void { }
821 pub fn getCpuArch(self: CrossTarget) void {}
822822 };
823823
824824 const DynamicLinker = struct {
825825 buffer: [255]u8 = undefined,
826826 };
827
828827 };
829828
830829 comptime {
test/stage1/behavior/fn.zig+3-3
......@@ -104,7 +104,7 @@ test "number literal as an argument" {
104104 comptime numberLiteralArg(3);
105105}
106106
107fn numberLiteralArg(a: var) void {
107fn numberLiteralArg(a: anytype) void {
108108 expect(a == 3);
109109}
110110
......@@ -132,7 +132,7 @@ test "pass by non-copying value through var arg" {
132132 expect(addPointCoordsVar(Point{ .x = 1, .y = 2 }) == 3);
133133}
134134
135fn addPointCoordsVar(pt: var) i32 {
135fn addPointCoordsVar(pt: anytype) i32 {
136136 comptime expect(@TypeOf(pt) == Point);
137137 return pt.x + pt.y;
138138}
......@@ -267,7 +267,7 @@ test "ability to give comptime types and non comptime types to same parameter" {
267267 expect(foo(i32) == 20);
268268 }
269269
270 fn foo(arg: var) i32 {
270 fn foo(arg: anytype) i32 {
271271 if (@typeInfo(@TypeOf(arg)) == .Type and arg == i32) return 20;
272272 return 9 + arg;
273273 }
test/stage1/behavior/generics.zig+4-4
......@@ -47,7 +47,7 @@ comptime {
4747 expect(max_f64(1.2, 3.4) == 3.4);
4848}
4949
50fn max_var(a: var, b: var) @TypeOf(a + b) {
50fn max_var(a: anytype, b: anytype) @TypeOf(a + b) {
5151 return if (a > b) a else b;
5252}
5353
......@@ -133,15 +133,15 @@ fn getFirstByte(comptime T: type, mem: []const T) u8 {
133133 return getByte(@ptrCast(*const u8, &mem[0]));
134134}
135135
136const foos = [_]fn (var) bool{
136const foos = [_]fn (anytype) bool{
137137 foo1,
138138 foo2,
139139};
140140
141fn foo1(arg: var) bool {
141fn foo1(arg: anytype) bool {
142142 return arg;
143143}
144fn foo2(arg: var) bool {
144fn foo2(arg: anytype) bool {
145145 return !arg;
146146}
147147
test/stage1/behavior/optional.zig+14-2
......@@ -67,8 +67,20 @@ fn test_cmp_optional_non_optional() void {
6767 // test evaluation is always lexical
6868 // ensure that the optional isn't always computed before the non-optional
6969 var mutable_state: i32 = 0;
70 _ = blk1: { mutable_state += 1; break :blk1 @as(?f64, 10.0); } != blk2: { expect(mutable_state == 1); break :blk2 @as(f64, 5.0); };
71 _ = blk1: { mutable_state += 1; break :blk1 @as(f64, 10.0); } != blk2: { expect(mutable_state == 2); break :blk2 @as(?f64, 5.0); };
70 _ = blk1: {
71 mutable_state += 1;
72 break :blk1 @as(?f64, 10.0);
73 } != blk2: {
74 expect(mutable_state == 1);
75 break :blk2 @as(f64, 5.0);
76 };
77 _ = blk1: {
78 mutable_state += 1;
79 break :blk1 @as(f64, 10.0);
80 } != blk2: {
81 expect(mutable_state == 2);
82 break :blk2 @as(?f64, 5.0);
83 };
7284}
7385
7486test "passing an optional integer as a parameter" {
test/stage1/behavior/struct.zig+5-5
......@@ -713,7 +713,7 @@ test "packed struct field passed to generic function" {
713713 a: u1,
714714 };
715715
716 fn genericReadPackedField(ptr: var) u5 {
716 fn genericReadPackedField(ptr: anytype) u5 {
717717 return ptr.*;
718718 }
719719 };
......@@ -754,7 +754,7 @@ test "fully anonymous struct" {
754754 .s = "hi",
755755 });
756756 }
757 fn dump(args: var) void {
757 fn dump(args: anytype) void {
758758 expect(args.int == 1234);
759759 expect(args.float == 12.34);
760760 expect(args.b);
......@@ -771,7 +771,7 @@ test "fully anonymous list literal" {
771771 fn doTheTest() void {
772772 dump(.{ @as(u32, 1234), @as(f64, 12.34), true, "hi" });
773773 }
774 fn dump(args: var) void {
774 fn dump(args: anytype) void {
775775 expect(args.@"0" == 1234);
776776 expect(args.@"1" == 12.34);
777777 expect(args.@"2");
......@@ -792,8 +792,8 @@ test "anonymous struct literal assigned to variable" {
792792
793793test "struct with var field" {
794794 const Point = struct {
795 x: var,
796 y: var,
795 x: anytype,
796 y: anytype,
797797 };
798798 const pt = Point{
799799 .x = 1,
test/stage1/behavior/tuple.zig+2-2
......@@ -42,7 +42,7 @@ test "tuple multiplication" {
4242 comptime S.doTheTest();
4343
4444 const T = struct {
45 fn consume_tuple(tuple: var, len: usize) void {
45 fn consume_tuple(tuple: anytype, len: usize) void {
4646 expect(tuple.len == len);
4747 }
4848
......@@ -82,7 +82,7 @@ test "tuple multiplication" {
8282
8383test "pass tuple to comptime var parameter" {
8484 const S = struct {
85 fn Foo(comptime args: var) void {
85 fn Foo(comptime args: anytype) void {
8686 expect(args[0] == 1);
8787 }
8888
test/stage1/behavior/type_info.zig+1-1
......@@ -385,7 +385,7 @@ test "@typeInfo does not force declarations into existence" {
385385}
386386
387387test "defaut value for a var-typed field" {
388 const S = struct { x: var };
388 const S = struct { x: anytype };
389389 expect(@typeInfo(S).Struct.fields[0].default_value == null);
390390}
391391
test/stage1/behavior/union.zig+1-1
......@@ -296,7 +296,7 @@ const TaggedUnionWithAVoid = union(enum) {
296296 B: i32,
297297};
298298
299fn testTaggedUnionInit(x: var) bool {
299fn testTaggedUnionInit(x: anytype) bool {
300300 const y = TaggedUnionWithAVoid{ .A = x };
301301 return @as(@TagType(TaggedUnionWithAVoid), y) == TaggedUnionWithAVoid.A;
302302}
test/stage1/behavior/var_args.zig+8-8
......@@ -1,6 +1,6 @@
11const expect = @import("std").testing.expect;
22
3fn add(args: var) i32 {
3fn add(args: anytype) i32 {
44 var sum = @as(i32, 0);
55 {
66 comptime var i: usize = 0;
......@@ -17,7 +17,7 @@ test "add arbitrary args" {
1717 expect(add(.{}) == 0);
1818}
1919
20fn readFirstVarArg(args: var) void {
20fn readFirstVarArg(args: anytype) void {
2121 const value = args[0];
2222}
2323
......@@ -31,7 +31,7 @@ test "pass args directly" {
3131 expect(addSomeStuff(.{}) == 0);
3232}
3333
34fn addSomeStuff(args: var) i32 {
34fn addSomeStuff(args: anytype) i32 {
3535 return add(args);
3636}
3737
......@@ -47,7 +47,7 @@ test "runtime parameter before var args" {
4747 }
4848}
4949
50fn extraFn(extra: u32, args: var) usize {
50fn extraFn(extra: u32, args: anytype) usize {
5151 if (args.len >= 1) {
5252 expect(args[0] == false);
5353 }
......@@ -57,15 +57,15 @@ fn extraFn(extra: u32, args: var) usize {
5757 return args.len;
5858}
5959
60const foos = [_]fn (var) bool{
60const foos = [_]fn (anytype) bool{
6161 foo1,
6262 foo2,
6363};
6464
65fn foo1(args: var) bool {
65fn foo1(args: anytype) bool {
6666 return true;
6767}
68fn foo2(args: var) bool {
68fn foo2(args: anytype) bool {
6969 return false;
7070}
7171
......@@ -78,6 +78,6 @@ test "pass zero length array to var args param" {
7878 doNothingWithFirstArg(.{""});
7979}
8080
81fn doNothingWithFirstArg(args: var) void {
81fn doNothingWithFirstArg(args: anytype) void {
8282 const a = args[0];
8383}
test/stage1/behavior/vector.zig+4-4
......@@ -171,7 +171,7 @@ test "load vector elements via comptime index" {
171171 expect(v[1] == 2);
172172 expect(loadv(&v[2]) == 3);
173173 }
174 fn loadv(ptr: var) i32 {
174 fn loadv(ptr: anytype) i32 {
175175 return ptr.*;
176176 }
177177 };
......@@ -194,7 +194,7 @@ test "store vector elements via comptime index" {
194194 storev(&v[0], 100);
195195 expect(v[0] == 100);
196196 }
197 fn storev(ptr: var, x: i32) void {
197 fn storev(ptr: anytype, x: i32) void {
198198 ptr.* = x;
199199 }
200200 };
......@@ -392,7 +392,7 @@ test "vector shift operators" {
392392 if (builtin.os.tag == .wasi) return error.SkipZigTest;
393393
394394 const S = struct {
395 fn doTheTestShift(x: var, y: var) void {
395 fn doTheTestShift(x: anytype, y: anytype) void {
396396 const N = @typeInfo(@TypeOf(x)).Array.len;
397397 const TX = @typeInfo(@TypeOf(x)).Array.child;
398398 const TY = @typeInfo(@TypeOf(y)).Array.child;
......@@ -409,7 +409,7 @@ test "vector shift operators" {
409409 expectEqual(x[i] << y[i], v);
410410 }
411411 }
412 fn doTheTestShiftExact(x: var, y: var, dir: enum { Left, Right }) void {
412 fn doTheTestShiftExact(x: anytype, y: anytype, dir: enum { Left, Right }) void {
413413 const N = @typeInfo(@TypeOf(x)).Array.len;
414414 const TX = @typeInfo(@TypeOf(x)).Array.child;
415415 const TY = @typeInfo(@TypeOf(y)).Array.child;
test/translate_c.zig+10-10
......@@ -21,7 +21,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
2121 cases.add("correct semicolon after infixop",
2222 \\#define __ferror_unlocked_body(_fp) (((_fp)->_flags & _IO_ERR_SEEN) != 0)
2323 , &[_][]const u8{
24 \\pub inline fn __ferror_unlocked_body(_fp: var) @TypeOf(((_fp.*._flags) & _IO_ERR_SEEN) != 0) {
24 \\pub inline fn __ferror_unlocked_body(_fp: anytype) @TypeOf(((_fp.*._flags) & _IO_ERR_SEEN) != 0) {
2525 \\ return ((_fp.*._flags) & _IO_ERR_SEEN) != 0;
2626 \\}
2727 });
......@@ -30,7 +30,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
3030 \\#define FOO(x) ((x >= 0) + (x >= 0))
3131 \\#define BAR 1 && 2 > 4
3232 , &[_][]const u8{
33 \\pub inline fn FOO(x: var) @TypeOf(@boolToInt(x >= 0) + @boolToInt(x >= 0)) {
33 \\pub inline fn FOO(x: anytype) @TypeOf(@boolToInt(x >= 0) + @boolToInt(x >= 0)) {
3434 \\ return @boolToInt(x >= 0) + @boolToInt(x >= 0);
3535 \\}
3636 ,
......@@ -81,7 +81,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
8181 \\ break :blk bar;
8282 \\};
8383 ,
84 \\pub inline fn bar(x: var) @TypeOf(baz(1, 2)) {
84 \\pub inline fn bar(x: anytype) @TypeOf(baz(1, 2)) {
8585 \\ return blk: {
8686 \\ _ = &x;
8787 \\ _ = 3;
......@@ -1483,11 +1483,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
14831483 , &[_][]const u8{
14841484 \\pub extern var c: c_int;
14851485 ,
1486 \\pub inline fn BASIC(c_1: var) @TypeOf(c_1 * 2) {
1486 \\pub inline fn BASIC(c_1: anytype) @TypeOf(c_1 * 2) {
14871487 \\ return c_1 * 2;
14881488 \\}
14891489 ,
1490 \\pub inline fn FOO(L: var, b: var) @TypeOf(L + b) {
1490 \\pub inline fn FOO(L: anytype, b: anytype) @TypeOf(L + b) {
14911491 \\ return L + b;
14921492 \\}
14931493 });
......@@ -2123,7 +2123,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
21232123 cases.add("macro call",
21242124 \\#define CALL(arg) bar(arg)
21252125 , &[_][]const u8{
2126 \\pub inline fn CALL(arg: var) @TypeOf(bar(arg)) {
2126 \\pub inline fn CALL(arg: anytype) @TypeOf(bar(arg)) {
21272127 \\ return bar(arg);
21282128 \\}
21292129 });
......@@ -2683,7 +2683,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
26832683 \\#define FOO(bar) baz((void *)(baz))
26842684 \\#define BAR (void*) a
26852685 , &[_][]const u8{
2686 \\pub inline fn FOO(bar: var) @TypeOf(baz((@import("std").meta.cast(?*c_void, baz)))) {
2686 \\pub inline fn FOO(bar: anytype) @TypeOf(baz((@import("std").meta.cast(?*c_void, baz)))) {
26872687 \\ return baz((@import("std").meta.cast(?*c_void, baz)));
26882688 \\}
26892689 ,
......@@ -2713,11 +2713,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
27132713 \\#define MIN(a, b) ((b) < (a) ? (b) : (a))
27142714 \\#define MAX(a, b) ((b) > (a) ? (b) : (a))
27152715 , &[_][]const u8{
2716 \\pub inline fn MIN(a: var, b: var) @TypeOf(if (b < a) b else a) {
2716 \\pub inline fn MIN(a: anytype, b: anytype) @TypeOf(if (b < a) b else a) {
27172717 \\ return if (b < a) b else a;
27182718 \\}
27192719 ,
2720 \\pub inline fn MAX(a: var, b: var) @TypeOf(if (b > a) b else a) {
2720 \\pub inline fn MAX(a: anytype, b: anytype) @TypeOf(if (b > a) b else a) {
27212721 \\ return if (b > a) b else a;
27222722 \\}
27232723 });
......@@ -2905,7 +2905,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
29052905 \\#define DefaultScreen(dpy) (((_XPrivDisplay)(dpy))->default_screen)
29062906 \\
29072907 , &[_][]const u8{
2908 \\pub inline fn DefaultScreen(dpy: var) @TypeOf((@import("std").meta.cast(_XPrivDisplay, dpy)).*.default_screen) {
2908 \\pub inline fn DefaultScreen(dpy: anytype) @TypeOf((@import("std").meta.cast(_XPrivDisplay, dpy)).*.default_screen) {
29092909 \\ return (@import("std").meta.cast(_XPrivDisplay, dpy)).*.default_screen;
29102910 \\}
29112911 });