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 {...@@ -153,7 +153,7 @@ pub fn build(b: *Builder) !void {
153 test_step.dependOn(docs_step);153 test_step.dependOn(docs_step);
154}154}
155155
156fn dependOnLib(b: *Builder, lib_exe_obj: var, dep: LibraryDep) void {156fn dependOnLib(b: *Builder, lib_exe_obj: anytype, dep: LibraryDep) void {
157 for (dep.libdirs.items) |lib_dir| {157 for (dep.libdirs.items) |lib_dir| {
158 lib_exe_obj.addLibPath(lib_dir);158 lib_exe_obj.addLibPath(lib_dir);
159 }159 }
...@@ -193,7 +193,7 @@ fn fileExists(filename: []const u8) !bool {...@@ -193,7 +193,7 @@ fn fileExists(filename: []const u8) !bool {
193 return true;193 return true;
194}194}
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 {
197 lib_exe_obj.addObjectFile(fs.path.join(b.allocator, &[_][]const u8{197 lib_exe_obj.addObjectFile(fs.path.join(b.allocator, &[_][]const u8{
198 cmake_binary_dir,198 cmake_binary_dir,
199 "zig_cpp",199 "zig_cpp",
...@@ -275,7 +275,7 @@ fn findLLVM(b: *Builder, llvm_config_exe: []const u8) !LibraryDep {...@@ -275,7 +275,7 @@ fn findLLVM(b: *Builder, llvm_config_exe: []const u8) !LibraryDep {
275 return result;275 return result;
276}276}
277277
278fn configureStage2(b: *Builder, exe: var, ctx: Context) !void {278fn configureStage2(b: *Builder, exe: anytype, ctx: Context) !void {
279 exe.addIncludeDir("src");279 exe.addIncludeDir("src");
280 exe.addIncludeDir(ctx.cmake_binary_dir);280 exe.addIncludeDir(ctx.cmake_binary_dir);
281 addCppLib(b, exe, ctx.cmake_binary_dir, "zig_cpp");281 addCppLib(b, exe, ctx.cmake_binary_dir, "zig_cpp");
...@@ -340,7 +340,7 @@ fn configureStage2(b: *Builder, exe: var, ctx: Context) !void {...@@ -340,7 +340,7 @@ fn configureStage2(b: *Builder, exe: var, ctx: Context) !void {
340fn addCxxKnownPath(340fn addCxxKnownPath(
341 b: *Builder,341 b: *Builder,
342 ctx: Context,342 ctx: Context,
343 exe: var,343 exe: anytype,
344 objname: []const u8,344 objname: []const u8,
345 errtxt: ?[]const u8,345 errtxt: ?[]const u8,
346) !void {346) !void {
doc/docgen.zig+6-5
...@@ -212,7 +212,7 @@ const Tokenizer = struct {...@@ -212,7 +212,7 @@ const Tokenizer = struct {
212 }212 }
213};213};
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 {
216 const loc = tokenizer.getTokenLocation(token);216 const loc = tokenizer.getTokenLocation(token);
217 const args_prefix = .{ tokenizer.source_file_name, loc.line + 1, loc.column + 1 };217 const args_prefix = .{ tokenizer.source_file_name, loc.line + 1, loc.column + 1 };
218 warn("{}:{}:{}: error: " ++ fmt ++ "\n", args_prefix ++ args);218 warn("{}:{}:{}: error: " ++ fmt ++ "\n", args_prefix ++ args);
...@@ -634,7 +634,7 @@ fn escapeHtml(allocator: *mem.Allocator, input: []const u8) ![]u8 {...@@ -634,7 +634,7 @@ fn escapeHtml(allocator: *mem.Allocator, input: []const u8) ![]u8 {
634 return buf.toOwnedSlice();634 return buf.toOwnedSlice();
635}635}
636636
637fn writeEscaped(out: var, input: []const u8) !void {637fn writeEscaped(out: anytype, input: []const u8) !void {
638 for (input) |c| {638 for (input) |c| {
639 try switch (c) {639 try switch (c) {
640 '&' => out.writeAll("&amp;"),640 '&' => out.writeAll("&amp;"),
...@@ -765,7 +765,7 @@ fn isType(name: []const u8) bool {...@@ -765,7 +765,7 @@ fn isType(name: []const u8) bool {
765 return false;765 return false;
766}766}
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 {
769 const src = mem.trim(u8, raw_src, " \n");769 const src = mem.trim(u8, raw_src, " \n");
770 try out.writeAll("<code class=\"zig\">");770 try out.writeAll("<code class=\"zig\">");
771 var tokenizer = std.zig.Tokenizer.init(src);771 var tokenizer = std.zig.Tokenizer.init(src);
...@@ -825,6 +825,7 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok...@@ -825,6 +825,7 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
825 .Keyword_volatile,825 .Keyword_volatile,
826 .Keyword_allowzero,826 .Keyword_allowzero,
827 .Keyword_while,827 .Keyword_while,
828 .Keyword_anytype,
828 => {829 => {
829 try out.writeAll("<span class=\"tok-kw\">");830 try out.writeAll("<span class=\"tok-kw\">");
830 try writeEscaped(out, src[token.loc.start..token.loc.end]);831 try writeEscaped(out, src[token.loc.start..token.loc.end]);
...@@ -977,12 +978,12 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok...@@ -977,12 +978,12 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
977 try out.writeAll("</code>");978 try out.writeAll("</code>");
978}979}
979980
980fn tokenizeAndPrint(docgen_tokenizer: *Tokenizer, out: var, source_token: Token) !void {981fn tokenizeAndPrint(docgen_tokenizer: *Tokenizer, out: anytype, source_token: Token) !void {
981 const raw_src = docgen_tokenizer.buffer[source_token.start..source_token.end];982 const raw_src = docgen_tokenizer.buffer[source_token.start..source_token.end];
982 return tokenizeAndPrintRaw(docgen_tokenizer, out, source_token, raw_src);983 return tokenizeAndPrintRaw(docgen_tokenizer, out, source_token, raw_src);
983}984}
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 {
986 var code_progress_index: usize = 0;987 var code_progress_index: usize = 0;
987988
988 var env_map = try process.getEnvMap(allocator);989 var env_map = try process.getEnvMap(allocator);
doc/langref.html.in+44-43
...@@ -1785,7 +1785,7 @@ test "fully anonymous list literal" {...@@ -1785,7 +1785,7 @@ test "fully anonymous list literal" {
1785 dump(.{ @as(u32, 1234), @as(f64, 12.34), true, "hi"});1785 dump(.{ @as(u32, 1234), @as(f64, 12.34), true, "hi"});
1786}1786}
17871787
1788fn dump(args: var) void {1788fn dump(args: anytype) void {
1789 assert(args.@"0" == 1234);1789 assert(args.@"0" == 1234);
1790 assert(args.@"1" == 12.34);1790 assert(args.@"1" == 12.34);
1791 assert(args.@"2");1791 assert(args.@"2");
...@@ -2717,7 +2717,7 @@ test "fully anonymous struct" {...@@ -2717,7 +2717,7 @@ test "fully anonymous struct" {
2717 });2717 });
2718}2718}
27192719
2720fn dump(args: var) void {2720fn dump(args: anytype) void {
2721 assert(args.int == 1234);2721 assert(args.int == 1234);
2722 assert(args.float == 12.34);2722 assert(args.float == 12.34);
2723 assert(args.b);2723 assert(args.b);
...@@ -4181,14 +4181,14 @@ test "pass struct to function" {...@@ -4181,14 +4181,14 @@ test "pass struct to function" {
4181 {#header_close#}4181 {#header_close#}
4182 {#header_open|Function Parameter Type Inference#}4182 {#header_open|Function Parameter Type Inference#}
4183 <p>4183 <p>
4184 Function parameters can be declared with {#syntax#}var{#endsyntax#} in place of the type.4184 Function parameters can be declared with {#syntax#}anytype{#endsyntax#} in place of the type.
4185 In this case the parameter types will be inferred when the function is called.4185 In this case the parameter types will be inferred when the function is called.
4186 Use {#link|@TypeOf#} and {#link|@typeInfo#} to get information about the inferred type.4186 Use {#link|@TypeOf#} and {#link|@typeInfo#} to get information about the inferred type.
4187 </p>4187 </p>
4188 {#code_begin|test#}4188 {#code_begin|test#}
4189const assert = @import("std").debug.assert;4189const assert = @import("std").debug.assert;
41904190
4191fn addFortyTwo(x: var) @TypeOf(x) {4191fn addFortyTwo(x: anytype) @TypeOf(x) {
4192 return x + 42;4192 return x + 42;
4193}4193}
41944194
...@@ -5974,7 +5974,7 @@ pub fn main() void {...@@ -5974,7 +5974,7 @@ pub fn main() void {
59745974
5975 {#code_begin|syntax#}5975 {#code_begin|syntax#}
5976/// Calls print and then flushes the buffer.5976/// 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 {
5978 const State = enum {5978 const State = enum {
5979 Start,5979 Start,
5980 OpenBrace,5980 OpenBrace,
...@@ -6060,7 +6060,7 @@ pub fn printf(self: *OutStream, arg0: i32, arg1: []const u8) !void {...@@ -6060,7 +6060,7 @@ pub fn printf(self: *OutStream, arg0: i32, arg1: []const u8) !void {
6060 on the type:6060 on the type:
6061 </p>6061 </p>
6062 {#code_begin|syntax#}6062 {#code_begin|syntax#}
6063pub fn printValue(self: *OutStream, value: var) !void {6063pub fn printValue(self: *OutStream, value: anytype) !void {
6064 switch (@typeInfo(@TypeOf(value))) {6064 switch (@typeInfo(@TypeOf(value))) {
6065 .Int => {6065 .Int => {
6066 return self.printInt(T, value);6066 return self.printInt(T, value);
...@@ -6686,7 +6686,7 @@ fn readFile(allocator: *Allocator, filename: []const u8) ![]u8 {...@@ -6686,7 +6686,7 @@ fn readFile(allocator: *Allocator, filename: []const u8) ![]u8 {
6686 </p>6686 </p>
6687 {#header_close#}6687 {#header_close#}
6688 {#header_open|@alignCast#}6688 {#header_open|@alignCast#}
6689 <pre>{#syntax#}@alignCast(comptime alignment: u29, ptr: var) var{#endsyntax#}</pre>6689 <pre>{#syntax#}@alignCast(comptime alignment: u29, ptr: anytype) anytype{#endsyntax#}</pre>
6690 <p>6690 <p>
6691 {#syntax#}ptr{#endsyntax#} can be {#syntax#}*T{#endsyntax#}, {#syntax#}fn(){#endsyntax#}, {#syntax#}?*T{#endsyntax#},6691 {#syntax#}ptr{#endsyntax#} can be {#syntax#}*T{#endsyntax#}, {#syntax#}fn(){#endsyntax#}, {#syntax#}?*T{#endsyntax#},
6692 {#syntax#}?fn(){#endsyntax#}, or {#syntax#}[]T{#endsyntax#}. It returns the same type as {#syntax#}ptr{#endsyntax#}6692 {#syntax#}?fn(){#endsyntax#}, or {#syntax#}[]T{#endsyntax#}. It returns the same type as {#syntax#}ptr{#endsyntax#}
...@@ -6723,7 +6723,7 @@ comptime {...@@ -6723,7 +6723,7 @@ comptime {
6723 {#header_close#}6723 {#header_close#}
67246724
6725 {#header_open|@asyncCall#}6725 {#header_open|@asyncCall#}
6726 <pre>{#syntax#}@asyncCall(frame_buffer: []align(@alignOf(@Frame(anyAsyncFunction))) u8, result_ptr, function_ptr, args: var) anyframe->T{#endsyntax#}</pre>6726 <pre>{#syntax#}@asyncCall(frame_buffer: []align(@alignOf(@Frame(anyAsyncFunction))) u8, result_ptr, function_ptr, args: anytype) anyframe->T{#endsyntax#}</pre>
6727 <p>6727 <p>
6728 {#syntax#}@asyncCall{#endsyntax#} performs an {#syntax#}async{#endsyntax#} call on a function pointer,6728 {#syntax#}@asyncCall{#endsyntax#} performs an {#syntax#}async{#endsyntax#} call on a function pointer,
6729 which may or may not be an {#link|async function|Async Functions#}.6729 which may or may not be an {#link|async function|Async Functions#}.
...@@ -6811,7 +6811,7 @@ fn func(y: *i32) void {...@@ -6811,7 +6811,7 @@ fn func(y: *i32) void {
6811 </p>6811 </p>
6812 {#header_close#}6812 {#header_close#}
6813 {#header_open|@bitCast#}6813 {#header_open|@bitCast#}
6814 <pre>{#syntax#}@bitCast(comptime DestType: type, value: var) DestType{#endsyntax#}</pre>6814 <pre>{#syntax#}@bitCast(comptime DestType: type, value: anytype) DestType{#endsyntax#}</pre>
6815 <p>6815 <p>
6816 Converts a value of one type to another type.6816 Converts a value of one type to another type.
6817 </p>6817 </p>
...@@ -6932,7 +6932,7 @@ fn func(y: *i32) void {...@@ -6932,7 +6932,7 @@ fn func(y: *i32) void {
6932 {#header_close#}6932 {#header_close#}
69336933
6934 {#header_open|@call#}6934 {#header_open|@call#}
6935 <pre>{#syntax#}@call(options: std.builtin.CallOptions, function: var, args: var) var{#endsyntax#}</pre>6935 <pre>{#syntax#}@call(options: std.builtin.CallOptions, function: anytype, args: anytype) anytype{#endsyntax#}</pre>
6936 <p>6936 <p>
6937 Calls a function, in the same way that invoking an expression with parentheses does:6937 Calls a function, in the same way that invoking an expression with parentheses does:
6938 </p>6938 </p>
...@@ -7279,7 +7279,7 @@ test "main" {...@@ -7279,7 +7279,7 @@ test "main" {
7279 {#header_close#}7279 {#header_close#}
72807280
7281 {#header_open|@enumToInt#}7281 {#header_open|@enumToInt#}
7282 <pre>{#syntax#}@enumToInt(enum_or_tagged_union: var) var{#endsyntax#}</pre>7282 <pre>{#syntax#}@enumToInt(enum_or_tagged_union: anytype) anytype{#endsyntax#}</pre>
7283 <p>7283 <p>
7284 Converts an enumeration value into its integer tag type. When a tagged union is passed,7284 Converts an enumeration value into its integer tag type. When a tagged union is passed,
7285 the tag value is used as the enumeration value.7285 the tag value is used as the enumeration value.
...@@ -7314,7 +7314,7 @@ test "main" {...@@ -7314,7 +7314,7 @@ test "main" {
7314 {#header_close#}7314 {#header_close#}
73157315
7316 {#header_open|@errorToInt#}7316 {#header_open|@errorToInt#}
7317 <pre>{#syntax#}@errorToInt(err: var) std.meta.IntType(false, @sizeOf(anyerror) * 8){#endsyntax#}</pre>7317 <pre>{#syntax#}@errorToInt(err: anytype) std.meta.IntType(false, @sizeOf(anyerror) * 8){#endsyntax#}</pre>
7318 <p>7318 <p>
7319 Supports the following types:7319 Supports the following types:
7320 </p>7320 </p>
...@@ -7334,7 +7334,7 @@ test "main" {...@@ -7334,7 +7334,7 @@ test "main" {
7334 {#header_close#}7334 {#header_close#}
73357335
7336 {#header_open|@errSetCast#}7336 {#header_open|@errSetCast#}
7337 <pre>{#syntax#}@errSetCast(comptime T: DestType, value: var) DestType{#endsyntax#}</pre>7337 <pre>{#syntax#}@errSetCast(comptime T: DestType, value: anytype) DestType{#endsyntax#}</pre>
7338 <p>7338 <p>
7339 Converts an error value from one error set to another error set. Attempting to convert an error7339 Converts an error value from one error set to another error set. Attempting to convert an error
7340 which is not in the destination error set results in safety-protected {#link|Undefined Behavior#}.7340 which is not in the destination error set results in safety-protected {#link|Undefined Behavior#}.
...@@ -7342,7 +7342,7 @@ test "main" {...@@ -7342,7 +7342,7 @@ test "main" {
7342 {#header_close#}7342 {#header_close#}
73437343
7344 {#header_open|@export#}7344 {#header_open|@export#}
7345 <pre>{#syntax#}@export(target: var, comptime options: std.builtin.ExportOptions) void{#endsyntax#}</pre>7345 <pre>{#syntax#}@export(target: anytype, comptime options: std.builtin.ExportOptions) void{#endsyntax#}</pre>
7346 <p>7346 <p>
7347 Creates a symbol in the output object file.7347 Creates a symbol in the output object file.
7348 </p>7348 </p>
...@@ -7387,7 +7387,7 @@ export fn @"A function name that is a complete sentence."() void {}...@@ -7387,7 +7387,7 @@ export fn @"A function name that is a complete sentence."() void {}
7387 {#header_close#}7387 {#header_close#}
73887388
7389 {#header_open|@field#}7389 {#header_open|@field#}
7390 <pre>{#syntax#}@field(lhs: var, comptime field_name: []const u8) (field){#endsyntax#}</pre>7390 <pre>{#syntax#}@field(lhs: anytype, comptime field_name: []const u8) (field){#endsyntax#}</pre>
7391 <p>Performs field access by a compile-time string.7391 <p>Performs field access by a compile-time string.
7392 </p>7392 </p>
7393 {#code_begin|test#}7393 {#code_begin|test#}
...@@ -7421,7 +7421,7 @@ test "field access by string" {...@@ -7421,7 +7421,7 @@ test "field access by string" {
7421 {#header_close#}7421 {#header_close#}
74227422
7423 {#header_open|@floatCast#}7423 {#header_open|@floatCast#}
7424 <pre>{#syntax#}@floatCast(comptime DestType: type, value: var) DestType{#endsyntax#}</pre>7424 <pre>{#syntax#}@floatCast(comptime DestType: type, value: anytype) DestType{#endsyntax#}</pre>
7425 <p>7425 <p>
7426 Convert from one float type to another. This cast is safe, but may cause the7426 Convert from one float type to another. This cast is safe, but may cause the
7427 numeric value to lose precision.7427 numeric value to lose precision.
...@@ -7429,7 +7429,7 @@ test "field access by string" {...@@ -7429,7 +7429,7 @@ test "field access by string" {
7429 {#header_close#}7429 {#header_close#}
74307430
7431 {#header_open|@floatToInt#}7431 {#header_open|@floatToInt#}
7432 <pre>{#syntax#}@floatToInt(comptime DestType: type, float: var) DestType{#endsyntax#}</pre>7432 <pre>{#syntax#}@floatToInt(comptime DestType: type, float: anytype) DestType{#endsyntax#}</pre>
7433 <p>7433 <p>
7434 Converts the integer part of a floating point number to the destination type.7434 Converts the integer part of a floating point number to the destination type.
7435 </p>7435 </p>
...@@ -7455,7 +7455,7 @@ test "field access by string" {...@@ -7455,7 +7455,7 @@ test "field access by string" {
7455 {#header_close#}7455 {#header_close#}
74567456
7457 {#header_open|@Frame#}7457 {#header_open|@Frame#}
7458 <pre>{#syntax#}@Frame(func: var) type{#endsyntax#}</pre>7458 <pre>{#syntax#}@Frame(func: anytype) type{#endsyntax#}</pre>
7459 <p>7459 <p>
7460 This function returns the frame type of a function. This works for {#link|Async Functions#}7460 This function returns the frame type of a function. This works for {#link|Async Functions#}
7461 as well as any function without a specific calling convention.7461 as well as any function without a specific calling convention.
...@@ -7581,7 +7581,7 @@ test "@hasDecl" {...@@ -7581,7 +7581,7 @@ test "@hasDecl" {
7581 {#header_close#}7581 {#header_close#}
75827582
7583 {#header_open|@intCast#}7583 {#header_open|@intCast#}
7584 <pre>{#syntax#}@intCast(comptime DestType: type, int: var) DestType{#endsyntax#}</pre>7584 <pre>{#syntax#}@intCast(comptime DestType: type, int: anytype) DestType{#endsyntax#}</pre>
7585 <p>7585 <p>
7586 Converts an integer to another integer while keeping the same numerical value.7586 Converts an integer to another integer while keeping the same numerical value.
7587 Attempting to convert a number which is out of range of the destination type results in7587 Attempting to convert a number which is out of range of the destination type results in
...@@ -7622,7 +7622,7 @@ test "@hasDecl" {...@@ -7622,7 +7622,7 @@ test "@hasDecl" {
7622 {#header_close#}7622 {#header_close#}
76237623
7624 {#header_open|@intToFloat#}7624 {#header_open|@intToFloat#}
7625 <pre>{#syntax#}@intToFloat(comptime DestType: type, int: var) DestType{#endsyntax#}</pre>7625 <pre>{#syntax#}@intToFloat(comptime DestType: type, int: anytype) DestType{#endsyntax#}</pre>
7626 <p>7626 <p>
7627 Converts an integer to the closest floating point representation. To convert the other way, use {#link|@floatToInt#}. This cast is always safe.7627 Converts an integer to the closest floating point representation. To convert the other way, use {#link|@floatToInt#}. This cast is always safe.
7628 </p>7628 </p>
...@@ -7773,7 +7773,7 @@ test "@wasmMemoryGrow" {...@@ -7773,7 +7773,7 @@ test "@wasmMemoryGrow" {
7773 {#header_close#}7773 {#header_close#}
77747774
7775 {#header_open|@ptrCast#}7775 {#header_open|@ptrCast#}
7776 <pre>{#syntax#}@ptrCast(comptime DestType: type, value: var) DestType{#endsyntax#}</pre>7776 <pre>{#syntax#}@ptrCast(comptime DestType: type, value: anytype) DestType{#endsyntax#}</pre>
7777 <p>7777 <p>
7778 Converts a pointer of one type to a pointer of another type.7778 Converts a pointer of one type to a pointer of another type.
7779 </p>7779 </p>
...@@ -7784,7 +7784,7 @@ test "@wasmMemoryGrow" {...@@ -7784,7 +7784,7 @@ test "@wasmMemoryGrow" {
7784 {#header_close#}7784 {#header_close#}
77857785
7786 {#header_open|@ptrToInt#}7786 {#header_open|@ptrToInt#}
7787 <pre>{#syntax#}@ptrToInt(value: var) usize{#endsyntax#}</pre>7787 <pre>{#syntax#}@ptrToInt(value: anytype) usize{#endsyntax#}</pre>
7788 <p>7788 <p>
7789 Converts {#syntax#}value{#endsyntax#} to a {#syntax#}usize{#endsyntax#} which is the address of the pointer. {#syntax#}value{#endsyntax#} can be one of these types:7789 Converts {#syntax#}value{#endsyntax#} to a {#syntax#}usize{#endsyntax#} which is the address of the pointer. {#syntax#}value{#endsyntax#} can be one of these types:
7790 </p>7790 </p>
...@@ -8042,7 +8042,7 @@ test "@setRuntimeSafety" {...@@ -8042,7 +8042,7 @@ test "@setRuntimeSafety" {
8042 {#header_close#}8042 {#header_close#}
80438043
8044 {#header_open|@splat#}8044 {#header_open|@splat#}
8045 <pre>{#syntax#}@splat(comptime len: u32, scalar: var) std.meta.Vector(len, @TypeOf(scalar)){#endsyntax#}</pre>8045 <pre>{#syntax#}@splat(comptime len: u32, scalar: anytype) std.meta.Vector(len, @TypeOf(scalar)){#endsyntax#}</pre>
8046 <p>8046 <p>
8047 Produces a vector of length {#syntax#}len{#endsyntax#} where each element is the value8047 Produces a vector of length {#syntax#}len{#endsyntax#} where each element is the value
8048 {#syntax#}scalar{#endsyntax#}:8048 {#syntax#}scalar{#endsyntax#}:
...@@ -8088,7 +8088,7 @@ fn doTheTest() void {...@@ -8088,7 +8088,7 @@ fn doTheTest() void {
8088 {#code_end#}8088 {#code_end#}
8089 {#header_close#}8089 {#header_close#}
8090 {#header_open|@sqrt#}8090 {#header_open|@sqrt#}
8091 <pre>{#syntax#}@sqrt(value: var) @TypeOf(value){#endsyntax#}</pre>8091 <pre>{#syntax#}@sqrt(value: anytype) @TypeOf(value){#endsyntax#}</pre>
8092 <p>8092 <p>
8093 Performs the square root of a floating point number. Uses a dedicated hardware instruction8093 Performs the square root of a floating point number. Uses a dedicated hardware instruction
8094 when available.8094 when available.
...@@ -8099,7 +8099,7 @@ fn doTheTest() void {...@@ -8099,7 +8099,7 @@ fn doTheTest() void {
8099 </p>8099 </p>
8100 {#header_close#}8100 {#header_close#}
8101 {#header_open|@sin#}8101 {#header_open|@sin#}
8102 <pre>{#syntax#}@sin(value: var) @TypeOf(value){#endsyntax#}</pre>8102 <pre>{#syntax#}@sin(value: anytype) @TypeOf(value){#endsyntax#}</pre>
8103 <p>8103 <p>
8104 Sine trigometric function on a floating point number. Uses a dedicated hardware instruction8104 Sine trigometric function on a floating point number. Uses a dedicated hardware instruction
8105 when available.8105 when available.
...@@ -8110,7 +8110,7 @@ fn doTheTest() void {...@@ -8110,7 +8110,7 @@ fn doTheTest() void {
8110 </p>8110 </p>
8111 {#header_close#}8111 {#header_close#}
8112 {#header_open|@cos#}8112 {#header_open|@cos#}
8113 <pre>{#syntax#}@cos(value: var) @TypeOf(value){#endsyntax#}</pre>8113 <pre>{#syntax#}@cos(value: anytype) @TypeOf(value){#endsyntax#}</pre>
8114 <p>8114 <p>
8115 Cosine trigometric function on a floating point number. Uses a dedicated hardware instruction8115 Cosine trigometric function on a floating point number. Uses a dedicated hardware instruction
8116 when available.8116 when available.
...@@ -8121,7 +8121,7 @@ fn doTheTest() void {...@@ -8121,7 +8121,7 @@ fn doTheTest() void {
8121 </p>8121 </p>
8122 {#header_close#}8122 {#header_close#}
8123 {#header_open|@exp#}8123 {#header_open|@exp#}
8124 <pre>{#syntax#}@exp(value: var) @TypeOf(value){#endsyntax#}</pre>8124 <pre>{#syntax#}@exp(value: anytype) @TypeOf(value){#endsyntax#}</pre>
8125 <p>8125 <p>
8126 Base-e exponential function on a floating point number. Uses a dedicated hardware instruction8126 Base-e exponential function on a floating point number. Uses a dedicated hardware instruction
8127 when available.8127 when available.
...@@ -8132,7 +8132,7 @@ fn doTheTest() void {...@@ -8132,7 +8132,7 @@ fn doTheTest() void {
8132 </p>8132 </p>
8133 {#header_close#}8133 {#header_close#}
8134 {#header_open|@exp2#}8134 {#header_open|@exp2#}
8135 <pre>{#syntax#}@exp2(value: var) @TypeOf(value){#endsyntax#}</pre>8135 <pre>{#syntax#}@exp2(value: anytype) @TypeOf(value){#endsyntax#}</pre>
8136 <p>8136 <p>
8137 Base-2 exponential function on a floating point number. Uses a dedicated hardware instruction8137 Base-2 exponential function on a floating point number. Uses a dedicated hardware instruction
8138 when available.8138 when available.
...@@ -8143,7 +8143,7 @@ fn doTheTest() void {...@@ -8143,7 +8143,7 @@ fn doTheTest() void {
8143 </p>8143 </p>
8144 {#header_close#}8144 {#header_close#}
8145 {#header_open|@log#}8145 {#header_open|@log#}
8146 <pre>{#syntax#}@log(value: var) @TypeOf(value){#endsyntax#}</pre>8146 <pre>{#syntax#}@log(value: anytype) @TypeOf(value){#endsyntax#}</pre>
8147 <p>8147 <p>
8148 Returns the natural logarithm of a floating point number. Uses a dedicated hardware instruction8148 Returns the natural logarithm of a floating point number. Uses a dedicated hardware instruction
8149 when available.8149 when available.
...@@ -8154,7 +8154,7 @@ fn doTheTest() void {...@@ -8154,7 +8154,7 @@ fn doTheTest() void {
8154 </p>8154 </p>
8155 {#header_close#}8155 {#header_close#}
8156 {#header_open|@log2#}8156 {#header_open|@log2#}
8157 <pre>{#syntax#}@log2(value: var) @TypeOf(value){#endsyntax#}</pre>8157 <pre>{#syntax#}@log2(value: anytype) @TypeOf(value){#endsyntax#}</pre>
8158 <p>8158 <p>
8159 Returns the logarithm to the base 2 of a floating point number. Uses a dedicated hardware instruction8159 Returns the logarithm to the base 2 of a floating point number. Uses a dedicated hardware instruction
8160 when available.8160 when available.
...@@ -8165,7 +8165,7 @@ fn doTheTest() void {...@@ -8165,7 +8165,7 @@ fn doTheTest() void {
8165 </p>8165 </p>
8166 {#header_close#}8166 {#header_close#}
8167 {#header_open|@log10#}8167 {#header_open|@log10#}
8168 <pre>{#syntax#}@log10(value: var) @TypeOf(value){#endsyntax#}</pre>8168 <pre>{#syntax#}@log10(value: anytype) @TypeOf(value){#endsyntax#}</pre>
8169 <p>8169 <p>
8170 Returns the logarithm to the base 10 of a floating point number. Uses a dedicated hardware instruction8170 Returns the logarithm to the base 10 of a floating point number. Uses a dedicated hardware instruction
8171 when available.8171 when available.
...@@ -8176,7 +8176,7 @@ fn doTheTest() void {...@@ -8176,7 +8176,7 @@ fn doTheTest() void {
8176 </p>8176 </p>
8177 {#header_close#}8177 {#header_close#}
8178 {#header_open|@fabs#}8178 {#header_open|@fabs#}
8179 <pre>{#syntax#}@fabs(value: var) @TypeOf(value){#endsyntax#}</pre>8179 <pre>{#syntax#}@fabs(value: anytype) @TypeOf(value){#endsyntax#}</pre>
8180 <p>8180 <p>
8181 Returns the absolute value of a floating point number. Uses a dedicated hardware instruction8181 Returns the absolute value of a floating point number. Uses a dedicated hardware instruction
8182 when available.8182 when available.
...@@ -8187,7 +8187,7 @@ fn doTheTest() void {...@@ -8187,7 +8187,7 @@ fn doTheTest() void {
8187 </p>8187 </p>
8188 {#header_close#}8188 {#header_close#}
8189 {#header_open|@floor#}8189 {#header_open|@floor#}
8190 <pre>{#syntax#}@floor(value: var) @TypeOf(value){#endsyntax#}</pre>8190 <pre>{#syntax#}@floor(value: anytype) @TypeOf(value){#endsyntax#}</pre>
8191 <p>8191 <p>
8192 Returns the largest integral value not greater than the given floating point number.8192 Returns the largest integral value not greater than the given floating point number.
8193 Uses a dedicated hardware instruction when available.8193 Uses a dedicated hardware instruction when available.
...@@ -8198,7 +8198,7 @@ fn doTheTest() void {...@@ -8198,7 +8198,7 @@ fn doTheTest() void {
8198 </p>8198 </p>
8199 {#header_close#}8199 {#header_close#}
8200 {#header_open|@ceil#}8200 {#header_open|@ceil#}
8201 <pre>{#syntax#}@ceil(value: var) @TypeOf(value){#endsyntax#}</pre>8201 <pre>{#syntax#}@ceil(value: anytype) @TypeOf(value){#endsyntax#}</pre>
8202 <p>8202 <p>
8203 Returns the largest integral value not less than the given floating point number.8203 Returns the largest integral value not less than the given floating point number.
8204 Uses a dedicated hardware instruction when available.8204 Uses a dedicated hardware instruction when available.
...@@ -8209,7 +8209,7 @@ fn doTheTest() void {...@@ -8209,7 +8209,7 @@ fn doTheTest() void {
8209 </p>8209 </p>
8210 {#header_close#}8210 {#header_close#}
8211 {#header_open|@trunc#}8211 {#header_open|@trunc#}
8212 <pre>{#syntax#}@trunc(value: var) @TypeOf(value){#endsyntax#}</pre>8212 <pre>{#syntax#}@trunc(value: anytype) @TypeOf(value){#endsyntax#}</pre>
8213 <p>8213 <p>
8214 Rounds the given floating point number to an integer, towards zero.8214 Rounds the given floating point number to an integer, towards zero.
8215 Uses a dedicated hardware instruction when available.8215 Uses a dedicated hardware instruction when available.
...@@ -8220,7 +8220,7 @@ fn doTheTest() void {...@@ -8220,7 +8220,7 @@ fn doTheTest() void {
8220 </p>8220 </p>
8221 {#header_close#}8221 {#header_close#}
8222 {#header_open|@round#}8222 {#header_open|@round#}
8223 <pre>{#syntax#}@round(value: var) @TypeOf(value){#endsyntax#}</pre>8223 <pre>{#syntax#}@round(value: anytype) @TypeOf(value){#endsyntax#}</pre>
8224 <p>8224 <p>
8225 Rounds the given floating point number to an integer, away from zero. Uses a dedicated hardware instruction8225 Rounds the given floating point number to an integer, away from zero. Uses a dedicated hardware instruction
8226 when available.8226 when available.
...@@ -8241,7 +8241,7 @@ fn doTheTest() void {...@@ -8241,7 +8241,7 @@ fn doTheTest() void {
8241 {#header_close#}8241 {#header_close#}
82428242
8243 {#header_open|@tagName#}8243 {#header_open|@tagName#}
8244 <pre>{#syntax#}@tagName(value: var) []const u8{#endsyntax#}</pre>8244 <pre>{#syntax#}@tagName(value: anytype) []const u8{#endsyntax#}</pre>
8245 <p>8245 <p>
8246 Converts an enum value or union value to a slice of bytes representing the name.</p><p>If the enum is non-exhaustive and the tag value does not map to a name, it invokes safety-checked {#link|Undefined Behavior#}.8246 Converts an enum value or union value to a slice of bytes representing the name.</p><p>If the enum is non-exhaustive and the tag value does not map to a name, it invokes safety-checked {#link|Undefined Behavior#}.
8247 </p>8247 </p>
...@@ -8292,7 +8292,7 @@ fn List(comptime T: type) type {...@@ -8292,7 +8292,7 @@ fn List(comptime T: type) type {
8292 {#header_close#}8292 {#header_close#}
82938293
8294 {#header_open|@truncate#}8294 {#header_open|@truncate#}
8295 <pre>{#syntax#}@truncate(comptime T: type, integer: var) T{#endsyntax#}</pre>8295 <pre>{#syntax#}@truncate(comptime T: type, integer: anytype) T{#endsyntax#}</pre>
8296 <p>8296 <p>
8297 This function truncates bits from an integer type, resulting in a smaller8297 This function truncates bits from an integer type, resulting in a smaller
8298 or same-sized integer type.8298 or same-sized integer type.
...@@ -10214,7 +10214,7 @@ TopLevelDecl...@@ -10214,7 +10214,7 @@ TopLevelDecl
10214 / (KEYWORD_export / KEYWORD_extern STRINGLITERALSINGLE?)? KEYWORD_threadlocal? VarDecl10214 / (KEYWORD_export / KEYWORD_extern STRINGLITERALSINGLE?)? KEYWORD_threadlocal? VarDecl
10215 / KEYWORD_usingnamespace Expr SEMICOLON10215 / 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
10219VarDecl &lt;- (KEYWORD_const / KEYWORD_var) IDENTIFIER (COLON TypeExpr)? ByteAlign? LinkSection? (EQUAL Expr)? SEMICOLON10219VarDecl &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...@@ -10386,7 +10386,7 @@ LinkSection &lt;- KEYWORD_linksection LPAREN Expr RPAREN
10386ParamDecl &lt;- (KEYWORD_noalias / KEYWORD_comptime)? (IDENTIFIER COLON)? ParamType10386ParamDecl &lt;- (KEYWORD_noalias / KEYWORD_comptime)? (IDENTIFIER COLON)? ParamType
1038710387
10388ParamType10388ParamType
10389 &lt;- KEYWORD_var10389 &lt;- KEYWORD_anytype
10390 / DOT310390 / DOT3
10391 / TypeExpr10391 / TypeExpr
1039210392
...@@ -10624,6 +10624,7 @@ KEYWORD_align &lt;- 'align' end_of_word...@@ -10624,6 +10624,7 @@ KEYWORD_align &lt;- 'align' end_of_word
10624KEYWORD_allowzero &lt;- 'allowzero' end_of_word10624KEYWORD_allowzero &lt;- 'allowzero' end_of_word
10625KEYWORD_and &lt;- 'and' end_of_word10625KEYWORD_and &lt;- 'and' end_of_word
10626KEYWORD_anyframe &lt;- 'anyframe' end_of_word10626KEYWORD_anyframe &lt;- 'anyframe' end_of_word
10627KEYWORD_anytype &lt;- 'anytype' end_of_word
10627KEYWORD_asm &lt;- 'asm' end_of_word10628KEYWORD_asm &lt;- 'asm' end_of_word
10628KEYWORD_async &lt;- 'async' end_of_word10629KEYWORD_async &lt;- 'async' end_of_word
10629KEYWORD_await &lt;- 'await' end_of_word10630KEYWORD_await &lt;- 'await' end_of_word
...@@ -10669,14 +10670,14 @@ KEYWORD_var &lt;- 'var' end_of_word...@@ -10669,14 +10670,14 @@ KEYWORD_var &lt;- 'var' end_of_word
10669KEYWORD_volatile &lt;- 'volatile' end_of_word10670KEYWORD_volatile &lt;- 'volatile' end_of_word
10670KEYWORD_while &lt;- 'while' end_of_word10671KEYWORD_while &lt;- 'while' end_of_word
1067110672
10672keyword &lt;- KEYWORD_align / KEYWORD_and / KEYWORD_allowzero / KEYWORD_asm10673keyword &lt;- KEYWORD_align / KEYWORD_and / KEYWORD_anyframe / KEYWORD_anytype
10673 / KEYWORD_async / KEYWORD_await / KEYWORD_break10674 / KEYWORD_allowzero / KEYWORD_asm / KEYWORD_async / KEYWORD_await / KEYWORD_break
10674 / KEYWORD_catch / KEYWORD_comptime / KEYWORD_const / KEYWORD_continue10675 / KEYWORD_catch / KEYWORD_comptime / KEYWORD_const / KEYWORD_continue
10675 / KEYWORD_defer / KEYWORD_else / KEYWORD_enum / KEYWORD_errdefer10676 / KEYWORD_defer / KEYWORD_else / KEYWORD_enum / KEYWORD_errdefer
10676 / KEYWORD_error / KEYWORD_export / KEYWORD_extern / KEYWORD_false10677 / KEYWORD_error / KEYWORD_export / KEYWORD_extern / KEYWORD_false
10677 / KEYWORD_fn / KEYWORD_for / KEYWORD_if / KEYWORD_inline10678 / KEYWORD_fn / KEYWORD_for / KEYWORD_if / KEYWORD_inline
10678 / KEYWORD_noalias / KEYWORD_null / KEYWORD_or10679 / KEYWORD_noalias / KEYWORD_null / KEYWORD_or
10679 / KEYWORD_orelse / KEYWORD_packed / KEYWORD_anyframe / KEYWORD_pub10680 / KEYWORD_orelse / KEYWORD_packed / KEYWORD_pub
10680 / KEYWORD_resume / KEYWORD_return / KEYWORD_linksection10681 / KEYWORD_resume / KEYWORD_return / KEYWORD_linksection
10681 / KEYWORD_struct / KEYWORD_suspend10682 / KEYWORD_struct / KEYWORD_suspend
10682 / KEYWORD_switch / KEYWORD_test / KEYWORD_threadlocal / KEYWORD_true / KEYWORD_try10683 / 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 {...@@ -53,7 +53,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
53 /// Deprecated: use `items` field directly.53 /// Deprecated: use `items` field directly.
54 /// Return contents as a slice. Only valid while the list54 /// Return contents as a slice. Only valid while the list
55 /// doesn't change size.55 /// doesn't change size.
56 pub fn span(self: var) @TypeOf(self.items) {56 pub fn span(self: anytype) @TypeOf(self.items) {
57 return self.items;57 return self.items;
58 }58 }
5959
lib/std/array_list_sentineled.zig+2-2
...@@ -69,7 +69,7 @@ pub fn ArrayListSentineled(comptime T: type, comptime sentinel: T) type {...@@ -69,7 +69,7 @@ pub fn ArrayListSentineled(comptime T: type, comptime sentinel: T) type {
69 }69 }
7070
71 /// Only works when `T` is `u8`.71 /// 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 {
73 const size = std.math.cast(usize, std.fmt.count(format, args)) catch |err| switch (err) {73 const size = std.math.cast(usize, std.fmt.count(format, args)) catch |err| switch (err) {
74 error.Overflow => return error.OutOfMemory,74 error.Overflow => return error.OutOfMemory,
75 };75 };
...@@ -82,7 +82,7 @@ pub fn ArrayListSentineled(comptime T: type, comptime sentinel: T) type {...@@ -82,7 +82,7 @@ pub fn ArrayListSentineled(comptime T: type, comptime sentinel: T) type {
82 self.list.deinit();82 self.list.deinit();
83 }83 }
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]) {
86 return self.list.items[0..self.len() :sentinel];86 return self.list.items[0..self.len() :sentinel];
87 }87 }
8888
lib/std/atomic/queue.zig+2-2
...@@ -123,10 +123,10 @@ pub fn Queue(comptime T: type) type {...@@ -123,10 +123,10 @@ pub fn Queue(comptime T: type) type {
123 /// Dumps the contents of the queue to `stream`.123 /// Dumps the contents of the queue to `stream`.
124 /// Up to 4 elements from the head are dumped and the tail of the queue is124 /// Up to 4 elements from the head are dumped and the tail of the queue is
125 /// dumped as well.125 /// dumped as well.
126 pub fn dumpToStream(self: *Self, stream: var) !void {126 pub fn dumpToStream(self: *Self, stream: anytype) !void {
127 const S = struct {127 const S = struct {
128 fn dumpRecursive(128 fn dumpRecursive(
129 s: var,129 s: anytype,
130 optional_node: ?*Node,130 optional_node: ?*Node,
131 indent: usize,131 indent: usize,
132 comptime depth: comptime_int,132 comptime depth: comptime_int,
lib/std/build.zig+2-2
...@@ -312,7 +312,7 @@ pub const Builder = struct {...@@ -312,7 +312,7 @@ pub const Builder = struct {
312 return write_file_step;312 return write_file_step;
313 }313 }
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 {
316 const data = self.fmt(format, args);316 const data = self.fmt(format, args);
317 const log_step = self.allocator.create(LogStep) catch unreachable;317 const log_step = self.allocator.create(LogStep) catch unreachable;
318 log_step.* = LogStep.init(self, data);318 log_step.* = LogStep.init(self, data);
...@@ -883,7 +883,7 @@ pub const Builder = struct {...@@ -883,7 +883,7 @@ pub const Builder = struct {
883 return fs.path.resolve(self.allocator, &[_][]const u8{ self.build_root, rel_path }) catch unreachable;883 return fs.path.resolve(self.allocator, &[_][]const u8{ self.build_root, rel_path }) catch unreachable;
884 }884 }
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 {
887 return fmt_lib.allocPrint(self.allocator, format, args) catch unreachable;887 return fmt_lib.allocPrint(self.allocator, format, args) catch unreachable;
888 }888 }
889889
lib/std/build/emit_raw.zig+1-1
...@@ -126,7 +126,7 @@ const BinaryElfOutput = struct {...@@ -126,7 +126,7 @@ const BinaryElfOutput = struct {
126 return segment.p_offset <= section.elfOffset and (segment.p_offset + segment.p_filesz) >= (section.elfOffset + section.fileSize);126 return segment.p_offset <= section.elfOffset and (segment.p_offset + segment.p_filesz) >= (section.elfOffset + section.fileSize);
127 }127 }
128128
129 fn sectionValidForOutput(shdr: var) bool {129 fn sectionValidForOutput(shdr: anytype) bool {
130 return shdr.sh_size > 0 and shdr.sh_type != elf.SHT_NOBITS and130 return shdr.sh_size > 0 and shdr.sh_type != elf.SHT_NOBITS and
131 ((shdr.sh_flags & elf.SHF_ALLOC) == elf.SHF_ALLOC);131 ((shdr.sh_flags & elf.SHF_ALLOC) == elf.SHF_ALLOC);
132 }132 }
lib/std/builtin.zig+5-5
...@@ -198,7 +198,7 @@ pub const TypeInfo = union(enum) {...@@ -198,7 +198,7 @@ pub const TypeInfo = union(enum) {
198 /// The type of the sentinel is the element type of the pointer, which is198 /// The type of the sentinel is the element type of the pointer, which is
199 /// the value of the `child` field in this struct. However there is no way199 /// the value of the `child` field in this struct. However there is no way
200 /// to refer to that type here, so we use `var`.200 /// to refer to that type here, so we use `var`.
201 sentinel: var,201 sentinel: anytype,
202202
203 /// This data structure is used by the Zig language code generation and203 /// This data structure is used by the Zig language code generation and
204 /// therefore must be kept in sync with the compiler implementation.204 /// therefore must be kept in sync with the compiler implementation.
...@@ -220,7 +220,7 @@ pub const TypeInfo = union(enum) {...@@ -220,7 +220,7 @@ pub const TypeInfo = union(enum) {
220 /// The type of the sentinel is the element type of the array, which is220 /// The type of the sentinel is the element type of the array, which is
221 /// the value of the `child` field in this struct. However there is no way221 /// the value of the `child` field in this struct. However there is no way
222 /// to refer to that type here, so we use `var`.222 /// to refer to that type here, so we use `var`.
223 sentinel: var,223 sentinel: anytype,
224 };224 };
225225
226 /// This data structure is used by the Zig language code generation and226 /// This data structure is used by the Zig language code generation and
...@@ -237,7 +237,7 @@ pub const TypeInfo = union(enum) {...@@ -237,7 +237,7 @@ pub const TypeInfo = union(enum) {
237 name: []const u8,237 name: []const u8,
238 offset: ?comptime_int,238 offset: ?comptime_int,
239 field_type: type,239 field_type: type,
240 default_value: var,240 default_value: anytype,
241 };241 };
242242
243 /// This data structure is used by the Zig language code generation and243 /// This data structure is used by the Zig language code generation and
...@@ -328,7 +328,7 @@ pub const TypeInfo = union(enum) {...@@ -328,7 +328,7 @@ pub const TypeInfo = union(enum) {
328 /// This data structure is used by the Zig language code generation and328 /// This data structure is used by the Zig language code generation and
329 /// therefore must be kept in sync with the compiler implementation.329 /// therefore must be kept in sync with the compiler implementation.
330 pub const Frame = struct {330 pub const Frame = struct {
331 function: var,331 function: anytype,
332 };332 };
333333
334 /// This data structure is used by the Zig language code generation and334 /// This data structure is used by the Zig language code generation and
...@@ -452,7 +452,7 @@ pub const Version = struct {...@@ -452,7 +452,7 @@ pub const Version = struct {
452 self: Version,452 self: Version,
453 comptime fmt: []const u8,453 comptime fmt: []const u8,
454 options: std.fmt.FormatOptions,454 options: std.fmt.FormatOptions,
455 out_stream: var,455 out_stream: anytype,
456 ) !void {456 ) !void {
457 if (fmt.len == 0) {457 if (fmt.len == 0) {
458 if (self.patch == 0) {458 if (self.patch == 0) {
lib/std/c.zig+1-1
...@@ -27,7 +27,7 @@ pub usingnamespace switch (std.Target.current.os.tag) {...@@ -27,7 +27,7 @@ pub usingnamespace switch (std.Target.current.os.tag) {
27 else => struct {},27 else => struct {},
28};28};
2929
30pub fn getErrno(rc: var) u16 {30pub fn getErrno(rc: anytype) u16 {
31 if (rc == -1) {31 if (rc == -1) {
32 return @intCast(u16, _errno().*);32 return @intCast(u16, _errno().*);
33 } else {33 } else {
lib/std/c/ast.zig+7-7
...@@ -64,7 +64,7 @@ pub const Error = union(enum) {...@@ -64,7 +64,7 @@ pub const Error = union(enum) {
64 NothingDeclared: SimpleError("declaration doesn't declare anything"),64 NothingDeclared: SimpleError("declaration doesn't declare anything"),
65 QualifierIgnored: SingleTokenError("qualifier '{}' ignored"),65 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 {
68 switch (self.*) {68 switch (self.*) {
69 .InvalidToken => |*x| return x.render(tree, stream),69 .InvalidToken => |*x| return x.render(tree, stream),
70 .ExpectedToken => |*x| return x.render(tree, stream),70 .ExpectedToken => |*x| return x.render(tree, stream),
...@@ -114,7 +114,7 @@ pub const Error = union(enum) {...@@ -114,7 +114,7 @@ pub const Error = union(enum) {
114 token: TokenIndex,114 token: TokenIndex,
115 expected_id: @TagType(Token.Id),115 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 {
118 const found_token = tree.tokens.at(self.token);118 const found_token = tree.tokens.at(self.token);
119 if (found_token.id == .Invalid) {119 if (found_token.id == .Invalid) {
120 return stream.print("expected '{}', found invalid bytes", .{self.expected_id.symbol()});120 return stream.print("expected '{}', found invalid bytes", .{self.expected_id.symbol()});
...@@ -129,7 +129,7 @@ pub const Error = union(enum) {...@@ -129,7 +129,7 @@ pub const Error = union(enum) {
129 token: TokenIndex,129 token: TokenIndex,
130 type_spec: *Node.TypeSpec,130 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 {
133 try stream.write("invalid type specifier '");133 try stream.write("invalid type specifier '");
134 try type_spec.spec.print(tree, stream);134 try type_spec.spec.print(tree, stream);
135 const token_name = tree.tokens.at(self.token).id.symbol();135 const token_name = tree.tokens.at(self.token).id.symbol();
...@@ -141,7 +141,7 @@ pub const Error = union(enum) {...@@ -141,7 +141,7 @@ pub const Error = union(enum) {
141 kw: TokenIndex,141 kw: TokenIndex,
142 name: TokenIndex,142 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 {
145 return stream.print("must use '{}' tag to refer to type '{}'", .{ tree.slice(kw), tree.slice(name) });145 return stream.print("must use '{}' tag to refer to type '{}'", .{ tree.slice(kw), tree.slice(name) });
146 }146 }
147 };147 };
...@@ -150,7 +150,7 @@ pub const Error = union(enum) {...@@ -150,7 +150,7 @@ pub const Error = union(enum) {
150 return struct {150 return struct {
151 token: TokenIndex,151 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 {
154 const actual_token = tree.tokens.at(self.token);154 const actual_token = tree.tokens.at(self.token);
155 return stream.print(msg, .{actual_token.id.symbol()});155 return stream.print(msg, .{actual_token.id.symbol()});
156 }156 }
...@@ -163,7 +163,7 @@ pub const Error = union(enum) {...@@ -163,7 +163,7 @@ pub const Error = union(enum) {
163163
164 token: TokenIndex,164 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 {
167 return stream.write(msg);167 return stream.write(msg);
168 }168 }
169 };169 };
...@@ -317,7 +317,7 @@ pub const Node = struct {...@@ -317,7 +317,7 @@ pub const Node = struct {
317 sym_type: *Type,317 sym_type: *Type,
318 },318 },
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 {
321 switch (self.spec) {321 switch (self.spec) {
322 .None => unreachable,322 .None => unreachable,
323 .Void => |index| try stream.write(tree.slice(index)),323 .Void => |index| try stream.write(tree.slice(index)),
lib/std/cache_hash.zig+1-1
...@@ -70,7 +70,7 @@ pub const CacheHash = struct {...@@ -70,7 +70,7 @@ pub const CacheHash = struct {
7070
71 /// Convert the input value into bytes and record it as a dependency of the71 /// Convert the input value into bytes and record it as a dependency of the
72 /// process being cached72 /// process being cached
73 pub fn add(self: *CacheHash, val: var) void {73 pub fn add(self: *CacheHash, val: anytype) void {
74 assert(self.manifest_file == null);74 assert(self.manifest_file == null);
7575
76 const valPtr = switch (@typeInfo(@TypeOf(val))) {76 const valPtr = switch (@typeInfo(@TypeOf(val))) {
lib/std/comptime_string_map.zig+3-3
...@@ -8,7 +8,7 @@ const mem = std.mem;...@@ -8,7 +8,7 @@ const mem = std.mem;
8/// `kvs` expects a list literal containing list literals or an array/slice of structs8/// `kvs` expects a list literal containing list literals or an array/slice of structs
9/// where `.@"0"` is the `[]const u8` key and `.@"1"` is the associated value of type `V`.9/// where `.@"0"` is the `[]const u8` key and `.@"1"` is the associated value of type `V`.
10/// TODO: https://github.com/ziglang/zig/issues/433510/// 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 {
12 const precomputed = comptime blk: {12 const precomputed = comptime blk: {
13 @setEvalBranchQuota(2000);13 @setEvalBranchQuota(2000);
14 const KV = struct {14 const KV = struct {
...@@ -126,7 +126,7 @@ test "ComptimeStringMap slice of structs" {...@@ -126,7 +126,7 @@ test "ComptimeStringMap slice of structs" {
126 testMap(map);126 testMap(map);
127}127}
128128
129fn testMap(comptime map: var) void {129fn testMap(comptime map: anytype) void {
130 std.testing.expectEqual(TestEnum.A, map.get("have").?);130 std.testing.expectEqual(TestEnum.A, map.get("have").?);
131 std.testing.expectEqual(TestEnum.B, map.get("nothing").?);131 std.testing.expectEqual(TestEnum.B, map.get("nothing").?);
132 std.testing.expect(null == map.get("missing"));132 std.testing.expect(null == map.get("missing"));
...@@ -165,7 +165,7 @@ test "ComptimeStringMap void value type, list literal of list literals" {...@@ -165,7 +165,7 @@ test "ComptimeStringMap void value type, list literal of list literals" {
165 testSet(map);165 testSet(map);
166}166}
167167
168fn testSet(comptime map: var) void {168fn testSet(comptime map: anytype) void {
169 std.testing.expectEqual({}, map.get("have").?);169 std.testing.expectEqual({}, map.get("have").?);
170 std.testing.expectEqual({}, map.get("nothing").?);170 std.testing.expectEqual({}, map.get("nothing").?);
171 std.testing.expect(null == map.get("missing"));171 std.testing.expect(null == map.get("missing"));
lib/std/crypto/benchmark.zig+6-6
...@@ -29,7 +29,7 @@ const hashes = [_]Crypto{...@@ -29,7 +29,7 @@ const hashes = [_]Crypto{
29 Crypto{ .ty = crypto.Blake3, .name = "blake3" },29 Crypto{ .ty = crypto.Blake3, .name = "blake3" },
30};30};
3131
32pub fn benchmarkHash(comptime Hash: var, comptime bytes: comptime_int) !u64 {32pub fn benchmarkHash(comptime Hash: anytype, comptime bytes: comptime_int) !u64 {
33 var h = Hash.init();33 var h = Hash.init();
3434
35 var block: [Hash.digest_length]u8 = undefined;35 var block: [Hash.digest_length]u8 = undefined;
...@@ -56,7 +56,7 @@ const macs = [_]Crypto{...@@ -56,7 +56,7 @@ const macs = [_]Crypto{
56 Crypto{ .ty = crypto.HmacSha256, .name = "hmac-sha256" },56 Crypto{ .ty = crypto.HmacSha256, .name = "hmac-sha256" },
57};57};
5858
59pub fn benchmarkMac(comptime Mac: var, comptime bytes: comptime_int) !u64 {59pub fn benchmarkMac(comptime Mac: anytype, comptime bytes: comptime_int) !u64 {
60 std.debug.assert(32 >= Mac.mac_length and 32 >= Mac.minimum_key_length);60 std.debug.assert(32 >= Mac.mac_length and 32 >= Mac.minimum_key_length);
6161
62 var in: [1 * MiB]u8 = undefined;62 var in: [1 * MiB]u8 = undefined;
...@@ -81,7 +81,7 @@ pub fn benchmarkMac(comptime Mac: var, comptime bytes: comptime_int) !u64 {...@@ -81,7 +81,7 @@ pub fn benchmarkMac(comptime Mac: var, comptime bytes: comptime_int) !u64 {
8181
82const exchanges = [_]Crypto{Crypto{ .ty = crypto.X25519, .name = "x25519" }};82const 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 {
85 std.debug.assert(DhKeyExchange.minimum_key_length >= DhKeyExchange.secret_length);85 std.debug.assert(DhKeyExchange.minimum_key_length >= DhKeyExchange.secret_length);
8686
87 var in: [DhKeyExchange.minimum_key_length]u8 = undefined;87 var in: [DhKeyExchange.minimum_key_length]u8 = undefined;
...@@ -166,21 +166,21 @@ pub fn main() !void {...@@ -166,21 +166,21 @@ pub fn main() !void {
166 inline for (hashes) |H| {166 inline for (hashes) |H| {
167 if (filter == null or std.mem.indexOf(u8, H.name, filter.?) != null) {167 if (filter == null or std.mem.indexOf(u8, H.name, filter.?) != null) {
168 const throughput = try benchmarkHash(H.ty, mode(32 * MiB));168 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) });
170 }170 }
171 }171 }
172172
173 inline for (macs) |M| {173 inline for (macs) |M| {
174 if (filter == null or std.mem.indexOf(u8, M.name, filter.?) != null) {174 if (filter == null or std.mem.indexOf(u8, M.name, filter.?) != null) {
175 const throughput = try benchmarkMac(M.ty, mode(128 * MiB));175 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) });
177 }177 }
178 }178 }
179179
180 inline for (exchanges) |E| {180 inline for (exchanges) |E| {
181 if (filter == null or std.mem.indexOf(u8, E.name, filter.?) != null) {181 if (filter == null or std.mem.indexOf(u8, E.name, filter.?) != null) {
182 const throughput = try benchmarkKeyExchange(E.ty, mode(1000));182 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 });
184 }184 }
185 }185 }
186}186}
lib/std/crypto/test.zig+1-1
...@@ -4,7 +4,7 @@ const mem = std.mem;...@@ -4,7 +4,7 @@ const mem = std.mem;
4const fmt = std.fmt;4const fmt = std.fmt;
55
6// Hash using the specified hasher `H` asserting `expected == H(input)`.6// 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 {
8 var h: [expected.len / 2]u8 = undefined;8 var h: [expected.len / 2]u8 = undefined;
9 Hasher.hash(input, h[0..]);9 Hasher.hash(input, h[0..]);
1010
lib/std/debug.zig+12-12
...@@ -58,7 +58,7 @@ pub const warn = print;...@@ -58,7 +58,7 @@ pub const warn = print;
5858
59/// Print to stderr, unbuffered, and silently returning on failure. Intended59/// Print to stderr, unbuffered, and silently returning on failure. Intended
60/// for use in "printf debugging." Use `std.log` functions for proper logging.60/// 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 {
62 const held = stderr_mutex.acquire();62 const held = stderr_mutex.acquire();
63 defer held.release();63 defer held.release();
64 const stderr = io.getStdErr().writer();64 const stderr = io.getStdErr().writer();
...@@ -223,7 +223,7 @@ pub fn assert(ok: bool) void {...@@ -223,7 +223,7 @@ pub fn assert(ok: bool) void {
223 if (!ok) unreachable; // assertion failure223 if (!ok) unreachable; // assertion failure
224}224}
225225
226pub fn panic(comptime format: []const u8, args: var) noreturn {226pub fn panic(comptime format: []const u8, args: anytype) noreturn {
227 @setCold(true);227 @setCold(true);
228 // TODO: remove conditional once wasi / LLVM defines __builtin_return_address228 // TODO: remove conditional once wasi / LLVM defines __builtin_return_address
229 const first_trace_addr = if (builtin.os.tag == .wasi) null else @returnAddress();229 const first_trace_addr = if (builtin.os.tag == .wasi) null else @returnAddress();
...@@ -241,7 +241,7 @@ var panic_mutex = std.Mutex.init();...@@ -241,7 +241,7 @@ var panic_mutex = std.Mutex.init();
241/// This is used to catch and handle panics triggered by the panic handler.241/// This is used to catch and handle panics triggered by the panic handler.
242threadlocal var panic_stage: usize = 0;242threadlocal 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 {
245 @setCold(true);245 @setCold(true);
246246
247 if (enable_segfault_handler) {247 if (enable_segfault_handler) {
...@@ -306,7 +306,7 @@ const RESET = "\x1b[0m";...@@ -306,7 +306,7 @@ const RESET = "\x1b[0m";
306306
307pub fn writeStackTrace(307pub fn writeStackTrace(
308 stack_trace: builtin.StackTrace,308 stack_trace: builtin.StackTrace,
309 out_stream: var,309 out_stream: anytype,
310 allocator: *mem.Allocator,310 allocator: *mem.Allocator,
311 debug_info: *DebugInfo,311 debug_info: *DebugInfo,
312 tty_config: TTY.Config,312 tty_config: TTY.Config,
...@@ -384,7 +384,7 @@ pub const StackIterator = struct {...@@ -384,7 +384,7 @@ pub const StackIterator = struct {
384};384};
385385
386pub fn writeCurrentStackTrace(386pub fn writeCurrentStackTrace(
387 out_stream: var,387 out_stream: anytype,
388 debug_info: *DebugInfo,388 debug_info: *DebugInfo,
389 tty_config: TTY.Config,389 tty_config: TTY.Config,
390 start_addr: ?usize,390 start_addr: ?usize,
...@@ -399,7 +399,7 @@ pub fn writeCurrentStackTrace(...@@ -399,7 +399,7 @@ pub fn writeCurrentStackTrace(
399}399}
400400
401pub fn writeCurrentStackTraceWindows(401pub fn writeCurrentStackTraceWindows(
402 out_stream: var,402 out_stream: anytype,
403 debug_info: *DebugInfo,403 debug_info: *DebugInfo,
404 tty_config: TTY.Config,404 tty_config: TTY.Config,
405 start_addr: ?usize,405 start_addr: ?usize,
...@@ -435,7 +435,7 @@ pub const TTY = struct {...@@ -435,7 +435,7 @@ pub const TTY = struct {
435 // TODO give this a payload of file handle435 // TODO give this a payload of file handle
436 windows_api,436 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 {
439 nosuspend switch (conf) {439 nosuspend switch (conf) {
440 .no_color => return,440 .no_color => return,
441 .escape_codes => switch (color) {441 .escape_codes => switch (color) {
...@@ -555,7 +555,7 @@ fn machoSearchSymbols(symbols: []const MachoSymbol, address: usize) ?*const Mach...@@ -555,7 +555,7 @@ fn machoSearchSymbols(symbols: []const MachoSymbol, address: usize) ?*const Mach
555}555}
556556
557/// TODO resources https://github.com/ziglang/zig/issues/4353557/// 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 {
559 const module = debug_info.getModuleForAddress(address) catch |err| switch (err) {559 const module = debug_info.getModuleForAddress(address) catch |err| switch (err) {
560 error.MissingDebugInfo, error.InvalidDebugInfo => {560 error.MissingDebugInfo, error.InvalidDebugInfo => {
561 return printLineInfo(561 return printLineInfo(
...@@ -586,13 +586,13 @@ pub fn printSourceAtAddress(debug_info: *DebugInfo, out_stream: var, address: us...@@ -586,13 +586,13 @@ pub fn printSourceAtAddress(debug_info: *DebugInfo, out_stream: var, address: us
586}586}
587587
588fn printLineInfo(588fn printLineInfo(
589 out_stream: var,589 out_stream: anytype,
590 line_info: ?LineInfo,590 line_info: ?LineInfo,
591 address: usize,591 address: usize,
592 symbol_name: []const u8,592 symbol_name: []const u8,
593 compile_unit_name: []const u8,593 compile_unit_name: []const u8,
594 tty_config: TTY.Config,594 tty_config: TTY.Config,
595 comptime printLineFromFile: var,595 comptime printLineFromFile: anytype,
596) !void {596) !void {
597 nosuspend {597 nosuspend {
598 tty_config.setColor(out_stream, .White);598 tty_config.setColor(out_stream, .White);
...@@ -820,7 +820,7 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf...@@ -820,7 +820,7 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf
820 }820 }
821}821}
822822
823fn readSparseBitVector(stream: var, allocator: *mem.Allocator) ![]usize {823fn readSparseBitVector(stream: anytype, allocator: *mem.Allocator) ![]usize {
824 const num_words = try stream.readIntLittle(u32);824 const num_words = try stream.readIntLittle(u32);
825 var word_i: usize = 0;825 var word_i: usize = 0;
826 var list = ArrayList(usize).init(allocator);826 var list = ArrayList(usize).init(allocator);
...@@ -1004,7 +1004,7 @@ fn readMachODebugInfo(allocator: *mem.Allocator, macho_file: File) !ModuleDebugI...@@ -1004,7 +1004,7 @@ fn readMachODebugInfo(allocator: *mem.Allocator, macho_file: File) !ModuleDebugI
1004 };1004 };
1005}1005}
10061006
1007fn printLineFromFileAnyOs(out_stream: var, line_info: LineInfo) !void {1007fn printLineFromFileAnyOs(out_stream: anytype, line_info: LineInfo) !void {
1008 // Need this to always block even in async I/O mode, because this could potentially1008 // Need this to always block even in async I/O mode, because this could potentially
1009 // be called from e.g. the event loop code crashing.1009 // be called from e.g. the event loop code crashing.
1010 var f = try fs.cwd().openFile(line_info.file_name, .{ .intended_io_mode = .blocking });1010 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;...@@ -3,7 +3,7 @@ const testing = std.testing;
33
4/// Read a single unsigned LEB128 value from the given reader as type T,4/// Read a single unsigned LEB128 value from the given reader as type T,
5/// or error.Overflow if the value cannot fit.5/// 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 {
7 const U = if (T.bit_count < 8) u8 else T;7 const U = if (T.bit_count < 8) u8 else T;
8 const ShiftT = std.math.Log2Int(U);8 const ShiftT = std.math.Log2Int(U);
99
...@@ -33,7 +33,7 @@ pub fn readULEB128(comptime T: type, reader: var) !T {...@@ -33,7 +33,7 @@ pub fn readULEB128(comptime T: type, reader: var) !T {
33}33}
3434
35/// Write a single unsigned integer as unsigned LEB128 to the given writer.35/// 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 {
37 const T = @TypeOf(uint_value);37 const T = @TypeOf(uint_value);
38 const U = if (T.bit_count < 8) u8 else T;38 const U = if (T.bit_count < 8) u8 else T;
39 var value = @intCast(U, uint_value);39 var value = @intCast(U, uint_value);
...@@ -61,7 +61,7 @@ pub fn readULEB128Mem(comptime T: type, ptr: *[]const u8) !T {...@@ -61,7 +61,7 @@ pub fn readULEB128Mem(comptime T: type, ptr: *[]const u8) !T {
6161
62/// Write a single unsigned LEB128 integer to the given memory as unsigned LEB128,62/// Write a single unsigned LEB128 integer to the given memory as unsigned LEB128,
63/// returning the number of bytes written.63/// returning the number of bytes written.
64pub fn writeULEB128Mem(ptr: []u8, uint_value: var) !usize {64pub fn writeULEB128Mem(ptr: []u8, uint_value: anytype) !usize {
65 const T = @TypeOf(uint_value);65 const T = @TypeOf(uint_value);
66 const max_group = (T.bit_count + 6) / 7;66 const max_group = (T.bit_count + 6) / 7;
67 var buf = std.io.fixedBufferStream(ptr);67 var buf = std.io.fixedBufferStream(ptr);
...@@ -71,7 +71,7 @@ pub fn writeULEB128Mem(ptr: []u8, uint_value: var) !usize {...@@ -71,7 +71,7 @@ pub fn writeULEB128Mem(ptr: []u8, uint_value: var) !usize {
7171
72/// Read a single signed LEB128 value from the given reader as type T,72/// Read a single signed LEB128 value from the given reader as type T,
73/// or error.Overflow if the value cannot fit.73/// 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 {
75 const S = if (T.bit_count < 8) i8 else T;75 const S = if (T.bit_count < 8) i8 else T;
76 const U = std.meta.Int(false, S.bit_count);76 const U = std.meta.Int(false, S.bit_count);
77 const ShiftU = std.math.Log2Int(U);77 const ShiftU = std.math.Log2Int(U);
...@@ -120,7 +120,7 @@ pub fn readILEB128(comptime T: type, reader: var) !T {...@@ -120,7 +120,7 @@ pub fn readILEB128(comptime T: type, reader: var) !T {
120}120}
121121
122/// Write a single signed integer as signed LEB128 to the given writer.122/// 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 {
124 const T = @TypeOf(int_value);124 const T = @TypeOf(int_value);
125 const S = if (T.bit_count < 8) i8 else T;125 const S = if (T.bit_count < 8) i8 else T;
126 const U = std.meta.Int(false, S.bit_count);126 const U = std.meta.Int(false, S.bit_count);
...@@ -152,7 +152,7 @@ pub fn readILEB128Mem(comptime T: type, ptr: *[]const u8) !T {...@@ -152,7 +152,7 @@ pub fn readILEB128Mem(comptime T: type, ptr: *[]const u8) !T {
152152
153/// Write a single signed LEB128 integer to the given memory as unsigned LEB128,153/// Write a single signed LEB128 integer to the given memory as unsigned LEB128,
154/// returning the number of bytes written.154/// returning the number of bytes written.
155pub fn writeILEB128Mem(ptr: []u8, int_value: var) !usize {155pub fn writeILEB128Mem(ptr: []u8, int_value: anytype) !usize {
156 const T = @TypeOf(int_value);156 const T = @TypeOf(int_value);
157 var buf = std.io.fixedBufferStream(ptr);157 var buf = std.io.fixedBufferStream(ptr);
158 try writeILEB128(buf.writer(), int_value);158 try writeILEB128(buf.writer(), int_value);
...@@ -295,7 +295,7 @@ test "deserialize unsigned LEB128" {...@@ -295,7 +295,7 @@ test "deserialize unsigned LEB128" {
295 try test_read_uleb128_seq(u64, 4, "\x81\x01\x3f\x80\x7f\x80\x80\x80\x00");295 try test_read_uleb128_seq(u64, 4, "\x81\x01\x3f\x80\x7f\x80\x80\x80\x00");
296}296}
297297
298fn test_write_leb128(value: var) !void {298fn test_write_leb128(value: anytype) !void {
299 const T = @TypeOf(value);299 const T = @TypeOf(value);
300300
301 const writeStream = if (T.is_signed) writeILEB128 else writeULEB128;301 const writeStream = if (T.is_signed) writeILEB128 else writeULEB128;
lib/std/dwarf.zig+9-9
...@@ -236,7 +236,7 @@ const LineNumberProgram = struct {...@@ -236,7 +236,7 @@ const LineNumberProgram = struct {
236 }236 }
237};237};
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 {
240 const first_32_bits = try in_stream.readInt(u32, endian);240 const first_32_bits = try in_stream.readInt(u32, endian);
241 is_64.* = (first_32_bits == 0xffffffff);241 is_64.* = (first_32_bits == 0xffffffff);
242 if (is_64.*) {242 if (is_64.*) {
...@@ -249,7 +249,7 @@ fn readUnitLength(in_stream: var, endian: builtin.Endian, is_64: *bool) !u64 {...@@ -249,7 +249,7 @@ fn readUnitLength(in_stream: var, endian: builtin.Endian, is_64: *bool) !u64 {
249}249}
250250
251// TODO the nosuspends here are workarounds251// 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 {
253 const buf = try allocator.alloc(u8, size);253 const buf = try allocator.alloc(u8, size);
254 errdefer allocator.free(buf);254 errdefer allocator.free(buf);
255 if ((try nosuspend in_stream.read(buf)) < size) return error.EndOfFile;255 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...@@ -257,25 +257,25 @@ fn readAllocBytes(allocator: *mem.Allocator, in_stream: var, size: usize) ![]u8
257}257}
258258
259// TODO the nosuspends here are workarounds259// 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 {
261 return nosuspend if (is_64)261 return nosuspend if (is_64)
262 try in_stream.readInt(u64, endian)262 try in_stream.readInt(u64, endian)
263 else263 else
264 @as(u64, try in_stream.readInt(u32, endian));264 @as(u64, try in_stream.readInt(u32, endian));
265}265}
266266
267fn parseFormValueBlockLen(allocator: *mem.Allocator, in_stream: var, size: usize) !FormValue {267fn parseFormValueBlockLen(allocator: *mem.Allocator, in_stream: anytype, size: usize) !FormValue {
268 const buf = try readAllocBytes(allocator, in_stream, size);268 const buf = try readAllocBytes(allocator, in_stream, size);
269 return FormValue{ .Block = buf };269 return FormValue{ .Block = buf };
270}270}
271271
272// TODO the nosuspends here are workarounds272// 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 {
274 const block_len = try nosuspend in_stream.readVarInt(usize, endian, size);274 const block_len = try nosuspend in_stream.readVarInt(usize, endian, size);
275 return parseFormValueBlockLen(allocator, in_stream, block_len);275 return parseFormValueBlockLen(allocator, in_stream, block_len);
276}276}
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 {
279 // TODO: Please forgive me, I've worked around zig not properly spilling some intermediate values here.279 // TODO: Please forgive me, I've worked around zig not properly spilling some intermediate values here.
280 // `nosuspend` should be removed from all the function calls once it is fixed.280 // `nosuspend` should be removed from all the function calls once it is fixed.
281 return FormValue{281 return FormValue{
...@@ -302,7 +302,7 @@ fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: var, signed: boo...@@ -302,7 +302,7 @@ fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: var, signed: boo
302}302}
303303
304// TODO the nosuspends here are workarounds304// 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 {
306 return FormValue{306 return FormValue{
307 .Ref = switch (size) {307 .Ref = switch (size) {
308 1 => try nosuspend in_stream.readInt(u8, endian),308 1 => try nosuspend in_stream.readInt(u8, endian),
...@@ -316,7 +316,7 @@ fn parseFormValueRef(allocator: *mem.Allocator, in_stream: var, endian: builtin....@@ -316,7 +316,7 @@ fn parseFormValueRef(allocator: *mem.Allocator, in_stream: var, endian: builtin.
316}316}
317317
318// TODO the nosuspends here are workarounds318// 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 {
320 return switch (form_id) {320 return switch (form_id) {
321 FORM_addr => FormValue{ .Address = try readAddress(in_stream, endian, @sizeOf(usize) == 8) },321 FORM_addr => FormValue{ .Address = try readAddress(in_stream, endian, @sizeOf(usize) == 8) },
322 FORM_block1 => parseFormValueBlock(allocator, in_stream, endian, 1),322 FORM_block1 => parseFormValueBlock(allocator, in_stream, endian, 1),
...@@ -670,7 +670,7 @@ pub const DwarfInfo = struct {...@@ -670,7 +670,7 @@ pub const DwarfInfo = struct {
670 }670 }
671 }671 }
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 {
674 const abbrev_code = try leb.readULEB128(u64, in_stream);674 const abbrev_code = try leb.readULEB128(u64, in_stream);
675 if (abbrev_code == 0) return null;675 if (abbrev_code == 0) return null;
676 const table_entry = getAbbrevTableEntry(abbrev_table, abbrev_code) orelse return error.InvalidDebugInfo;676 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 {...@@ -517,7 +517,7 @@ pub fn readAllHeaders(allocator: *mem.Allocator, file: File) !AllHeaders {
517 return hdrs;517 return hdrs;
518}518}
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) {
521 if (is_64) {521 if (is_64) {
522 if (need_bswap) {522 if (need_bswap) {
523 return @byteSwap(@TypeOf(int_64), int_64);523 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_...@@ -529,7 +529,7 @@ pub fn int(is_64: bool, need_bswap: bool, int_32: var, int_64: var) @TypeOf(int_
529 }529 }
530}530}
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 {
533 if (need_bswap) {533 if (need_bswap) {
534 return @byteSwap(@TypeOf(int_32), int_32);534 return @byteSwap(@TypeOf(int_32), int_32);
535 } else {535 } else {
lib/std/event/group.zig+1-1
...@@ -65,7 +65,7 @@ pub fn Group(comptime ReturnType: type) type {...@@ -65,7 +65,7 @@ pub fn Group(comptime ReturnType: type) type {
65 /// allocated by the group and freed by `wait`.65 /// allocated by the group and freed by `wait`.
66 /// `func` must be async and have return type `ReturnType`.66 /// `func` must be async and have return type `ReturnType`.
67 /// Thread-safe.67 /// 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 {
69 var frame = try self.allocator.create(@TypeOf(@call(.{ .modifier = .async_kw }, func, args)));69 var frame = try self.allocator.create(@TypeOf(@call(.{ .modifier = .async_kw }, func, args)));
70 errdefer self.allocator.destroy(frame);70 errdefer self.allocator.destroy(frame);
71 const node = try self.allocator.create(AllocStack.Node);71 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 {...@@ -69,16 +69,16 @@ fn peekIsAlign(comptime fmt: []const u8) bool {
69///69///
70/// If a formatted user type contains a function of the type70/// If a formatted user type contains a function of the type
71/// ```71/// ```
72/// pub fn format(value: ?, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: var) !void72/// pub fn format(value: ?, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void
73/// ```73/// ```
74/// with `?` being the type formatted, this function will be called instead of the default implementation.74/// with `?` being the type formatted, this function will be called instead of the default implementation.
75/// This allows user types to be formatted in a logical manner instead of dumping all fields of the type.75/// This allows user types to be formatted in a logical manner instead of dumping all fields of the type.
76///76///
77/// A user type may be a `struct`, `vector`, `union` or `enum` type.77/// A user type may be a `struct`, `vector`, `union` or `enum` type.
78pub fn format(78pub fn format(
79 writer: var,79 writer: anytype,
80 comptime fmt: []const u8,80 comptime fmt: []const u8,
81 args: var,81 args: anytype,
82) !void {82) !void {
83 const ArgSetType = u32;83 const ArgSetType = u32;
84 if (@typeInfo(@TypeOf(args)) != .Struct) {84 if (@typeInfo(@TypeOf(args)) != .Struct) {
...@@ -311,10 +311,10 @@ pub fn format(...@@ -311,10 +311,10 @@ pub fn format(
311}311}
312312
313pub fn formatType(313pub fn formatType(
314 value: var,314 value: anytype,
315 comptime fmt: []const u8,315 comptime fmt: []const u8,
316 options: FormatOptions,316 options: FormatOptions,
317 writer: var,317 writer: anytype,
318 max_depth: usize,318 max_depth: usize,
319) @TypeOf(writer).Error!void {319) @TypeOf(writer).Error!void {
320 if (comptime std.mem.eql(u8, fmt, "*")) {320 if (comptime std.mem.eql(u8, fmt, "*")) {
...@@ -490,10 +490,10 @@ pub fn formatType(...@@ -490,10 +490,10 @@ pub fn formatType(
490}490}
491491
492fn formatValue(492fn formatValue(
493 value: var,493 value: anytype,
494 comptime fmt: []const u8,494 comptime fmt: []const u8,
495 options: FormatOptions,495 options: FormatOptions,
496 writer: var,496 writer: anytype,
497) !void {497) !void {
498 if (comptime std.mem.eql(u8, fmt, "B")) {498 if (comptime std.mem.eql(u8, fmt, "B")) {
499 return formatBytes(value, options, 1000, writer);499 return formatBytes(value, options, 1000, writer);
...@@ -511,10 +511,10 @@ fn formatValue(...@@ -511,10 +511,10 @@ fn formatValue(
511}511}
512512
513pub fn formatIntValue(513pub fn formatIntValue(
514 value: var,514 value: anytype,
515 comptime fmt: []const u8,515 comptime fmt: []const u8,
516 options: FormatOptions,516 options: FormatOptions,
517 writer: var,517 writer: anytype,
518) !void {518) !void {
519 comptime var radix = 10;519 comptime var radix = 10;
520 comptime var uppercase = false;520 comptime var uppercase = false;
...@@ -551,10 +551,10 @@ pub fn formatIntValue(...@@ -551,10 +551,10 @@ pub fn formatIntValue(
551}551}
552552
553fn formatFloatValue(553fn formatFloatValue(
554 value: var,554 value: anytype,
555 comptime fmt: []const u8,555 comptime fmt: []const u8,
556 options: FormatOptions,556 options: FormatOptions,
557 writer: var,557 writer: anytype,
558) !void {558) !void {
559 if (fmt.len == 0 or comptime std.mem.eql(u8, fmt, "e")) {559 if (fmt.len == 0 or comptime std.mem.eql(u8, fmt, "e")) {
560 return formatFloatScientific(value, options, writer);560 return formatFloatScientific(value, options, writer);
...@@ -569,7 +569,7 @@ pub fn formatText(...@@ -569,7 +569,7 @@ pub fn formatText(
569 bytes: []const u8,569 bytes: []const u8,
570 comptime fmt: []const u8,570 comptime fmt: []const u8,
571 options: FormatOptions,571 options: FormatOptions,
572 writer: var,572 writer: anytype,
573) !void {573) !void {
574 if (comptime std.mem.eql(u8, fmt, "s") or (fmt.len == 0)) {574 if (comptime std.mem.eql(u8, fmt, "s") or (fmt.len == 0)) {
575 return formatBuf(bytes, options, writer);575 return formatBuf(bytes, options, writer);
...@@ -586,7 +586,7 @@ pub fn formatText(...@@ -586,7 +586,7 @@ pub fn formatText(
586pub fn formatAsciiChar(586pub fn formatAsciiChar(
587 c: u8,587 c: u8,
588 options: FormatOptions,588 options: FormatOptions,
589 writer: var,589 writer: anytype,
590) !void {590) !void {
591 return writer.writeAll(@as(*const [1]u8, &c));591 return writer.writeAll(@as(*const [1]u8, &c));
592}592}
...@@ -594,7 +594,7 @@ pub fn formatAsciiChar(...@@ -594,7 +594,7 @@ pub fn formatAsciiChar(
594pub fn formatBuf(594pub fn formatBuf(
595 buf: []const u8,595 buf: []const u8,
596 options: FormatOptions,596 options: FormatOptions,
597 writer: var,597 writer: anytype,
598) !void {598) !void {
599 const width = options.width orelse buf.len;599 const width = options.width orelse buf.len;
600 var padding = if (width > buf.len) (width - buf.len) else 0;600 var padding = if (width > buf.len) (width - buf.len) else 0;
...@@ -626,9 +626,9 @@ pub fn formatBuf(...@@ -626,9 +626,9 @@ pub fn formatBuf(
626// It should be the case that every full precision, printed value can be re-parsed back to the626// It should be the case that every full precision, printed value can be re-parsed back to the
627// same type unambiguously.627// same type unambiguously.
628pub fn formatFloatScientific(628pub fn formatFloatScientific(
629 value: var,629 value: anytype,
630 options: FormatOptions,630 options: FormatOptions,
631 writer: var,631 writer: anytype,
632) !void {632) !void {
633 var x = @floatCast(f64, value);633 var x = @floatCast(f64, value);
634634
...@@ -719,9 +719,9 @@ pub fn formatFloatScientific(...@@ -719,9 +719,9 @@ pub fn formatFloatScientific(
719// Print a float of the format x.yyyyy where the number of y is specified by the precision argument.719// Print a float of the format x.yyyyy where the number of y is specified by the precision argument.
720// By default floats are printed at full precision (no rounding).720// By default floats are printed at full precision (no rounding).
721pub fn formatFloatDecimal(721pub fn formatFloatDecimal(
722 value: var,722 value: anytype,
723 options: FormatOptions,723 options: FormatOptions,
724 writer: var,724 writer: anytype,
725) !void {725) !void {
726 var x = @as(f64, value);726 var x = @as(f64, value);
727727
...@@ -860,10 +860,10 @@ pub fn formatFloatDecimal(...@@ -860,10 +860,10 @@ pub fn formatFloatDecimal(
860}860}
861861
862pub fn formatBytes(862pub fn formatBytes(
863 value: var,863 value: anytype,
864 options: FormatOptions,864 options: FormatOptions,
865 comptime radix: usize,865 comptime radix: usize,
866 writer: var,866 writer: anytype,
867) !void {867) !void {
868 if (value == 0) {868 if (value == 0) {
869 return writer.writeAll("0B");869 return writer.writeAll("0B");
...@@ -901,11 +901,11 @@ pub fn formatBytes(...@@ -901,11 +901,11 @@ pub fn formatBytes(
901}901}
902902
903pub fn formatInt(903pub fn formatInt(
904 value: var,904 value: anytype,
905 base: u8,905 base: u8,
906 uppercase: bool,906 uppercase: bool,
907 options: FormatOptions,907 options: FormatOptions,
908 writer: var,908 writer: anytype,
909) !void {909) !void {
910 const int_value = if (@TypeOf(value) == comptime_int) blk: {910 const int_value = if (@TypeOf(value) == comptime_int) blk: {
911 const Int = math.IntFittingRange(value, value);911 const Int = math.IntFittingRange(value, value);
...@@ -921,11 +921,11 @@ pub fn formatInt(...@@ -921,11 +921,11 @@ pub fn formatInt(
921}921}
922922
923fn formatIntSigned(923fn formatIntSigned(
924 value: var,924 value: anytype,
925 base: u8,925 base: u8,
926 uppercase: bool,926 uppercase: bool,
927 options: FormatOptions,927 options: FormatOptions,
928 writer: var,928 writer: anytype,
929) !void {929) !void {
930 const new_options = FormatOptions{930 const new_options = FormatOptions{
931 .width = if (options.width) |w| (if (w == 0) 0 else w - 1) else null,931 .width = if (options.width) |w| (if (w == 0) 0 else w - 1) else null,
...@@ -948,11 +948,11 @@ fn formatIntSigned(...@@ -948,11 +948,11 @@ fn formatIntSigned(
948}948}
949949
950fn formatIntUnsigned(950fn formatIntUnsigned(
951 value: var,951 value: anytype,
952 base: u8,952 base: u8,
953 uppercase: bool,953 uppercase: bool,
954 options: FormatOptions,954 options: FormatOptions,
955 writer: var,955 writer: anytype,
956) !void {956) !void {
957 assert(base >= 2);957 assert(base >= 2);
958 var buf: [math.max(@TypeOf(value).bit_count, 1)]u8 = undefined;958 var buf: [math.max(@TypeOf(value).bit_count, 1)]u8 = undefined;
...@@ -990,7 +990,7 @@ fn formatIntUnsigned(...@@ -990,7 +990,7 @@ fn formatIntUnsigned(
990 }990 }
991}991}
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 {
994 var fbs = std.io.fixedBufferStream(out_buf);994 var fbs = std.io.fixedBufferStream(out_buf);
995 formatInt(value, base, uppercase, options, fbs.writer()) catch unreachable;995 formatInt(value, base, uppercase, options, fbs.writer()) catch unreachable;
996 return fbs.pos;996 return fbs.pos;
...@@ -1050,7 +1050,7 @@ fn parseWithSign(...@@ -1050,7 +1050,7 @@ fn parseWithSign(
1050 .Pos => math.add,1050 .Pos => math.add,
1051 .Neg => math.sub,1051 .Neg => math.sub,
1052 };1052 };
1053 1053
1054 var x: T = 0;1054 var x: T = 0;
10551055
1056 for (buf) |c| {1056 for (buf) |c| {
...@@ -1132,14 +1132,14 @@ pub const BufPrintError = error{...@@ -1132,14 +1132,14 @@ pub const BufPrintError = error{
1132 /// As much as possible was written to the buffer, but it was too small to fit all the printed bytes.1132 /// As much as possible was written to the buffer, but it was too small to fit all the printed bytes.
1133 NoSpaceLeft,1133 NoSpaceLeft,
1134};1134};
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 {
1136 var fbs = std.io.fixedBufferStream(buf);1136 var fbs = std.io.fixedBufferStream(buf);
1137 try format(fbs.writer(), fmt, args);1137 try format(fbs.writer(), fmt, args);
1138 return fbs.getWritten();1138 return fbs.getWritten();
1139}1139}
11401140
1141// Count the characters needed for format. Useful for preallocating memory1141// 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 {
1143 var counting_writer = std.io.countingWriter(std.io.null_writer);1143 var counting_writer = std.io.countingWriter(std.io.null_writer);
1144 format(counting_writer.writer(), fmt, args) catch |err| switch (err) {};1144 format(counting_writer.writer(), fmt, args) catch |err| switch (err) {};
1145 return counting_writer.bytes_written;1145 return counting_writer.bytes_written;
...@@ -1147,7 +1147,7 @@ pub fn count(comptime fmt: []const u8, args: var) u64 {...@@ -1147,7 +1147,7 @@ pub fn count(comptime fmt: []const u8, args: var) u64 {
11471147
1148pub const AllocPrintError = error{OutOfMemory};1148pub 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 {
1151 const size = math.cast(usize, count(fmt, args)) catch |err| switch (err) {1151 const size = math.cast(usize, count(fmt, args)) catch |err| switch (err) {
1152 // Output too long. Can't possibly allocate enough memory to display it.1152 // Output too long. Can't possibly allocate enough memory to display it.
1153 error.Overflow => return error.OutOfMemory,1153 error.Overflow => return error.OutOfMemory,
...@@ -1158,7 +1158,7 @@ pub fn allocPrint(allocator: *mem.Allocator, comptime fmt: []const u8, args: var...@@ -1158,7 +1158,7 @@ pub fn allocPrint(allocator: *mem.Allocator, comptime fmt: []const u8, args: var
1158 };1158 };
1159}1159}
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 {
1162 const result = try allocPrint(allocator, fmt ++ "\x00", args);1162 const result = try allocPrint(allocator, fmt ++ "\x00", args);
1163 return result[0 .. result.len - 1 :0];1163 return result[0 .. result.len - 1 :0];
1164}1164}
...@@ -1184,7 +1184,7 @@ test "bufPrintInt" {...@@ -1184,7 +1184,7 @@ test "bufPrintInt" {
1184 std.testing.expectEqualSlices(u8, "-42", bufPrintIntToSlice(buf, @as(i32, -42), 10, false, FormatOptions{ .width = 3 }));1184 std.testing.expectEqualSlices(u8, "-42", bufPrintIntToSlice(buf, @as(i32, -42), 10, false, FormatOptions{ .width = 3 }));
1185}1185}
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 {
1188 return buf[0..formatIntBuf(buf, value, base, uppercase, options)];1188 return buf[0..formatIntBuf(buf, value, base, uppercase, options)];
1189}1189}
11901190
...@@ -1452,7 +1452,7 @@ test "custom" {...@@ -1452,7 +1452,7 @@ test "custom" {
1452 self: SelfType,1452 self: SelfType,
1453 comptime fmt: []const u8,1453 comptime fmt: []const u8,
1454 options: FormatOptions,1454 options: FormatOptions,
1455 writer: var,1455 writer: anytype,
1456 ) !void {1456 ) !void {
1457 if (fmt.len == 0 or comptime std.mem.eql(u8, fmt, "p")) {1457 if (fmt.len == 0 or comptime std.mem.eql(u8, fmt, "p")) {
1458 return std.fmt.format(writer, "({d:.3},{d:.3})", .{ self.x, self.y });1458 return std.fmt.format(writer, "({d:.3},{d:.3})", .{ self.x, self.y });
...@@ -1573,7 +1573,7 @@ test "bytes.hex" {...@@ -1573,7 +1573,7 @@ test "bytes.hex" {
1573 try testFmt("lowercase: 000ebabe\n", "lowercase: {x}\n", .{bytes_with_zeros});1573 try testFmt("lowercase: 000ebabe\n", "lowercase: {x}\n", .{bytes_with_zeros});
1574}1574}
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 {
1577 var buf: [100]u8 = undefined;1577 var buf: [100]u8 = undefined;
1578 const result = try bufPrint(buf[0..], template, args);1578 const result = try bufPrint(buf[0..], template, args);
1579 if (mem.eql(u8, result, expected)) return;1579 if (mem.eql(u8, result, expected)) return;
...@@ -1669,7 +1669,7 @@ test "formatType max_depth" {...@@ -1669,7 +1669,7 @@ test "formatType max_depth" {
1669 self: SelfType,1669 self: SelfType,
1670 comptime fmt: []const u8,1670 comptime fmt: []const u8,
1671 options: FormatOptions,1671 options: FormatOptions,
1672 writer: var,1672 writer: anytype,
1673 ) !void {1673 ) !void {
1674 if (fmt.len == 0) {1674 if (fmt.len == 0) {
1675 return std.fmt.format(writer, "({d:.3},{d:.3})", .{ self.x, self.y });1675 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) {...@@ -29,7 +29,7 @@ pub const PreopenType = union(PreopenTypeTag) {
29 }29 }
30 }30 }
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 {
33 try out_stream.print("PreopenType{{ ", .{});33 try out_stream.print("PreopenType{{ ", .{});
34 switch (self) {34 switch (self) {
35 PreopenType.Dir => |path| try out_stream.print(".Dir = '{}'", .{path}),35 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 {...@@ -21,7 +21,7 @@ pub const HashStrategy = enum {
21};21};
2222
23/// Helper function to hash a pointer and mutate the strategy if needed.23/// 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 {
25 const info = @typeInfo(@TypeOf(key));25 const info = @typeInfo(@TypeOf(key));
2626
27 switch (info.Pointer.size) {27 switch (info.Pointer.size) {
...@@ -53,7 +53,7 @@ pub fn hashPointer(hasher: var, key: var, comptime strat: HashStrategy) void {...@@ -53,7 +53,7 @@ pub fn hashPointer(hasher: var, key: var, comptime strat: HashStrategy) void {
53}53}
5454
55/// Helper function to hash a set of contiguous objects, from an array or slice.55/// 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 {
57 switch (strat) {57 switch (strat) {
58 .Shallow => {58 .Shallow => {
59 // TODO detect via a trait when Key has no padding bits to59 // 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 {...@@ -73,7 +73,7 @@ pub fn hashArray(hasher: var, key: var, comptime strat: HashStrategy) void {
7373
74/// Provides generic hashing for any eligible type.74/// Provides generic hashing for any eligible type.
75/// Strategy is provided to determine if pointers should be followed or not.75/// 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 {
77 const Key = @TypeOf(key);77 const Key = @TypeOf(key);
78 switch (@typeInfo(Key)) {78 switch (@typeInfo(Key)) {
79 .NoReturn,79 .NoReturn,
...@@ -161,7 +161,7 @@ pub fn hash(hasher: var, key: var, comptime strat: HashStrategy) void {...@@ -161,7 +161,7 @@ pub fn hash(hasher: var, key: var, comptime strat: HashStrategy) void {
161/// Provides generic hashing for any eligible type.161/// Provides generic hashing for any eligible type.
162/// Only hashes `key` itself, pointers are not followed.162/// Only hashes `key` itself, pointers are not followed.
163/// Slices are rejected to avoid ambiguity on the user's intention.163/// 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 {
165 const Key = @TypeOf(key);165 const Key = @TypeOf(key);
166 if (comptime meta.trait.isSlice(Key)) {166 if (comptime meta.trait.isSlice(Key)) {
167 comptime assert(@hasDecl(std, "StringHashMap")); // detect when the following message needs updated167 comptime assert(@hasDecl(std, "StringHashMap")); // detect when the following message needs updated
...@@ -181,28 +181,28 @@ pub fn autoHash(hasher: var, key: var) void {...@@ -181,28 +181,28 @@ pub fn autoHash(hasher: var, key: var) void {
181const testing = std.testing;181const testing = std.testing;
182const Wyhash = std.hash.Wyhash;182const Wyhash = std.hash.Wyhash;
183183
184fn testHash(key: var) u64 {184fn testHash(key: anytype) u64 {
185 // Any hash could be used here, for testing autoHash.185 // Any hash could be used here, for testing autoHash.
186 var hasher = Wyhash.init(0);186 var hasher = Wyhash.init(0);
187 hash(&hasher, key, .Shallow);187 hash(&hasher, key, .Shallow);
188 return hasher.final();188 return hasher.final();
189}189}
190190
191fn testHashShallow(key: var) u64 {191fn testHashShallow(key: anytype) u64 {
192 // Any hash could be used here, for testing autoHash.192 // Any hash could be used here, for testing autoHash.
193 var hasher = Wyhash.init(0);193 var hasher = Wyhash.init(0);
194 hash(&hasher, key, .Shallow);194 hash(&hasher, key, .Shallow);
195 return hasher.final();195 return hasher.final();
196}196}
197197
198fn testHashDeep(key: var) u64 {198fn testHashDeep(key: anytype) u64 {
199 // Any hash could be used here, for testing autoHash.199 // Any hash could be used here, for testing autoHash.
200 var hasher = Wyhash.init(0);200 var hasher = Wyhash.init(0);
201 hash(&hasher, key, .Deep);201 hash(&hasher, key, .Deep);
202 return hasher.final();202 return hasher.final();
203}203}
204204
205fn testHashDeepRecursive(key: var) u64 {205fn testHashDeepRecursive(key: anytype) u64 {
206 // Any hash could be used here, for testing autoHash.206 // Any hash could be used here, for testing autoHash.
207 var hasher = Wyhash.init(0);207 var hasher = Wyhash.init(0);
208 hash(&hasher, key, .DeepRecursive);208 hash(&hasher, key, .DeepRecursive);
lib/std/hash/benchmark.zig+2-2
...@@ -88,7 +88,7 @@ const Result = struct {...@@ -88,7 +88,7 @@ const Result = struct {
8888
89const block_size: usize = 8 * 8192;89const block_size: usize = 8 * 8192;
9090
91pub fn benchmarkHash(comptime H: var, bytes: usize) !Result {91pub fn benchmarkHash(comptime H: anytype, bytes: usize) !Result {
92 var h = blk: {92 var h = blk: {
93 if (H.init_u8s) |init| {93 if (H.init_u8s) |init| {
94 break :blk H.ty.init(init);94 break :blk H.ty.init(init);
...@@ -119,7 +119,7 @@ pub fn benchmarkHash(comptime H: var, bytes: usize) !Result {...@@ -119,7 +119,7 @@ pub fn benchmarkHash(comptime H: var, bytes: usize) !Result {
119 };119 };
120}120}
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 {
123 const key_count = bytes / key_size;123 const key_count = bytes / key_size;
124 var block: [block_size]u8 = undefined;124 var block: [block_size]u8 = undefined;
125 prng.random.bytes(block[0..]);125 prng.random.bytes(block[0..]);
lib/std/hash/cityhash.zig+1-1
...@@ -354,7 +354,7 @@ pub const CityHash64 = struct {...@@ -354,7 +354,7 @@ pub const CityHash64 = struct {
354 }354 }
355};355};
356356
357fn SMHasherTest(comptime hash_fn: var, comptime hashbits: u32) u32 {357fn SMHasherTest(comptime hash_fn: anytype, comptime hashbits: u32) u32 {
358 const hashbytes = hashbits / 8;358 const hashbytes = hashbits / 8;
359 var key: [256]u8 = undefined;359 var key: [256]u8 = undefined;
360 var hashes: [hashbytes * 256]u8 = undefined;360 var hashes: [hashbytes * 256]u8 = undefined;
lib/std/hash/murmur.zig+1-1
...@@ -279,7 +279,7 @@ pub const Murmur3_32 = struct {...@@ -279,7 +279,7 @@ pub const Murmur3_32 = struct {
279 }279 }
280};280};
281281
282fn SMHasherTest(comptime hash_fn: var, comptime hashbits: u32) u32 {282fn SMHasherTest(comptime hash_fn: anytype, comptime hashbits: u32) u32 {
283 const hashbytes = hashbits / 8;283 const hashbytes = hashbits / 8;
284 var key: [256]u8 = undefined;284 var key: [256]u8 = undefined;
285 var hashes: [hashbytes * 256]u8 = undefined;285 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;...@@ -15,15 +15,20 @@ pub const ArenaAllocator = @import("heap/arena_allocator.zig").ArenaAllocator;
1515
16const Allocator = mem.Allocator;16const Allocator = mem.Allocator;
1717
18usingnamespace if (comptime @hasDecl(c, "malloc_size")) struct {18usingnamespace if (comptime @hasDecl(c, "malloc_size"))
19 pub const supports_malloc_size = true;19 struct {
20 pub const malloc_size = c.malloc_size;20 pub const supports_malloc_size = true;
21} else if (comptime @hasDecl(c, "malloc_usable_size")) struct {21 pub const malloc_size = c.malloc_size;
22 pub const supports_malloc_size = true;22 }
23 pub const malloc_size = c.malloc_usable_size;23else if (comptime @hasDecl(c, "malloc_usable_size"))
24} else struct {24 struct {
25 pub const supports_malloc_size = false;25 pub const supports_malloc_size = true;
26};26 pub const malloc_size = c.malloc_usable_size;
27 }
28else
29 struct {
30 pub const supports_malloc_size = false;
31 };
2732
28pub const c_allocator = &c_allocator_state;33pub const c_allocator = &c_allocator_state;
29var c_allocator_state = Allocator{34var c_allocator_state = Allocator{
...@@ -151,8 +156,7 @@ const PageAllocator = struct {...@@ -151,8 +156,7 @@ const PageAllocator = struct {
151 }156 }
152157
153 const maxDropLen = alignment - std.math.min(alignment, mem.page_size);158 const maxDropLen = alignment - std.math.min(alignment, mem.page_size);
154 const allocLen = if (maxDropLen <= alignedLen - n) alignedLen159 const allocLen = if (maxDropLen <= alignedLen - n) alignedLen else mem.alignForward(alignedLen + maxDropLen, mem.page_size);
155 else mem.alignForward(alignedLen + maxDropLen, mem.page_size);
156 const slice = os.mmap(160 const slice = os.mmap(
157 null,161 null,
158 allocLen,162 allocLen,
...@@ -331,8 +335,7 @@ const WasmPageAllocator = struct {...@@ -331,8 +335,7 @@ const WasmPageAllocator = struct {
331 fn alloc(allocator: *Allocator, len: usize, alignment: u29, len_align: u29) error{OutOfMemory}![]u8 {335 fn alloc(allocator: *Allocator, len: usize, alignment: u29, len_align: u29) error{OutOfMemory}![]u8 {
332 const page_count = nPages(len);336 const page_count = nPages(len);
333 const page_idx = try allocPages(page_count, alignment);337 const page_idx = try allocPages(page_count, alignment);
334 return @intToPtr([*]u8, page_idx * mem.page_size)338 return @intToPtr([*]u8, page_idx * mem.page_size)[0..alignPageAllocLen(page_count * mem.page_size, len, len_align)];
335 [0..alignPageAllocLen(page_count * mem.page_size, len, len_align)];
336 }339 }
337 fn allocPages(page_count: usize, alignment: u29) !usize {340 fn allocPages(page_count: usize, alignment: u29) !usize {
338 {341 {
...@@ -452,7 +455,7 @@ pub const HeapAllocator = switch (builtin.os.tag) {...@@ -452,7 +455,7 @@ pub const HeapAllocator = switch (builtin.os.tag) {
452 fn resize(allocator: *Allocator, buf: []u8, new_size: usize, len_align: u29) error{OutOfMemory}!usize {455 fn resize(allocator: *Allocator, buf: []u8, new_size: usize, len_align: u29) error{OutOfMemory}!usize {
453 const self = @fieldParentPtr(HeapAllocator, "allocator", allocator);456 const self = @fieldParentPtr(HeapAllocator, "allocator", allocator);
454 if (new_size == 0) {457 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).*));
456 return 0;459 return 0;
457 }460 }
458461
lib/std/heap/logging_allocator.zig+2-2
...@@ -40,7 +40,7 @@ pub fn LoggingAllocator(comptime OutStreamType: type) type {...@@ -40,7 +40,7 @@ pub fn LoggingAllocator(comptime OutStreamType: type) type {
40 if (new_len == 0) {40 if (new_len == 0) {
41 self.out_stream.print("free : {}\n", .{buf.len}) catch {};41 self.out_stream.print("free : {}\n", .{buf.len}) catch {};
42 } else if (new_len <= buf.len) {42 } 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 {};
44 } else {44 } else {
45 self.out_stream.print("expand: {} to {}", .{ buf.len, new_len }) catch {};45 self.out_stream.print("expand: {} to {}", .{ buf.len, new_len }) catch {};
46 }46 }
...@@ -60,7 +60,7 @@ pub fn LoggingAllocator(comptime OutStreamType: type) type {...@@ -60,7 +60,7 @@ pub fn LoggingAllocator(comptime OutStreamType: type) type {
6060
61pub fn loggingAllocator(61pub fn loggingAllocator(
62 parent_allocator: *Allocator,62 parent_allocator: *Allocator,
63 out_stream: var,63 out_stream: anytype,
64) LoggingAllocator(@TypeOf(out_stream)) {64) LoggingAllocator(@TypeOf(out_stream)) {
65 return LoggingAllocator(@TypeOf(out_stream)).init(parent_allocator, out_stream);65 return LoggingAllocator(@TypeOf(out_stream)).init(parent_allocator, out_stream);
66}66}
lib/std/http/headers.zig+1-1
...@@ -348,7 +348,7 @@ pub const Headers = struct {...@@ -348,7 +348,7 @@ pub const Headers = struct {
348 self: Self,348 self: Self,
349 comptime fmt: []const u8,349 comptime fmt: []const u8,
350 options: std.fmt.FormatOptions,350 options: std.fmt.FormatOptions,
351 out_stream: var,351 out_stream: anytype,
352 ) !void {352 ) !void {
353 for (self.toSlice()) |entry| {353 for (self.toSlice()) |entry| {
354 try out_stream.writeAll(entry.name);354 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 {...@@ -170,7 +170,7 @@ pub fn BitReader(endian: builtin.Endian, comptime ReaderType: type) type {
170170
171pub fn bitReader(171pub fn bitReader(
172 comptime endian: builtin.Endian,172 comptime endian: builtin.Endian,
173 underlying_stream: var,173 underlying_stream: anytype,
174) BitReader(endian, @TypeOf(underlying_stream)) {174) BitReader(endian, @TypeOf(underlying_stream)) {
175 return BitReader(endian, @TypeOf(underlying_stream)).init(underlying_stream);175 return BitReader(endian, @TypeOf(underlying_stream)).init(underlying_stream);
176}176}
lib/std/io/bit_writer.zig+2-2
...@@ -34,7 +34,7 @@ pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type {...@@ -34,7 +34,7 @@ pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type {
34 /// Write the specified number of bits to the stream from the least significant bits of34 /// Write the specified number of bits to the stream from the least significant bits of
35 /// the specified unsigned int value. Bits will only be written to the stream when there35 /// the specified unsigned int value. Bits will only be written to the stream when there
36 /// are enough to fill a byte.36 /// 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 {
38 if (bits == 0) return;38 if (bits == 0) return;
3939
40 const U = @TypeOf(value);40 const U = @TypeOf(value);
...@@ -145,7 +145,7 @@ pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type {...@@ -145,7 +145,7 @@ pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type {
145145
146pub fn bitWriter(146pub fn bitWriter(
147 comptime endian: builtin.Endian,147 comptime endian: builtin.Endian,
148 underlying_stream: var,148 underlying_stream: anytype,
149) BitWriter(endian, @TypeOf(underlying_stream)) {149) BitWriter(endian, @TypeOf(underlying_stream)) {
150 return BitWriter(endian, @TypeOf(underlying_stream)).init(underlying_stream);150 return BitWriter(endian, @TypeOf(underlying_stream)).init(underlying_stream);
151}151}
lib/std/io/buffered_reader.zig+1-1
...@@ -48,7 +48,7 @@ pub fn BufferedReader(comptime buffer_size: usize, comptime ReaderType: type) ty...@@ -48,7 +48,7 @@ pub fn BufferedReader(comptime buffer_size: usize, comptime ReaderType: type) ty
48 };48 };
49}49}
5050
51pub fn bufferedReader(underlying_stream: var) BufferedReader(4096, @TypeOf(underlying_stream)) {51pub fn bufferedReader(underlying_stream: anytype) BufferedReader(4096, @TypeOf(underlying_stream)) {
52 return .{ .unbuffered_reader = underlying_stream };52 return .{ .unbuffered_reader = underlying_stream };
53}53}
5454
lib/std/io/buffered_writer.zig+1-1
...@@ -43,6 +43,6 @@ pub fn BufferedWriter(comptime buffer_size: usize, comptime WriterType: type) ty...@@ -43,6 +43,6 @@ pub fn BufferedWriter(comptime buffer_size: usize, comptime WriterType: type) ty
43 };43 };
44}44}
4545
46pub fn bufferedWriter(underlying_stream: var) BufferedWriter(4096, @TypeOf(underlying_stream)) {46pub fn bufferedWriter(underlying_stream: anytype) BufferedWriter(4096, @TypeOf(underlying_stream)) {
47 return .{ .unbuffered_writer = underlying_stream };47 return .{ .unbuffered_writer = underlying_stream };
48}48}
lib/std/io/counting_writer.zig+1-1
...@@ -32,7 +32,7 @@ pub fn CountingWriter(comptime WriterType: type) type {...@@ -32,7 +32,7 @@ pub fn CountingWriter(comptime WriterType: type) type {
32 };32 };
33}33}
3434
35pub fn countingWriter(child_stream: var) CountingWriter(@TypeOf(child_stream)) {35pub fn countingWriter(child_stream: anytype) CountingWriter(@TypeOf(child_stream)) {
36 return .{ .bytes_written = 0, .child_stream = child_stream };36 return .{ .bytes_written = 0, .child_stream = child_stream };
37}37}
3838
lib/std/io/fixed_buffer_stream.zig+1-1
...@@ -127,7 +127,7 @@ pub fn FixedBufferStream(comptime Buffer: type) type {...@@ -127,7 +127,7 @@ pub fn FixedBufferStream(comptime Buffer: type) type {
127 };127 };
128}128}
129129
130pub fn fixedBufferStream(buffer: var) FixedBufferStream(NonSentinelSpan(@TypeOf(buffer))) {130pub fn fixedBufferStream(buffer: anytype) FixedBufferStream(NonSentinelSpan(@TypeOf(buffer))) {
131 return .{ .buffer = mem.span(buffer), .pos = 0 };131 return .{ .buffer = mem.span(buffer), .pos = 0 };
132}132}
133133
lib/std/io/multi_writer.zig+1-1
...@@ -43,7 +43,7 @@ pub fn MultiWriter(comptime Writers: type) type {...@@ -43,7 +43,7 @@ pub fn MultiWriter(comptime Writers: type) type {
43 };43 };
44}44}
4545
46pub fn multiWriter(streams: var) MultiWriter(@TypeOf(streams)) {46pub fn multiWriter(streams: anytype) MultiWriter(@TypeOf(streams)) {
47 return .{ .streams = streams };47 return .{ .streams = streams };
48}48}
4949
lib/std/io/peek_stream.zig+1-1
...@@ -80,7 +80,7 @@ pub fn PeekStream(...@@ -80,7 +80,7 @@ pub fn PeekStream(
8080
81pub fn peekStream(81pub fn peekStream(
82 comptime lookahead: comptime_int,82 comptime lookahead: comptime_int,
83 underlying_stream: var,83 underlying_stream: anytype,
84) PeekStream(.{ .Static = lookahead }, @TypeOf(underlying_stream)) {84) PeekStream(.{ .Static = lookahead }, @TypeOf(underlying_stream)) {
85 return PeekStream(.{ .Static = lookahead }, @TypeOf(underlying_stream)).init(underlying_stream);85 return PeekStream(.{ .Static = lookahead }, @TypeOf(underlying_stream)).init(underlying_stream);
86}86}
lib/std/io/serialization.zig+33-29
...@@ -16,14 +16,16 @@ pub const Packing = enum {...@@ -16,14 +16,16 @@ pub const Packing = enum {
16};16};
1717
18/// Creates a deserializer that deserializes types from any stream.18/// Creates a deserializer that deserializes types from any stream.
19/// If `is_packed` is true, the data stream is treated as bit-packed,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.20/// otherwise data is expected to be packed to the smallest byte.
21/// Types may implement a custom deserialization routine with a21/// Types may implement a custom deserialization routine with a
22/// function named `deserialize` in the form of:22/// function named `deserialize` in the form of:
23/// pub fn deserialize(self: *Self, deserializer: var) !void23/// ```
24/// which will be called when the deserializer is used to deserialize24/// pub fn deserialize(self: *Self, deserializer: anytype) !void
25/// that type. It will pass a pointer to the type instance to deserialize25/// ```
26/// into and a pointer to the deserializer struct.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.
27pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing, comptime ReaderType: type) type {29pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing, comptime ReaderType: type) type {
28 return struct {30 return struct {
29 in_stream: if (packing == .Bit) io.BitReader(endian, ReaderType) else ReaderType,31 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,...@@ -93,7 +95,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
93 }95 }
9496
95 /// Deserializes data into the type pointed to by `ptr`97 /// 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 {
97 const T = @TypeOf(ptr);99 const T = @TypeOf(ptr);
98 comptime assert(trait.is(.Pointer)(T));100 comptime assert(trait.is(.Pointer)(T));
99101
...@@ -108,7 +110,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,...@@ -108,7 +110,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
108 const C = comptime meta.Child(T);110 const C = comptime meta.Child(T);
109 const child_type_id = @typeInfo(C);111 const child_type_id = @typeInfo(C);
110112
111 //custom deserializer: fn(self: *Self, deserializer: var) !void113 //custom deserializer: fn(self: *Self, deserializer: anytype) !void
112 if (comptime trait.hasFn("deserialize")(C)) return C.deserialize(ptr, self);114 if (comptime trait.hasFn("deserialize")(C)) return C.deserialize(ptr, self);
113115
114 if (comptime trait.isPacked(C) and packing != .Bit) {116 if (comptime trait.isPacked(C) and packing != .Bit) {
...@@ -190,24 +192,26 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,...@@ -190,24 +192,26 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
190pub fn deserializer(192pub fn deserializer(
191 comptime endian: builtin.Endian,193 comptime endian: builtin.Endian,
192 comptime packing: Packing,194 comptime packing: Packing,
193 in_stream: var,195 in_stream: anytype,
194) Deserializer(endian, packing, @TypeOf(in_stream)) {196) Deserializer(endian, packing, @TypeOf(in_stream)) {
195 return Deserializer(endian, packing, @TypeOf(in_stream)).init(in_stream);197 return Deserializer(endian, packing, @TypeOf(in_stream)).init(in_stream);
196}198}
197199
198/// Creates a serializer that serializes types to any stream.200/// Creates a serializer that serializes types to any stream.
199/// If `is_packed` is true, the data will be bit-packed into the stream.201/// 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 done202/// 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.203/// 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 case204/// 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 specified205/// 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.206/// endianess, after which data will resume being written at the next byte boundary.
205/// Types may implement a custom serialization routine with a207/// Types may implement a custom serialization routine with a
206/// function named `serialize` in the form of:208/// function named `serialize` in the form of:
207/// pub fn serialize(self: Self, serializer: var) !void209/// ```
208/// which will be called when the serializer is used to serialize that type. It will210/// pub fn serialize(self: Self, serializer: anytype) !void
209/// pass a const pointer to the type instance to be serialized and a pointer211/// ```
210/// to the serializer struct.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.
211pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, comptime OutStreamType: type) type {215pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, comptime OutStreamType: type) type {
212 return struct {216 return struct {
213 out_stream: if (packing == .Bit) io.BitOutStream(endian, OutStreamType) else OutStreamType,217 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...@@ -229,7 +233,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
229 if (packing == .Bit) return self.out_stream.flushBits();233 if (packing == .Bit) return self.out_stream.flushBits();
230 }234 }
231235
232 fn serializeInt(self: *Self, value: var) Error!void {236 fn serializeInt(self: *Self, value: anytype) Error!void {
233 const T = @TypeOf(value);237 const T = @TypeOf(value);
234 comptime assert(trait.is(.Int)(T) or trait.is(.Float)(T));238 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...@@ -261,7 +265,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
261 }265 }
262266
263 /// Serializes the passed value into the stream267 /// 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 {
265 const T = comptime @TypeOf(value);269 const T = comptime @TypeOf(value);
266270
267 if (comptime trait.isIndexable(T)) {271 if (comptime trait.isIndexable(T)) {
...@@ -270,7 +274,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co...@@ -270,7 +274,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
270 return;274 return;
271 }275 }
272276
273 //custom serializer: fn(self: Self, serializer: var) !void277 //custom serializer: fn(self: Self, serializer: anytype) !void
274 if (comptime trait.hasFn("serialize")(T)) return T.serialize(value, self);278 if (comptime trait.hasFn("serialize")(T)) return T.serialize(value, self);
275279
276 if (comptime trait.isPacked(T) and packing != .Bit) {280 if (comptime trait.isPacked(T) and packing != .Bit) {
...@@ -346,7 +350,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co...@@ -346,7 +350,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
346pub fn serializer(350pub fn serializer(
347 comptime endian: builtin.Endian,351 comptime endian: builtin.Endian,
348 comptime packing: Packing,352 comptime packing: Packing,
349 out_stream: var,353 out_stream: anytype,
350) Serializer(endian, packing, @TypeOf(out_stream)) {354) Serializer(endian, packing, @TypeOf(out_stream)) {
351 return Serializer(endian, packing, @TypeOf(out_stream)).init(out_stream);355 return Serializer(endian, packing, @TypeOf(out_stream)).init(out_stream);
352}356}
...@@ -462,7 +466,7 @@ test "Serializer/Deserializer Int: Inf/NaN" {...@@ -462,7 +466,7 @@ test "Serializer/Deserializer Int: Inf/NaN" {
462 try testIntSerializerDeserializerInfNaN(.Little, .Bit);466 try testIntSerializerDeserializerInfNaN(.Little, .Bit);
463}467}
464468
465fn testAlternateSerializer(self: var, _serializer: var) !void {469fn testAlternateSerializer(self: anytype, _serializer: anytype) !void {
466 try _serializer.serialize(self.f_f16);470 try _serializer.serialize(self.f_f16);
467}471}
468472
...@@ -503,7 +507,7 @@ fn testSerializerDeserializer(comptime endian: builtin.Endian, comptime packing:...@@ -503,7 +507,7 @@ fn testSerializerDeserializer(comptime endian: builtin.Endian, comptime packing:
503 f_f16: f16,507 f_f16: f16,
504 f_unused_u32: u32,508 f_unused_u32: u32,
505509
506 pub fn deserialize(self: *@This(), _deserializer: var) !void {510 pub fn deserialize(self: *@This(), _deserializer: anytype) !void {
507 try _deserializer.deserializeInto(&self.f_f16);511 try _deserializer.deserializeInto(&self.f_f16);
508 self.f_unused_u32 = 47;512 self.f_unused_u32 = 47;
509 }513 }
lib/std/io/writer.zig+1-1
...@@ -24,7 +24,7 @@ pub fn Writer(...@@ -24,7 +24,7 @@ pub fn Writer(
24 }24 }
25 }25 }
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 {
28 return std.fmt.format(self, format, args);28 return std.fmt.format(self, format, args);
29 }29 }
3030
lib/std/json.zig+8-8
...@@ -239,7 +239,7 @@ pub const StreamingParser = struct {...@@ -239,7 +239,7 @@ pub const StreamingParser = struct {
239 NullLiteral3,239 NullLiteral3,
240240
241 // Only call this function to generate array/object final state.241 // Only call this function to generate array/object final state.
242 pub fn fromInt(x: var) State {242 pub fn fromInt(x: anytype) State {
243 debug.assert(x == 0 or x == 1);243 debug.assert(x == 0 or x == 1);
244 const T = @TagType(State);244 const T = @TagType(State);
245 return @intToEnum(State, @intCast(T, x));245 return @intToEnum(State, @intCast(T, x));
...@@ -1236,7 +1236,7 @@ pub const Value = union(enum) {...@@ -1236,7 +1236,7 @@ pub const Value = union(enum) {
1236 pub fn jsonStringify(1236 pub fn jsonStringify(
1237 value: @This(),1237 value: @This(),
1238 options: StringifyOptions,1238 options: StringifyOptions,
1239 out_stream: var,1239 out_stream: anytype,
1240 ) @TypeOf(out_stream).Error!void {1240 ) @TypeOf(out_stream).Error!void {
1241 switch (value) {1241 switch (value) {
1242 .Null => try stringify(null, options, out_stream),1242 .Null => try stringify(null, options, out_stream),
...@@ -2338,7 +2338,7 @@ pub const StringifyOptions = struct {...@@ -2338,7 +2338,7 @@ pub const StringifyOptions = struct {
23382338
2339 pub fn outputIndent(2339 pub fn outputIndent(
2340 whitespace: @This(),2340 whitespace: @This(),
2341 out_stream: var,2341 out_stream: anytype,
2342 ) @TypeOf(out_stream).Error!void {2342 ) @TypeOf(out_stream).Error!void {
2343 var char: u8 = undefined;2343 var char: u8 = undefined;
2344 var n_chars: usize = undefined;2344 var n_chars: usize = undefined;
...@@ -2380,7 +2380,7 @@ pub const StringifyOptions = struct {...@@ -2380,7 +2380,7 @@ pub const StringifyOptions = struct {
23802380
2381fn outputUnicodeEscape(2381fn outputUnicodeEscape(
2382 codepoint: u21,2382 codepoint: u21,
2383 out_stream: var,2383 out_stream: anytype,
2384) !void {2384) !void {
2385 if (codepoint <= 0xFFFF) {2385 if (codepoint <= 0xFFFF) {
2386 // If the character is in the Basic Multilingual Plane (U+0000 through U+FFFF),2386 // If the character is in the Basic Multilingual Plane (U+0000 through U+FFFF),
...@@ -2402,9 +2402,9 @@ fn outputUnicodeEscape(...@@ -2402,9 +2402,9 @@ fn outputUnicodeEscape(
2402}2402}
24032403
2404pub fn stringify(2404pub fn stringify(
2405 value: var,2405 value: anytype,
2406 options: StringifyOptions,2406 options: StringifyOptions,
2407 out_stream: var,2407 out_stream: anytype,
2408) @TypeOf(out_stream).Error!void {2408) @TypeOf(out_stream).Error!void {
2409 const T = @TypeOf(value);2409 const T = @TypeOf(value);
2410 switch (@typeInfo(T)) {2410 switch (@typeInfo(T)) {
...@@ -2584,7 +2584,7 @@ pub fn stringify(...@@ -2584,7 +2584,7 @@ pub fn stringify(
2584 unreachable;2584 unreachable;
2585}2585}
25862586
2587fn teststringify(expected: []const u8, value: var, options: StringifyOptions) !void {2587fn teststringify(expected: []const u8, value: anytype, options: StringifyOptions) !void {
2588 const ValidationOutStream = struct {2588 const ValidationOutStream = struct {
2589 const Self = @This();2589 const Self = @This();
2590 pub const OutStream = std.io.OutStream(*Self, Error, write);2590 pub const OutStream = std.io.OutStream(*Self, Error, write);
...@@ -2758,7 +2758,7 @@ test "stringify struct with custom stringifier" {...@@ -2758,7 +2758,7 @@ test "stringify struct with custom stringifier" {
2758 pub fn jsonStringify(2758 pub fn jsonStringify(
2759 value: Self,2759 value: Self,
2760 options: StringifyOptions,2760 options: StringifyOptions,
2761 out_stream: var,2761 out_stream: anytype,
2762 ) !void {2762 ) !void {
2763 try out_stream.writeAll("[\"something special\",");2763 try out_stream.writeAll("[\"something special\",");
2764 try stringify(42, options, out_stream);2764 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 {...@@ -152,7 +152,7 @@ pub fn WriteStream(comptime OutStream: type, comptime max_depth: usize) type {
152 self: *Self,152 self: *Self,
153 /// An integer, float, or `std.math.BigInt`. Emitted as a bare number if it fits losslessly153 /// An integer, float, or `std.math.BigInt`. Emitted as a bare number if it fits losslessly
154 /// in a IEEE 754 double float, otherwise emitted as a string to the full precision.154 /// in a IEEE 754 double float, otherwise emitted as a string to the full precision.
155 value: var,155 value: anytype,
156 ) !void {156 ) !void {
157 assert(self.state[self.state_index] == State.Value);157 assert(self.state[self.state_index] == State.Value);
158 switch (@typeInfo(@TypeOf(value))) {158 switch (@typeInfo(@TypeOf(value))) {
...@@ -215,7 +215,7 @@ pub fn WriteStream(comptime OutStream: type, comptime max_depth: usize) type {...@@ -215,7 +215,7 @@ pub fn WriteStream(comptime OutStream: type, comptime max_depth: usize) type {
215 self.state_index -= 1;215 self.state_index -= 1;
216 }216 }
217217
218 fn stringify(self: *Self, value: var) !void {218 fn stringify(self: *Self, value: anytype) !void {
219 try std.json.stringify(value, std.json.StringifyOptions{219 try std.json.stringify(value, std.json.StringifyOptions{
220 .whitespace = self.whitespace,220 .whitespace = self.whitespace,
221 }, self.stream);221 }, self.stream);
...@@ -224,7 +224,7 @@ pub fn WriteStream(comptime OutStream: type, comptime max_depth: usize) type {...@@ -224,7 +224,7 @@ pub fn WriteStream(comptime OutStream: type, comptime max_depth: usize) type {
224}224}
225225
226pub fn writeStream(226pub fn writeStream(
227 out_stream: var,227 out_stream: anytype,
228 comptime max_depth: usize,228 comptime max_depth: usize,
229) WriteStream(@TypeOf(out_stream), max_depth) {229) WriteStream(@TypeOf(out_stream), max_depth) {
230 return WriteStream(@TypeOf(out_stream), max_depth).init(out_stream);230 return WriteStream(@TypeOf(out_stream), max_depth).init(out_stream);
lib/std/log.zig+10-10
...@@ -22,7 +22,7 @@ const root = @import("root");...@@ -22,7 +22,7 @@ const root = @import("root");
22//! comptime level: std.log.Level,22//! comptime level: std.log.Level,
23//! comptime scope: @TypeOf(.EnumLiteral),23//! comptime scope: @TypeOf(.EnumLiteral),
24//! comptime format: []const u8,24//! comptime format: []const u8,
25//! args: var,25//! args: anytype,
26//! ) void {26//! ) void {
27//! // Ignore all non-critical logging from sources other than27//! // Ignore all non-critical logging from sources other than
28//! // .my_project and .nice_library28//! // .my_project and .nice_library
...@@ -101,7 +101,7 @@ fn log(...@@ -101,7 +101,7 @@ fn log(
101 comptime message_level: Level,101 comptime message_level: Level,
102 comptime scope: @Type(.EnumLiteral),102 comptime scope: @Type(.EnumLiteral),
103 comptime format: []const u8,103 comptime format: []const u8,
104 args: var,104 args: anytype,
105) void {105) void {
106 if (@enumToInt(message_level) <= @enumToInt(level)) {106 if (@enumToInt(message_level) <= @enumToInt(level)) {
107 if (@hasDecl(root, "log")) {107 if (@hasDecl(root, "log")) {
...@@ -120,7 +120,7 @@ fn log(...@@ -120,7 +120,7 @@ fn log(
120pub fn emerg(120pub fn emerg(
121 comptime scope: @Type(.EnumLiteral),121 comptime scope: @Type(.EnumLiteral),
122 comptime format: []const u8,122 comptime format: []const u8,
123 args: var,123 args: anytype,
124) void {124) void {
125 @setCold(true);125 @setCold(true);
126 log(.emerg, scope, format, args);126 log(.emerg, scope, format, args);
...@@ -131,7 +131,7 @@ pub fn emerg(...@@ -131,7 +131,7 @@ pub fn emerg(
131pub fn alert(131pub fn alert(
132 comptime scope: @Type(.EnumLiteral),132 comptime scope: @Type(.EnumLiteral),
133 comptime format: []const u8,133 comptime format: []const u8,
134 args: var,134 args: anytype,
135) void {135) void {
136 @setCold(true);136 @setCold(true);
137 log(.alert, scope, format, args);137 log(.alert, scope, format, args);
...@@ -143,7 +143,7 @@ pub fn alert(...@@ -143,7 +143,7 @@ pub fn alert(
143pub fn crit(143pub fn crit(
144 comptime scope: @Type(.EnumLiteral),144 comptime scope: @Type(.EnumLiteral),
145 comptime format: []const u8,145 comptime format: []const u8,
146 args: var,146 args: anytype,
147) void {147) void {
148 @setCold(true);148 @setCold(true);
149 log(.crit, scope, format, args);149 log(.crit, scope, format, args);
...@@ -154,7 +154,7 @@ pub fn crit(...@@ -154,7 +154,7 @@ pub fn crit(
154pub fn err(154pub fn err(
155 comptime scope: @Type(.EnumLiteral),155 comptime scope: @Type(.EnumLiteral),
156 comptime format: []const u8,156 comptime format: []const u8,
157 args: var,157 args: anytype,
158) void {158) void {
159 @setCold(true);159 @setCold(true);
160 log(.err, scope, format, args);160 log(.err, scope, format, args);
...@@ -166,7 +166,7 @@ pub fn err(...@@ -166,7 +166,7 @@ pub fn err(
166pub fn warn(166pub fn warn(
167 comptime scope: @Type(.EnumLiteral),167 comptime scope: @Type(.EnumLiteral),
168 comptime format: []const u8,168 comptime format: []const u8,
169 args: var,169 args: anytype,
170) void {170) void {
171 log(.warn, scope, format, args);171 log(.warn, scope, format, args);
172}172}
...@@ -176,7 +176,7 @@ pub fn warn(...@@ -176,7 +176,7 @@ pub fn warn(
176pub fn notice(176pub fn notice(
177 comptime scope: @Type(.EnumLiteral),177 comptime scope: @Type(.EnumLiteral),
178 comptime format: []const u8,178 comptime format: []const u8,
179 args: var,179 args: anytype,
180) void {180) void {
181 log(.notice, scope, format, args);181 log(.notice, scope, format, args);
182}182}
...@@ -186,7 +186,7 @@ pub fn notice(...@@ -186,7 +186,7 @@ pub fn notice(
186pub fn info(186pub fn info(
187 comptime scope: @Type(.EnumLiteral),187 comptime scope: @Type(.EnumLiteral),
188 comptime format: []const u8,188 comptime format: []const u8,
189 args: var,189 args: anytype,
190) void {190) void {
191 log(.info, scope, format, args);191 log(.info, scope, format, args);
192}192}
...@@ -196,7 +196,7 @@ pub fn info(...@@ -196,7 +196,7 @@ pub fn info(
196pub fn debug(196pub fn debug(
197 comptime scope: @Type(.EnumLiteral),197 comptime scope: @Type(.EnumLiteral),
198 comptime format: []const u8,198 comptime format: []const u8,
199 args: var,199 args: anytype,
200) void {200) void {
201 log(.debug, scope, format, args);201 log(.debug, scope, format, args);
202}202}
lib/std/math.zig+18-18
...@@ -104,7 +104,7 @@ pub fn approxEq(comptime T: type, x: T, y: T, epsilon: T) bool {...@@ -104,7 +104,7 @@ pub fn approxEq(comptime T: type, x: T, y: T, epsilon: T) bool {
104}104}
105105
106// TODO: Hide the following in an internal module.106// TODO: Hide the following in an internal module.
107pub fn forceEval(value: var) void {107pub fn forceEval(value: anytype) void {
108 const T = @TypeOf(value);108 const T = @TypeOf(value);
109 switch (T) {109 switch (T) {
110 f16 => {110 f16 => {
...@@ -259,7 +259,7 @@ pub fn Min(comptime A: type, comptime B: type) type {...@@ -259,7 +259,7 @@ pub fn Min(comptime A: type, comptime B: type) type {
259259
260/// Returns the smaller number. When one of the parameter's type's full range fits in the other,260/// Returns the smaller number. When one of the parameter's type's full range fits in the other,
261/// the return type is the smaller type.261/// 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)) {
263 const Result = Min(@TypeOf(x), @TypeOf(y));263 const Result = Min(@TypeOf(x), @TypeOf(y));
264 if (x < y) {264 if (x < y) {
265 // TODO Zig should allow this as an implicit cast because x is immutable and in this265 // TODO Zig should allow this as an implicit cast because x is immutable and in this
...@@ -310,7 +310,7 @@ test "math.min" {...@@ -310,7 +310,7 @@ test "math.min" {
310 }310 }
311}311}
312312
313pub fn max(x: var, y: var) @TypeOf(x, y) {313pub fn max(x: anytype, y: anytype) @TypeOf(x, y) {
314 return if (x > y) x else y;314 return if (x > y) x else y;
315}315}
316316
...@@ -318,7 +318,7 @@ test "math.max" {...@@ -318,7 +318,7 @@ test "math.max" {
318 testing.expect(max(@as(i32, -1), @as(i32, 2)) == 2);318 testing.expect(max(@as(i32, -1), @as(i32, 2)) == 2);
319}319}
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) {
322 assert(lower <= upper);322 assert(lower <= upper);
323 return max(lower, min(val, upper));323 return max(lower, min(val, upper));
324}324}
...@@ -354,7 +354,7 @@ pub fn sub(comptime T: type, a: T, b: T) (error{Overflow}!T) {...@@ -354,7 +354,7 @@ pub fn sub(comptime T: type, a: T, b: T) (error{Overflow}!T) {
354 return if (@subWithOverflow(T, a, b, &answer)) error.Overflow else answer;354 return if (@subWithOverflow(T, a, b, &answer)) error.Overflow else answer;
355}355}
356356
357pub fn negate(x: var) !@TypeOf(x) {357pub fn negate(x: anytype) !@TypeOf(x) {
358 return sub(@TypeOf(x), 0, x);358 return sub(@TypeOf(x), 0, x);
359}359}
360360
...@@ -365,7 +365,7 @@ pub fn shlExact(comptime T: type, a: T, shift_amt: Log2Int(T)) !T {...@@ -365,7 +365,7 @@ pub fn shlExact(comptime T: type, a: T, shift_amt: Log2Int(T)) !T {
365365
366/// Shifts left. Overflowed bits are truncated.366/// Shifts left. Overflowed bits are truncated.
367/// A negative shift amount results in a right shift.367/// 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 {
369 const abs_shift_amt = absCast(shift_amt);369 const abs_shift_amt = absCast(shift_amt);
370 const casted_shift_amt = if (abs_shift_amt >= T.bit_count) return 0 else @intCast(Log2Int(T), abs_shift_amt);370 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" {...@@ -391,7 +391,7 @@ test "math.shl" {
391391
392/// Shifts right. Overflowed bits are truncated.392/// Shifts right. Overflowed bits are truncated.
393/// A negative shift amount results in a left shift.393/// 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 {
395 const abs_shift_amt = absCast(shift_amt);395 const abs_shift_amt = absCast(shift_amt);
396 const casted_shift_amt = if (abs_shift_amt >= T.bit_count) return 0 else @intCast(Log2Int(T), abs_shift_amt);396 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" {...@@ -419,7 +419,7 @@ test "math.shr" {
419419
420/// Rotates right. Only unsigned values can be rotated.420/// Rotates right. Only unsigned values can be rotated.
421/// Negative shift values results in shift modulo the bit count.421/// 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 {
423 if (T.is_signed) {423 if (T.is_signed) {
424 @compileError("cannot rotate signed integer");424 @compileError("cannot rotate signed integer");
425 } else {425 } else {
...@@ -438,7 +438,7 @@ test "math.rotr" {...@@ -438,7 +438,7 @@ test "math.rotr" {
438438
439/// Rotates left. Only unsigned values can be rotated.439/// Rotates left. Only unsigned values can be rotated.
440/// Negative shift values results in shift modulo the bit count.440/// 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 {
442 if (T.is_signed) {442 if (T.is_signed) {
443 @compileError("cannot rotate signed integer");443 @compileError("cannot rotate signed integer");
444 } else {444 } else {
...@@ -541,7 +541,7 @@ fn testOverflow() void {...@@ -541,7 +541,7 @@ fn testOverflow() void {
541 testing.expect((shlExact(i32, 0b11, 4) catch unreachable) == 0b110000);541 testing.expect((shlExact(i32, 0b11, 4) catch unreachable) == 0b110000);
542}542}
543543
544pub fn absInt(x: var) !@TypeOf(x) {544pub fn absInt(x: anytype) !@TypeOf(x) {
545 const T = @TypeOf(x);545 const T = @TypeOf(x);
546 comptime assert(@typeInfo(T) == .Int); // must pass an integer to absInt546 comptime assert(@typeInfo(T) == .Int); // must pass an integer to absInt
547 comptime assert(T.is_signed); // must pass a signed integer to absInt547 comptime assert(T.is_signed); // must pass a signed integer to absInt
...@@ -689,7 +689,7 @@ fn testRem() void {...@@ -689,7 +689,7 @@ fn testRem() void {
689689
690/// Returns the absolute value of the integer parameter.690/// Returns the absolute value of the integer parameter.
691/// Result is an unsigned integer.691/// Result is an unsigned integer.
692pub fn absCast(x: var) switch (@typeInfo(@TypeOf(x))) {692pub fn absCast(x: anytype) switch (@typeInfo(@TypeOf(x))) {
693 .ComptimeInt => comptime_int,693 .ComptimeInt => comptime_int,
694 .Int => |intInfo| std.meta.Int(false, intInfo.bits),694 .Int => |intInfo| std.meta.Int(false, intInfo.bits),
695 else => @compileError("absCast only accepts integers"),695 else => @compileError("absCast only accepts integers"),
...@@ -724,7 +724,7 @@ test "math.absCast" {...@@ -724,7 +724,7 @@ test "math.absCast" {
724724
725/// Returns the negation of the integer parameter.725/// Returns the negation of the integer parameter.
726/// Result is a signed integer.726/// 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) {
728 if (@TypeOf(x).is_signed) return negate(x);728 if (@TypeOf(x).is_signed) return negate(x);
729729
730 const int = std.meta.Int(true, @TypeOf(x).bit_count);730 const int = std.meta.Int(true, @TypeOf(x).bit_count);
...@@ -747,7 +747,7 @@ test "math.negateCast" {...@@ -747,7 +747,7 @@ test "math.negateCast" {
747747
748/// Cast an integer to a different integer type. If the value doesn't fit,748/// Cast an integer to a different integer type. If the value doesn't fit,
749/// return an error.749/// 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) {
751 comptime assert(@typeInfo(T) == .Int); // must pass an integer751 comptime assert(@typeInfo(T) == .Int); // must pass an integer
752 comptime assert(@typeInfo(@TypeOf(x)) == .Int); // must pass an integer752 comptime assert(@typeInfo(@TypeOf(x)) == .Int); // must pass an integer
753 if (maxInt(@TypeOf(x)) > maxInt(T) and x > maxInt(T)) {753 if (maxInt(@TypeOf(x)) > maxInt(T) and x > maxInt(T)) {
...@@ -772,7 +772,7 @@ test "math.cast" {...@@ -772,7 +772,7 @@ test "math.cast" {
772pub const AlignCastError = error{UnalignedMemory};772pub const AlignCastError = error{UnalignedMemory};
773773
774/// Align cast a pointer but return an error if it's the wrong alignment774/// 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)) {
776 const addr = @ptrToInt(ptr);776 const addr = @ptrToInt(ptr);
777 if (addr % alignment != 0) {777 if (addr % alignment != 0) {
778 return error.UnalignedMemory;778 return error.UnalignedMemory;
...@@ -780,7 +780,7 @@ pub fn alignCast(comptime alignment: u29, ptr: var) AlignCastError!@TypeOf(@alig...@@ -780,7 +780,7 @@ pub fn alignCast(comptime alignment: u29, ptr: var) AlignCastError!@TypeOf(@alig
780 return @alignCast(alignment, ptr);780 return @alignCast(alignment, ptr);
781}781}
782782
783pub fn isPowerOfTwo(v: var) bool {783pub fn isPowerOfTwo(v: anytype) bool {
784 assert(v != 0);784 assert(v != 0);
785 return (v & (v - 1)) == 0;785 return (v & (v - 1)) == 0;
786}786}
...@@ -897,7 +897,7 @@ test "std.math.log2_int_ceil" {...@@ -897,7 +897,7 @@ test "std.math.log2_int_ceil" {
897 testing.expect(log2_int_ceil(u32, 10) == 4);897 testing.expect(log2_int_ceil(u32, 10) == 4);
898}898}
899899
900pub fn lossyCast(comptime T: type, value: var) T {900pub fn lossyCast(comptime T: type, value: anytype) T {
901 switch (@typeInfo(@TypeOf(value))) {901 switch (@typeInfo(@TypeOf(value))) {
902 .Int => return @intToFloat(T, value),902 .Int => return @intToFloat(T, value),
903 .Float => return @floatCast(T, value),903 .Float => return @floatCast(T, value),
...@@ -1031,7 +1031,7 @@ pub const Order = enum {...@@ -1031,7 +1031,7 @@ pub const Order = enum {
1031};1031};
10321032
1033/// Given two numbers, this function returns the order they are with respect to each other.1033/// 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 {
1035 if (a == b) {1035 if (a == b) {
1036 return .eq;1036 return .eq;
1037 } else if (a < b) {1037 } else if (a < b) {
...@@ -1062,7 +1062,7 @@ pub const CompareOperator = enum {...@@ -1062,7 +1062,7 @@ pub const CompareOperator = enum {
1062/// This function does the same thing as comparison operators, however the1062/// This function does the same thing as comparison operators, however the
1063/// operator is a runtime-known enum value. Works on any operands that1063/// operator is a runtime-known enum value. Works on any operands that
1064/// support comparison operators.1064/// support comparison operators.
1065pub fn compare(a: var, op: CompareOperator, b: var) bool {1065pub fn compare(a: anytype, op: CompareOperator, b: anytype) bool {
1066 return switch (op) {1066 return switch (op) {
1067 .lt => a < b,1067 .lt => a < b,
1068 .lte => a <= b,1068 .lte => a <= b,
lib/std/math/acos.zig+1-1
...@@ -12,7 +12,7 @@ const expect = std.testing.expect;...@@ -12,7 +12,7 @@ const expect = std.testing.expect;
12///12///
13/// Special cases:13/// Special cases:
14/// - acos(x) = nan if x < -1 or x > 114/// - acos(x) = nan if x < -1 or x > 1
15pub fn acos(x: var) @TypeOf(x) {15pub fn acos(x: anytype) @TypeOf(x) {
16 const T = @TypeOf(x);16 const T = @TypeOf(x);
17 return switch (T) {17 return switch (T) {
18 f32 => acos32(x),18 f32 => acos32(x),
lib/std/math/acosh.zig+1-1
...@@ -14,7 +14,7 @@ const expect = std.testing.expect;...@@ -14,7 +14,7 @@ const expect = std.testing.expect;
14/// Special cases:14/// Special cases:
15/// - acosh(x) = snan if x < 115/// - acosh(x) = snan if x < 1
16/// - acosh(nan) = nan16/// - acosh(nan) = nan
17pub fn acosh(x: var) @TypeOf(x) {17pub fn acosh(x: anytype) @TypeOf(x) {
18 const T = @TypeOf(x);18 const T = @TypeOf(x);
19 return switch (T) {19 return switch (T) {
20 f32 => acosh32(x),20 f32 => acosh32(x),
lib/std/math/asin.zig+1-1
...@@ -13,7 +13,7 @@ const expect = std.testing.expect;...@@ -13,7 +13,7 @@ const expect = std.testing.expect;
13/// Special Cases:13/// Special Cases:
14/// - asin(+-0) = +-014/// - asin(+-0) = +-0
15/// - asin(x) = nan if x < -1 or x > 115/// - asin(x) = nan if x < -1 or x > 1
16pub fn asin(x: var) @TypeOf(x) {16pub fn asin(x: anytype) @TypeOf(x) {
17 const T = @TypeOf(x);17 const T = @TypeOf(x);
18 return switch (T) {18 return switch (T) {
19 f32 => asin32(x),19 f32 => asin32(x),
lib/std/math/asinh.zig+1-1
...@@ -15,7 +15,7 @@ const maxInt = std.math.maxInt;...@@ -15,7 +15,7 @@ const maxInt = std.math.maxInt;
15/// - asinh(+-0) = +-015/// - asinh(+-0) = +-0
16/// - asinh(+-inf) = +-inf16/// - asinh(+-inf) = +-inf
17/// - asinh(nan) = nan17/// - asinh(nan) = nan
18pub fn asinh(x: var) @TypeOf(x) {18pub fn asinh(x: anytype) @TypeOf(x) {
19 const T = @TypeOf(x);19 const T = @TypeOf(x);
20 return switch (T) {20 return switch (T) {
21 f32 => asinh32(x),21 f32 => asinh32(x),
lib/std/math/atan.zig+1-1
...@@ -13,7 +13,7 @@ const expect = std.testing.expect;...@@ -13,7 +13,7 @@ const expect = std.testing.expect;
13/// Special Cases:13/// Special Cases:
14/// - atan(+-0) = +-014/// - atan(+-0) = +-0
15/// - atan(+-inf) = +-pi/215/// - atan(+-inf) = +-pi/2
16pub fn atan(x: var) @TypeOf(x) {16pub fn atan(x: anytype) @TypeOf(x) {
17 const T = @TypeOf(x);17 const T = @TypeOf(x);
18 return switch (T) {18 return switch (T) {
19 f32 => atan32(x),19 f32 => atan32(x),
lib/std/math/atanh.zig+1-1
...@@ -15,7 +15,7 @@ const maxInt = std.math.maxInt;...@@ -15,7 +15,7 @@ const maxInt = std.math.maxInt;
15/// - atanh(+-1) = +-inf with signal15/// - atanh(+-1) = +-inf with signal
16/// - atanh(x) = nan if |x| > 1 with signal16/// - atanh(x) = nan if |x| > 1 with signal
17/// - atanh(nan) = nan17/// - atanh(nan) = nan
18pub fn atanh(x: var) @TypeOf(x) {18pub fn atanh(x: anytype) @TypeOf(x) {
19 const T = @TypeOf(x);19 const T = @TypeOf(x);
20 return switch (T) {20 return switch (T) {
21 f32 => atanh_32(x),21 f32 => atanh_32(x),
lib/std/math/big/int.zig+10-10
...@@ -12,7 +12,7 @@ const assert = std.debug.assert;...@@ -12,7 +12,7 @@ const assert = std.debug.assert;
1212
13/// Returns the number of limbs needed to store `scalar`, which must be a13/// Returns the number of limbs needed to store `scalar`, which must be a
14/// primitive integer value.14/// primitive integer value.
15pub fn calcLimbLen(scalar: var) usize {15pub fn calcLimbLen(scalar: anytype) usize {
16 const T = @TypeOf(scalar);16 const T = @TypeOf(scalar);
17 switch (@typeInfo(T)) {17 switch (@typeInfo(T)) {
18 .Int => |info| {18 .Int => |info| {
...@@ -110,7 +110,7 @@ pub const Mutable = struct {...@@ -110,7 +110,7 @@ pub const Mutable = struct {
110 /// `value` is a primitive integer type.110 /// `value` is a primitive integer type.
111 /// Asserts the value fits within the provided `limbs_buffer`.111 /// Asserts the value fits within the provided `limbs_buffer`.
112 /// Note: `calcLimbLen` can be used to figure out how big an array to allocate for `limbs_buffer`.112 /// 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 {
114 limbs_buffer[0] = 0;114 limbs_buffer[0] = 0;
115 var self: Mutable = .{115 var self: Mutable = .{
116 .limbs = limbs_buffer,116 .limbs = limbs_buffer,
...@@ -169,7 +169,7 @@ pub const Mutable = struct {...@@ -169,7 +169,7 @@ pub const Mutable = struct {
169 /// Asserts the value fits within the limbs buffer.169 /// Asserts the value fits within the limbs buffer.
170 /// Note: `calcLimbLen` can be used to figure out how big the limbs buffer170 /// Note: `calcLimbLen` can be used to figure out how big the limbs buffer
171 /// needs to be to store a specific value.171 /// 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 {
173 const T = @TypeOf(value);173 const T = @TypeOf(value);
174174
175 switch (@typeInfo(T)) {175 switch (@typeInfo(T)) {
...@@ -281,7 +281,7 @@ pub const Mutable = struct {...@@ -281,7 +281,7 @@ pub const Mutable = struct {
281 ///281 ///
282 /// Asserts the result fits in `r`. An upper bound on the number of limbs needed by282 /// Asserts the result fits in `r`. An upper bound on the number of limbs needed by
283 /// r is `math.max(a.limbs.len, calcLimbLen(scalar)) + 1`.283 /// 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 {
285 var limbs: [calcLimbLen(scalar)]Limb = undefined;285 var limbs: [calcLimbLen(scalar)]Limb = undefined;
286 const operand = init(&limbs, scalar).toConst();286 const operand = init(&limbs, scalar).toConst();
287 return add(r, a, operand);287 return add(r, a, operand);
...@@ -1058,7 +1058,7 @@ pub const Const = struct {...@@ -1058,7 +1058,7 @@ pub const Const = struct {
1058 self: Const,1058 self: Const,
1059 comptime fmt: []const u8,1059 comptime fmt: []const u8,
1060 options: std.fmt.FormatOptions,1060 options: std.fmt.FormatOptions,
1061 out_stream: var,1061 out_stream: anytype,
1062 ) !void {1062 ) !void {
1063 comptime var radix = 10;1063 comptime var radix = 10;
1064 comptime var uppercase = false;1064 comptime var uppercase = false;
...@@ -1261,7 +1261,7 @@ pub const Const = struct {...@@ -1261,7 +1261,7 @@ pub const Const = struct {
1261 }1261 }
12621262
1263 /// Same as `order` but the right-hand operand is a primitive integer.1263 /// 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 {
1265 var limbs: [calcLimbLen(scalar)]Limb = undefined;1265 var limbs: [calcLimbLen(scalar)]Limb = undefined;
1266 const rhs = Mutable.init(&limbs, scalar);1266 const rhs = Mutable.init(&limbs, scalar);
1267 return order(lhs, rhs.toConst());1267 return order(lhs, rhs.toConst());
...@@ -1333,7 +1333,7 @@ pub const Managed = struct {...@@ -1333,7 +1333,7 @@ pub const Managed = struct {
1333 /// Creates a new `Managed` with value `value`.1333 /// Creates a new `Managed` with value `value`.
1334 ///1334 ///
1335 /// This is identical to an `init`, followed by a `set`.1335 /// 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 {
1337 var s = try Managed.init(allocator);1337 var s = try Managed.init(allocator);
1338 try s.set(value);1338 try s.set(value);
1339 return s;1339 return s;
...@@ -1496,7 +1496,7 @@ pub const Managed = struct {...@@ -1496,7 +1496,7 @@ pub const Managed = struct {
1496 }1496 }
14971497
1498 /// Sets an Managed to value. Value must be an primitive integer type.1498 /// 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 {
1500 try self.ensureCapacity(calcLimbLen(value));1500 try self.ensureCapacity(calcLimbLen(value));
1501 var m = self.toMutable();1501 var m = self.toMutable();
1502 m.set(value);1502 m.set(value);
...@@ -1549,7 +1549,7 @@ pub const Managed = struct {...@@ -1549,7 +1549,7 @@ pub const Managed = struct {
1549 self: Managed,1549 self: Managed,
1550 comptime fmt: []const u8,1550 comptime fmt: []const u8,
1551 options: std.fmt.FormatOptions,1551 options: std.fmt.FormatOptions,
1552 out_stream: var,1552 out_stream: anytype,
1553 ) !void {1553 ) !void {
1554 return self.toConst().format(fmt, options, out_stream);1554 return self.toConst().format(fmt, options, out_stream);
1555 }1555 }
...@@ -1607,7 +1607,7 @@ pub const Managed = struct {...@@ -1607,7 +1607,7 @@ pub const Managed = struct {
1607 /// scalar is a primitive integer type.1607 /// scalar is a primitive integer type.
1608 ///1608 ///
1609 /// Returns an error if memory could not be allocated.1609 /// 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 {
1611 try r.ensureCapacity(math.max(a.limbs.len, calcLimbLen(scalar)) + 1);1611 try r.ensureCapacity(math.max(a.limbs.len, calcLimbLen(scalar)) + 1);
1612 var m = r.toMutable();1612 var m = r.toMutable();
1613 m.addScalar(a, scalar);1613 m.addScalar(a, scalar);
lib/std/math/big/rational.zig+2-2
...@@ -43,7 +43,7 @@ pub const Rational = struct {...@@ -43,7 +43,7 @@ pub const Rational = struct {
43 }43 }
4444
45 /// Set a Rational from a primitive integer type.45 /// 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 {
47 try self.p.set(a);47 try self.p.set(a);
48 try self.q.set(1);48 try self.q.set(1);
49 }49 }
...@@ -280,7 +280,7 @@ pub const Rational = struct {...@@ -280,7 +280,7 @@ pub const Rational = struct {
280 }280 }
281281
282 /// Set a rational from an integer ratio.282 /// 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 {
284 try self.p.set(p);284 try self.p.set(p);
285 try self.q.set(q);285 try self.q.set(q);
286286
lib/std/math/cbrt.zig+1-1
...@@ -14,7 +14,7 @@ const expect = std.testing.expect;...@@ -14,7 +14,7 @@ const expect = std.testing.expect;
14/// - cbrt(+-0) = +-014/// - cbrt(+-0) = +-0
15/// - cbrt(+-inf) = +-inf15/// - cbrt(+-inf) = +-inf
16/// - cbrt(nan) = nan16/// - cbrt(nan) = nan
17pub fn cbrt(x: var) @TypeOf(x) {17pub fn cbrt(x: anytype) @TypeOf(x) {
18 const T = @TypeOf(x);18 const T = @TypeOf(x);
19 return switch (T) {19 return switch (T) {
20 f32 => cbrt32(x),20 f32 => cbrt32(x),
lib/std/math/ceil.zig+1-1
...@@ -15,7 +15,7 @@ const expect = std.testing.expect;...@@ -15,7 +15,7 @@ const expect = std.testing.expect;
15/// - ceil(+-0) = +-015/// - ceil(+-0) = +-0
16/// - ceil(+-inf) = +-inf16/// - ceil(+-inf) = +-inf
17/// - ceil(nan) = nan17/// - ceil(nan) = nan
18pub fn ceil(x: var) @TypeOf(x) {18pub fn ceil(x: anytype) @TypeOf(x) {
19 const T = @TypeOf(x);19 const T = @TypeOf(x);
20 return switch (T) {20 return switch (T) {
21 f32 => ceil32(x),21 f32 => ceil32(x),
lib/std/math/complex/abs.zig+1-1
...@@ -5,7 +5,7 @@ const cmath = math.complex;...@@ -5,7 +5,7 @@ const cmath = math.complex;
5const Complex = cmath.Complex;5const Complex = cmath.Complex;
66
7/// Returns the absolute value (modulus) of z.7/// Returns the absolute value (modulus) of z.
8pub fn abs(z: var) @TypeOf(z.re) {8pub fn abs(z: anytype) @TypeOf(z.re) {
9 const T = @TypeOf(z.re);9 const T = @TypeOf(z.re);
10 return math.hypot(T, z.re, z.im);10 return math.hypot(T, z.re, z.im);
11}11}
lib/std/math/complex/acos.zig+1-1
...@@ -5,7 +5,7 @@ const cmath = math.complex;...@@ -5,7 +5,7 @@ const cmath = math.complex;
5const Complex = cmath.Complex;5const Complex = cmath.Complex;
66
7/// Returns the arc-cosine of z.7/// Returns the arc-cosine of z.
8pub fn acos(z: var) Complex(@TypeOf(z.re)) {8pub fn acos(z: anytype) Complex(@TypeOf(z.re)) {
9 const T = @TypeOf(z.re);9 const T = @TypeOf(z.re);
10 const q = cmath.asin(z);10 const q = cmath.asin(z);
11 return Complex(T).new(@as(T, math.pi) / 2 - q.re, -q.im);11 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;...@@ -5,7 +5,7 @@ const cmath = math.complex;
5const Complex = cmath.Complex;5const Complex = cmath.Complex;
66
7/// Returns the hyperbolic arc-cosine of z.7/// 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)) {
9 const T = @TypeOf(z.re);9 const T = @TypeOf(z.re);
10 const q = cmath.acos(z);10 const q = cmath.acos(z);
11 return Complex(T).new(-q.im, q.re);11 return Complex(T).new(-q.im, q.re);
lib/std/math/complex/arg.zig+1-1
...@@ -5,7 +5,7 @@ const cmath = math.complex;...@@ -5,7 +5,7 @@ const cmath = math.complex;
5const Complex = cmath.Complex;5const Complex = cmath.Complex;
66
7/// Returns the angular component (in radians) of z.7/// Returns the angular component (in radians) of z.
8pub fn arg(z: var) @TypeOf(z.re) {8pub fn arg(z: anytype) @TypeOf(z.re) {
9 const T = @TypeOf(z.re);9 const T = @TypeOf(z.re);
10 return math.atan2(T, z.im, z.re);10 return math.atan2(T, z.im, z.re);
11}11}
lib/std/math/complex/asin.zig+1-1
...@@ -5,7 +5,7 @@ const cmath = math.complex;...@@ -5,7 +5,7 @@ const cmath = math.complex;
5const Complex = cmath.Complex;5const Complex = cmath.Complex;
66
7// Returns the arc-sine of z.7// Returns the arc-sine of z.
8pub fn asin(z: var) Complex(@TypeOf(z.re)) {8pub fn asin(z: anytype) Complex(@TypeOf(z.re)) {
9 const T = @TypeOf(z.re);9 const T = @TypeOf(z.re);
10 const x = z.re;10 const x = z.re;
11 const y = z.im;11 const y = z.im;
lib/std/math/complex/asinh.zig+1-1
...@@ -5,7 +5,7 @@ const cmath = math.complex;...@@ -5,7 +5,7 @@ const cmath = math.complex;
5const Complex = cmath.Complex;5const Complex = cmath.Complex;
66
7/// Returns the hyperbolic arc-sine of z.7/// 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)) {
9 const T = @TypeOf(z.re);9 const T = @TypeOf(z.re);
10 const q = Complex(T).new(-z.im, z.re);10 const q = Complex(T).new(-z.im, z.re);
11 const r = cmath.asin(q);11 const r = cmath.asin(q);
lib/std/math/complex/atan.zig+1-1
...@@ -12,7 +12,7 @@ const cmath = math.complex;...@@ -12,7 +12,7 @@ const cmath = math.complex;
12const Complex = cmath.Complex;12const Complex = cmath.Complex;
1313
14/// Returns the arc-tangent of z.14/// Returns the arc-tangent of z.
15pub fn atan(z: var) @TypeOf(z) {15pub fn atan(z: anytype) @TypeOf(z) {
16 const T = @TypeOf(z.re);16 const T = @TypeOf(z.re);
17 return switch (T) {17 return switch (T) {
18 f32 => atan32(z),18 f32 => atan32(z),
lib/std/math/complex/atanh.zig+1-1
...@@ -5,7 +5,7 @@ const cmath = math.complex;...@@ -5,7 +5,7 @@ const cmath = math.complex;
5const Complex = cmath.Complex;5const Complex = cmath.Complex;
66
7/// Returns the hyperbolic arc-tangent of z.7/// 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)) {
9 const T = @TypeOf(z.re);9 const T = @TypeOf(z.re);
10 const q = Complex(T).new(-z.im, z.re);10 const q = Complex(T).new(-z.im, z.re);
11 const r = cmath.atan(q);11 const r = cmath.atan(q);
lib/std/math/complex/conj.zig+1-1
...@@ -5,7 +5,7 @@ const cmath = math.complex;...@@ -5,7 +5,7 @@ const cmath = math.complex;
5const Complex = cmath.Complex;5const Complex = cmath.Complex;
66
7/// Returns the complex conjugate of z.7/// Returns the complex conjugate of z.
8pub fn conj(z: var) Complex(@TypeOf(z.re)) {8pub fn conj(z: anytype) Complex(@TypeOf(z.re)) {
9 const T = @TypeOf(z.re);9 const T = @TypeOf(z.re);
10 return Complex(T).new(z.re, -z.im);10 return Complex(T).new(z.re, -z.im);
11}11}
lib/std/math/complex/cos.zig+1-1
...@@ -5,7 +5,7 @@ const cmath = math.complex;...@@ -5,7 +5,7 @@ const cmath = math.complex;
5const Complex = cmath.Complex;5const Complex = cmath.Complex;
66
7/// Returns the cosine of z.7/// Returns the cosine of z.
8pub fn cos(z: var) Complex(@TypeOf(z.re)) {8pub fn cos(z: anytype) Complex(@TypeOf(z.re)) {
9 const T = @TypeOf(z.re);9 const T = @TypeOf(z.re);
10 const p = Complex(T).new(-z.im, z.re);10 const p = Complex(T).new(-z.im, z.re);
11 return cmath.cosh(p);11 return cmath.cosh(p);
lib/std/math/complex/cosh.zig+1-1
...@@ -14,7 +14,7 @@ const Complex = cmath.Complex;...@@ -14,7 +14,7 @@ const Complex = cmath.Complex;
14const ldexp_cexp = @import("ldexp.zig").ldexp_cexp;14const ldexp_cexp = @import("ldexp.zig").ldexp_cexp;
1515
16/// Returns the hyperbolic arc-cosine of z.16/// 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)) {
18 const T = @TypeOf(z.re);18 const T = @TypeOf(z.re);
19 return switch (T) {19 return switch (T) {
20 f32 => cosh32(z),20 f32 => cosh32(z),
lib/std/math/complex/exp.zig+1-1
...@@ -14,7 +14,7 @@ const Complex = cmath.Complex;...@@ -14,7 +14,7 @@ const Complex = cmath.Complex;
14const ldexp_cexp = @import("ldexp.zig").ldexp_cexp;14const ldexp_cexp = @import("ldexp.zig").ldexp_cexp;
1515
16/// Returns e raised to the power of z (e^z).16/// Returns e raised to the power of z (e^z).
17pub fn exp(z: var) @TypeOf(z) {17pub fn exp(z: anytype) @TypeOf(z) {
18 const T = @TypeOf(z.re);18 const T = @TypeOf(z.re);
1919
20 return switch (T) {20 return switch (T) {
lib/std/math/complex/ldexp.zig+1-1
...@@ -11,7 +11,7 @@ const cmath = math.complex;...@@ -11,7 +11,7 @@ const cmath = math.complex;
11const Complex = cmath.Complex;11const Complex = cmath.Complex;
1212
13/// Returns exp(z) scaled to avoid overflow.13/// 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) {
15 const T = @TypeOf(z.re);15 const T = @TypeOf(z.re);
1616
17 return switch (T) {17 return switch (T) {
lib/std/math/complex/log.zig+1-1
...@@ -5,7 +5,7 @@ const cmath = math.complex;...@@ -5,7 +5,7 @@ const cmath = math.complex;
5const Complex = cmath.Complex;5const Complex = cmath.Complex;
66
7/// Returns the natural logarithm of z.7/// Returns the natural logarithm of z.
8pub fn log(z: var) Complex(@TypeOf(z.re)) {8pub fn log(z: anytype) Complex(@TypeOf(z.re)) {
9 const T = @TypeOf(z.re);9 const T = @TypeOf(z.re);
10 const r = cmath.abs(z);10 const r = cmath.abs(z);
11 const phi = cmath.arg(z);11 const phi = cmath.arg(z);
lib/std/math/complex/proj.zig+1-1
...@@ -5,7 +5,7 @@ const cmath = math.complex;...@@ -5,7 +5,7 @@ const cmath = math.complex;
5const Complex = cmath.Complex;5const Complex = cmath.Complex;
66
7/// Returns the projection of z onto the riemann sphere.7/// 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)) {
9 const T = @TypeOf(z.re);9 const T = @TypeOf(z.re);
1010
11 if (math.isInf(z.re) or math.isInf(z.im)) {11 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;...@@ -5,7 +5,7 @@ const cmath = math.complex;
5const Complex = cmath.Complex;5const Complex = cmath.Complex;
66
7/// Returns the sine of z.7/// Returns the sine of z.
8pub fn sin(z: var) Complex(@TypeOf(z.re)) {8pub fn sin(z: anytype) Complex(@TypeOf(z.re)) {
9 const T = @TypeOf(z.re);9 const T = @TypeOf(z.re);
10 const p = Complex(T).new(-z.im, z.re);10 const p = Complex(T).new(-z.im, z.re);
11 const q = cmath.sinh(p);11 const q = cmath.sinh(p);
lib/std/math/complex/sinh.zig+1-1
...@@ -14,7 +14,7 @@ const Complex = cmath.Complex;...@@ -14,7 +14,7 @@ const Complex = cmath.Complex;
14const ldexp_cexp = @import("ldexp.zig").ldexp_cexp;14const ldexp_cexp = @import("ldexp.zig").ldexp_cexp;
1515
16/// Returns the hyperbolic sine of z.16/// Returns the hyperbolic sine of z.
17pub fn sinh(z: var) @TypeOf(z) {17pub fn sinh(z: anytype) @TypeOf(z) {
18 const T = @TypeOf(z.re);18 const T = @TypeOf(z.re);
19 return switch (T) {19 return switch (T) {
20 f32 => sinh32(z),20 f32 => sinh32(z),
lib/std/math/complex/sqrt.zig+1-1
...@@ -12,7 +12,7 @@ const Complex = cmath.Complex;...@@ -12,7 +12,7 @@ const Complex = cmath.Complex;
1212
13/// Returns the square root of z. The real and imaginary parts of the result have the same sign13/// Returns the square root of z. The real and imaginary parts of the result have the same sign
14/// as the imaginary part of z.14/// as the imaginary part of z.
15pub fn sqrt(z: var) @TypeOf(z) {15pub fn sqrt(z: anytype) @TypeOf(z) {
16 const T = @TypeOf(z.re);16 const T = @TypeOf(z.re);
1717
18 return switch (T) {18 return switch (T) {
lib/std/math/complex/tan.zig+1-1
...@@ -5,7 +5,7 @@ const cmath = math.complex;...@@ -5,7 +5,7 @@ const cmath = math.complex;
5const Complex = cmath.Complex;5const Complex = cmath.Complex;
66
7/// Returns the tanget of z.7/// Returns the tanget of z.
8pub fn tan(z: var) Complex(@TypeOf(z.re)) {8pub fn tan(z: anytype) Complex(@TypeOf(z.re)) {
9 const T = @TypeOf(z.re);9 const T = @TypeOf(z.re);
10 const q = Complex(T).new(-z.im, z.re);10 const q = Complex(T).new(-z.im, z.re);
11 const r = cmath.tanh(q);11 const r = cmath.tanh(q);
lib/std/math/complex/tanh.zig+1-1
...@@ -12,7 +12,7 @@ const cmath = math.complex;...@@ -12,7 +12,7 @@ const cmath = math.complex;
12const Complex = cmath.Complex;12const Complex = cmath.Complex;
1313
14/// Returns the hyperbolic tangent of z.14/// Returns the hyperbolic tangent of z.
15pub fn tanh(z: var) @TypeOf(z) {15pub fn tanh(z: anytype) @TypeOf(z) {
16 const T = @TypeOf(z.re);16 const T = @TypeOf(z.re);
17 return switch (T) {17 return switch (T) {
18 f32 => tanh32(z),18 f32 => tanh32(z),
lib/std/math/cos.zig+1-1
...@@ -13,7 +13,7 @@ const expect = std.testing.expect;...@@ -13,7 +13,7 @@ const expect = std.testing.expect;
13/// Special Cases:13/// Special Cases:
14/// - cos(+-inf) = nan14/// - cos(+-inf) = nan
15/// - cos(nan) = nan15/// - cos(nan) = nan
16pub fn cos(x: var) @TypeOf(x) {16pub fn cos(x: anytype) @TypeOf(x) {
17 const T = @TypeOf(x);17 const T = @TypeOf(x);
18 return switch (T) {18 return switch (T) {
19 f32 => cos_(f32, x),19 f32 => cos_(f32, x),
lib/std/math/cosh.zig+1-1
...@@ -17,7 +17,7 @@ const maxInt = std.math.maxInt;...@@ -17,7 +17,7 @@ const maxInt = std.math.maxInt;
17/// - cosh(+-0) = 117/// - cosh(+-0) = 1
18/// - cosh(+-inf) = +inf18/// - cosh(+-inf) = +inf
19/// - cosh(nan) = nan19/// - cosh(nan) = nan
20pub fn cosh(x: var) @TypeOf(x) {20pub fn cosh(x: anytype) @TypeOf(x) {
21 const T = @TypeOf(x);21 const T = @TypeOf(x);
22 return switch (T) {22 return switch (T) {
23 f32 => cosh32(x),23 f32 => cosh32(x),
lib/std/math/exp.zig+1-1
...@@ -14,7 +14,7 @@ const builtin = @import("builtin");...@@ -14,7 +14,7 @@ const builtin = @import("builtin");
14/// Special Cases:14/// Special Cases:
15/// - exp(+inf) = +inf15/// - exp(+inf) = +inf
16/// - exp(nan) = nan16/// - exp(nan) = nan
17pub fn exp(x: var) @TypeOf(x) {17pub fn exp(x: anytype) @TypeOf(x) {
18 const T = @TypeOf(x);18 const T = @TypeOf(x);
19 return switch (T) {19 return switch (T) {
20 f32 => exp32(x),20 f32 => exp32(x),
lib/std/math/exp2.zig+1-1
...@@ -13,7 +13,7 @@ const expect = std.testing.expect;...@@ -13,7 +13,7 @@ const expect = std.testing.expect;
13/// Special Cases:13/// Special Cases:
14/// - exp2(+inf) = +inf14/// - exp2(+inf) = +inf
15/// - exp2(nan) = nan15/// - exp2(nan) = nan
16pub fn exp2(x: var) @TypeOf(x) {16pub fn exp2(x: anytype) @TypeOf(x) {
17 const T = @TypeOf(x);17 const T = @TypeOf(x);
18 return switch (T) {18 return switch (T) {
19 f32 => exp2_32(x),19 f32 => exp2_32(x),
lib/std/math/expm1.zig+1-1
...@@ -18,7 +18,7 @@ const expect = std.testing.expect;...@@ -18,7 +18,7 @@ const expect = std.testing.expect;
18/// - expm1(+inf) = +inf18/// - expm1(+inf) = +inf
19/// - expm1(-inf) = -119/// - expm1(-inf) = -1
20/// - expm1(nan) = nan20/// - expm1(nan) = nan
21pub fn expm1(x: var) @TypeOf(x) {21pub fn expm1(x: anytype) @TypeOf(x) {
22 const T = @TypeOf(x);22 const T = @TypeOf(x);
23 return switch (T) {23 return switch (T) {
24 f32 => expm1_32(x),24 f32 => expm1_32(x),
lib/std/math/expo2.zig+1-1
...@@ -7,7 +7,7 @@...@@ -7,7 +7,7 @@
7const math = @import("../math.zig");7const math = @import("../math.zig");
88
9/// Returns exp(x) / 2 for x >= log(maxFloat(T)).9/// Returns exp(x) / 2 for x >= log(maxFloat(T)).
10pub fn expo2(x: var) @TypeOf(x) {10pub fn expo2(x: anytype) @TypeOf(x) {
11 const T = @TypeOf(x);11 const T = @TypeOf(x);
12 return switch (T) {12 return switch (T) {
13 f32 => expo2f(x),13 f32 => expo2f(x),
lib/std/math/fabs.zig+1-1
...@@ -14,7 +14,7 @@ const maxInt = std.math.maxInt;...@@ -14,7 +14,7 @@ const maxInt = std.math.maxInt;
14/// Special Cases:14/// Special Cases:
15/// - fabs(+-inf) = +inf15/// - fabs(+-inf) = +inf
16/// - fabs(nan) = nan16/// - fabs(nan) = nan
17pub fn fabs(x: var) @TypeOf(x) {17pub fn fabs(x: anytype) @TypeOf(x) {
18 const T = @TypeOf(x);18 const T = @TypeOf(x);
19 return switch (T) {19 return switch (T) {
20 f16 => fabs16(x),20 f16 => fabs16(x),
lib/std/math/floor.zig+1-1
...@@ -15,7 +15,7 @@ const math = std.math;...@@ -15,7 +15,7 @@ const math = std.math;
15/// - floor(+-0) = +-015/// - floor(+-0) = +-0
16/// - floor(+-inf) = +-inf16/// - floor(+-inf) = +-inf
17/// - floor(nan) = nan17/// - floor(nan) = nan
18pub fn floor(x: var) @TypeOf(x) {18pub fn floor(x: anytype) @TypeOf(x) {
19 const T = @TypeOf(x);19 const T = @TypeOf(x);
20 return switch (T) {20 return switch (T) {
21 f16 => floor16(x),21 f16 => floor16(x),
lib/std/math/frexp.zig+1-1
...@@ -24,7 +24,7 @@ pub const frexp64_result = frexp_result(f64);...@@ -24,7 +24,7 @@ pub const frexp64_result = frexp_result(f64);
24/// - frexp(+-0) = +-0, 024/// - frexp(+-0) = +-0, 0
25/// - frexp(+-inf) = +-inf, 025/// - frexp(+-inf) = +-inf, 0
26/// - frexp(nan) = nan, undefined26/// - frexp(nan) = nan, undefined
27pub fn frexp(x: var) frexp_result(@TypeOf(x)) {27pub fn frexp(x: anytype) frexp_result(@TypeOf(x)) {
28 const T = @TypeOf(x);28 const T = @TypeOf(x);
29 return switch (T) {29 return switch (T) {
30 f32 => frexp32(x),30 f32 => frexp32(x),
lib/std/math/ilogb.zig+1-1
...@@ -16,7 +16,7 @@ const minInt = std.math.minInt;...@@ -16,7 +16,7 @@ const minInt = std.math.minInt;
16/// - ilogb(+-inf) = maxInt(i32)16/// - ilogb(+-inf) = maxInt(i32)
17/// - ilogb(0) = maxInt(i32)17/// - ilogb(0) = maxInt(i32)
18/// - ilogb(nan) = maxInt(i32)18/// - ilogb(nan) = maxInt(i32)
19pub fn ilogb(x: var) i32 {19pub fn ilogb(x: anytype) i32 {
20 const T = @TypeOf(x);20 const T = @TypeOf(x);
21 return switch (T) {21 return switch (T) {
22 f32 => ilogb32(x),22 f32 => ilogb32(x),
lib/std/math/isfinite.zig+1-1
...@@ -4,7 +4,7 @@ const expect = std.testing.expect;...@@ -4,7 +4,7 @@ const expect = std.testing.expect;
4const maxInt = std.math.maxInt;4const maxInt = std.math.maxInt;
55
6/// Returns whether x is a finite value.6/// Returns whether x is a finite value.
7pub fn isFinite(x: var) bool {7pub fn isFinite(x: anytype) bool {
8 const T = @TypeOf(x);8 const T = @TypeOf(x);
9 switch (T) {9 switch (T) {
10 f16 => {10 f16 => {
lib/std/math/isinf.zig+3-3
...@@ -4,7 +4,7 @@ const expect = std.testing.expect;...@@ -4,7 +4,7 @@ const expect = std.testing.expect;
4const maxInt = std.math.maxInt;4const maxInt = std.math.maxInt;
55
6/// Returns whether x is an infinity, ignoring sign.6/// Returns whether x is an infinity, ignoring sign.
7pub fn isInf(x: var) bool {7pub fn isInf(x: anytype) bool {
8 const T = @TypeOf(x);8 const T = @TypeOf(x);
9 switch (T) {9 switch (T) {
10 f16 => {10 f16 => {
...@@ -30,7 +30,7 @@ pub fn isInf(x: var) bool {...@@ -30,7 +30,7 @@ pub fn isInf(x: var) bool {
30}30}
3131
32/// Returns whether x is an infinity with a positive sign.32/// Returns whether x is an infinity with a positive sign.
33pub fn isPositiveInf(x: var) bool {33pub fn isPositiveInf(x: anytype) bool {
34 const T = @TypeOf(x);34 const T = @TypeOf(x);
35 switch (T) {35 switch (T) {
36 f16 => {36 f16 => {
...@@ -52,7 +52,7 @@ pub fn isPositiveInf(x: var) bool {...@@ -52,7 +52,7 @@ pub fn isPositiveInf(x: var) bool {
52}52}
5353
54/// Returns whether x is an infinity with a negative sign.54/// Returns whether x is an infinity with a negative sign.
55pub fn isNegativeInf(x: var) bool {55pub fn isNegativeInf(x: anytype) bool {
56 const T = @TypeOf(x);56 const T = @TypeOf(x);
57 switch (T) {57 switch (T) {
58 f16 => {58 f16 => {
lib/std/math/isnan.zig+2-2
...@@ -4,12 +4,12 @@ const expect = std.testing.expect;...@@ -4,12 +4,12 @@ const expect = std.testing.expect;
4const maxInt = std.math.maxInt;4const maxInt = std.math.maxInt;
55
6/// Returns whether x is a nan.6/// Returns whether x is a nan.
7pub fn isNan(x: var) bool {7pub fn isNan(x: anytype) bool {
8 return x != x;8 return x != x;
9}9}
1010
11/// Returns whether x is a signalling nan.11/// Returns whether x is a signalling nan.
12pub fn isSignalNan(x: var) bool {12pub fn isSignalNan(x: anytype) bool {
13 // Note: A signalling nan is identical to a standard nan right now but may have a different bit13 // Note: A signalling nan is identical to a standard nan right now but may have a different bit
14 // representation in the future when required.14 // representation in the future when required.
15 return isNan(x);15 return isNan(x);
lib/std/math/isnormal.zig+1-1
...@@ -4,7 +4,7 @@ const expect = std.testing.expect;...@@ -4,7 +4,7 @@ const expect = std.testing.expect;
4const maxInt = std.math.maxInt;4const maxInt = std.math.maxInt;
55
6// Returns whether x has a normalized representation (i.e. integer part of mantissa is 1).6// 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 {
8 const T = @TypeOf(x);8 const T = @TypeOf(x);
9 switch (T) {9 switch (T) {
10 f16 => {10 f16 => {
lib/std/math/ln.zig+1-1
...@@ -15,7 +15,7 @@ const expect = std.testing.expect;...@@ -15,7 +15,7 @@ const expect = std.testing.expect;
15/// - ln(0) = -inf15/// - ln(0) = -inf
16/// - ln(x) = nan if x < 016/// - ln(x) = nan if x < 0
17/// - ln(nan) = nan17/// - ln(nan) = nan
18pub fn ln(x: var) @TypeOf(x) {18pub fn ln(x: anytype) @TypeOf(x) {
19 const T = @TypeOf(x);19 const T = @TypeOf(x);
20 switch (@typeInfo(T)) {20 switch (@typeInfo(T)) {
21 .ComptimeFloat => {21 .ComptimeFloat => {
lib/std/math/log10.zig+1-1
...@@ -16,7 +16,7 @@ const maxInt = std.math.maxInt;...@@ -16,7 +16,7 @@ const maxInt = std.math.maxInt;
16/// - log10(0) = -inf16/// - log10(0) = -inf
17/// - log10(x) = nan if x < 017/// - log10(x) = nan if x < 0
18/// - log10(nan) = nan18/// - log10(nan) = nan
19pub fn log10(x: var) @TypeOf(x) {19pub fn log10(x: anytype) @TypeOf(x) {
20 const T = @TypeOf(x);20 const T = @TypeOf(x);
21 switch (@typeInfo(T)) {21 switch (@typeInfo(T)) {
22 .ComptimeFloat => {22 .ComptimeFloat => {
lib/std/math/log1p.zig+1-1
...@@ -17,7 +17,7 @@ const expect = std.testing.expect;...@@ -17,7 +17,7 @@ const expect = std.testing.expect;
17/// - log1p(-1) = -inf17/// - log1p(-1) = -inf
18/// - log1p(x) = nan if x < -118/// - log1p(x) = nan if x < -1
19/// - log1p(nan) = nan19/// - log1p(nan) = nan
20pub fn log1p(x: var) @TypeOf(x) {20pub fn log1p(x: anytype) @TypeOf(x) {
21 const T = @TypeOf(x);21 const T = @TypeOf(x);
22 return switch (T) {22 return switch (T) {
23 f32 => log1p_32(x),23 f32 => log1p_32(x),
lib/std/math/log2.zig+1-1
...@@ -16,7 +16,7 @@ const maxInt = std.math.maxInt;...@@ -16,7 +16,7 @@ const maxInt = std.math.maxInt;
16/// - log2(0) = -inf16/// - log2(0) = -inf
17/// - log2(x) = nan if x < 017/// - log2(x) = nan if x < 0
18/// - log2(nan) = nan18/// - log2(nan) = nan
19pub fn log2(x: var) @TypeOf(x) {19pub fn log2(x: anytype) @TypeOf(x) {
20 const T = @TypeOf(x);20 const T = @TypeOf(x);
21 switch (@typeInfo(T)) {21 switch (@typeInfo(T)) {
22 .ComptimeFloat => {22 .ComptimeFloat => {
lib/std/math/modf.zig+1-1
...@@ -24,7 +24,7 @@ pub const modf64_result = modf_result(f64);...@@ -24,7 +24,7 @@ pub const modf64_result = modf_result(f64);
24/// Special Cases:24/// Special Cases:
25/// - modf(+-inf) = +-inf, nan25/// - modf(+-inf) = +-inf, nan
26/// - modf(nan) = nan, nan26/// - modf(nan) = nan, nan
27pub fn modf(x: var) modf_result(@TypeOf(x)) {27pub fn modf(x: anytype) modf_result(@TypeOf(x)) {
28 const T = @TypeOf(x);28 const T = @TypeOf(x);
29 return switch (T) {29 return switch (T) {
30 f32 => modf32(x),30 f32 => modf32(x),
lib/std/math/round.zig+1-1
...@@ -15,7 +15,7 @@ const math = std.math;...@@ -15,7 +15,7 @@ const math = std.math;
15/// - round(+-0) = +-015/// - round(+-0) = +-0
16/// - round(+-inf) = +-inf16/// - round(+-inf) = +-inf
17/// - round(nan) = nan17/// - round(nan) = nan
18pub fn round(x: var) @TypeOf(x) {18pub fn round(x: anytype) @TypeOf(x) {
19 const T = @TypeOf(x);19 const T = @TypeOf(x);
20 return switch (T) {20 return switch (T) {
21 f32 => round32(x),21 f32 => round32(x),
lib/std/math/scalbn.zig+1-1
...@@ -9,7 +9,7 @@ const math = std.math;...@@ -9,7 +9,7 @@ const math = std.math;
9const expect = std.testing.expect;9const expect = std.testing.expect;
1010
11/// Returns x * 2^n.11/// Returns x * 2^n.
12pub fn scalbn(x: var, n: i32) @TypeOf(x) {12pub fn scalbn(x: anytype, n: i32) @TypeOf(x) {
13 const T = @TypeOf(x);13 const T = @TypeOf(x);
14 return switch (T) {14 return switch (T) {
15 f32 => scalbn32(x, n),15 f32 => scalbn32(x, n),
lib/std/math/signbit.zig+1-1
...@@ -3,7 +3,7 @@ const math = std.math;...@@ -3,7 +3,7 @@ const math = std.math;
3const expect = std.testing.expect;3const expect = std.testing.expect;
44
5/// Returns whether x is negative or negative 0.5/// Returns whether x is negative or negative 0.
6pub fn signbit(x: var) bool {6pub fn signbit(x: anytype) bool {
7 const T = @TypeOf(x);7 const T = @TypeOf(x);
8 return switch (T) {8 return switch (T) {
9 f16 => signbit16(x),9 f16 => signbit16(x),
lib/std/math/sin.zig+1-1
...@@ -14,7 +14,7 @@ const expect = std.testing.expect;...@@ -14,7 +14,7 @@ const expect = std.testing.expect;
14/// - sin(+-0) = +-014/// - sin(+-0) = +-0
15/// - sin(+-inf) = nan15/// - sin(+-inf) = nan
16/// - sin(nan) = nan16/// - sin(nan) = nan
17pub fn sin(x: var) @TypeOf(x) {17pub fn sin(x: anytype) @TypeOf(x) {
18 const T = @TypeOf(x);18 const T = @TypeOf(x);
19 return switch (T) {19 return switch (T) {
20 f32 => sin_(T, x),20 f32 => sin_(T, x),
lib/std/math/sinh.zig+1-1
...@@ -17,7 +17,7 @@ const maxInt = std.math.maxInt;...@@ -17,7 +17,7 @@ const maxInt = std.math.maxInt;
17/// - sinh(+-0) = +-017/// - sinh(+-0) = +-0
18/// - sinh(+-inf) = +-inf18/// - sinh(+-inf) = +-inf
19/// - sinh(nan) = nan19/// - sinh(nan) = nan
20pub fn sinh(x: var) @TypeOf(x) {20pub fn sinh(x: anytype) @TypeOf(x) {
21 const T = @TypeOf(x);21 const T = @TypeOf(x);
22 return switch (T) {22 return switch (T) {
23 f32 => sinh32(x),23 f32 => sinh32(x),
lib/std/math/sqrt.zig+1-1
...@@ -13,7 +13,7 @@ const maxInt = std.math.maxInt;...@@ -13,7 +13,7 @@ const maxInt = std.math.maxInt;
13/// - sqrt(x) = nan if x < 013/// - sqrt(x) = nan if x < 0
14/// - sqrt(nan) = nan14/// - sqrt(nan) = nan
15/// TODO Decide if all this logic should be implemented directly in the @sqrt bultin function.15/// 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)) {
17 const T = @TypeOf(x);17 const T = @TypeOf(x);
18 switch (@typeInfo(T)) {18 switch (@typeInfo(T)) {
19 .Float, .ComptimeFloat => return @sqrt(x),19 .Float, .ComptimeFloat => return @sqrt(x),
lib/std/math/tan.zig+1-1
...@@ -14,7 +14,7 @@ const expect = std.testing.expect;...@@ -14,7 +14,7 @@ const expect = std.testing.expect;
14/// - tan(+-0) = +-014/// - tan(+-0) = +-0
15/// - tan(+-inf) = nan15/// - tan(+-inf) = nan
16/// - tan(nan) = nan16/// - tan(nan) = nan
17pub fn tan(x: var) @TypeOf(x) {17pub fn tan(x: anytype) @TypeOf(x) {
18 const T = @TypeOf(x);18 const T = @TypeOf(x);
19 return switch (T) {19 return switch (T) {
20 f32 => tan_(f32, x),20 f32 => tan_(f32, x),
lib/std/math/tanh.zig+1-1
...@@ -17,7 +17,7 @@ const maxInt = std.math.maxInt;...@@ -17,7 +17,7 @@ const maxInt = std.math.maxInt;
17/// - sinh(+-0) = +-017/// - sinh(+-0) = +-0
18/// - sinh(+-inf) = +-118/// - sinh(+-inf) = +-1
19/// - sinh(nan) = nan19/// - sinh(nan) = nan
20pub fn tanh(x: var) @TypeOf(x) {20pub fn tanh(x: anytype) @TypeOf(x) {
21 const T = @TypeOf(x);21 const T = @TypeOf(x);
22 return switch (T) {22 return switch (T) {
23 f32 => tanh32(x),23 f32 => tanh32(x),
lib/std/math/trunc.zig+1-1
...@@ -15,7 +15,7 @@ const maxInt = std.math.maxInt;...@@ -15,7 +15,7 @@ const maxInt = std.math.maxInt;
15/// - trunc(+-0) = +-015/// - trunc(+-0) = +-0
16/// - trunc(+-inf) = +-inf16/// - trunc(+-inf) = +-inf
17/// - trunc(nan) = nan17/// - trunc(nan) = nan
18pub fn trunc(x: var) @TypeOf(x) {18pub fn trunc(x: anytype) @TypeOf(x) {
19 const T = @TypeOf(x);19 const T = @TypeOf(x);
20 return switch (T) {20 return switch (T) {
21 f32 => trunc32(x),21 f32 => trunc32(x),
lib/std/mem.zig+87-86
...@@ -122,7 +122,7 @@ pub const Allocator = struct {...@@ -122,7 +122,7 @@ pub const Allocator = struct {
122 assert(resized_len >= new_byte_count);122 assert(resized_len >= new_byte_count);
123 @memset(old_mem.ptr + new_byte_count, undefined, resized_len - new_byte_count);123 @memset(old_mem.ptr + new_byte_count, undefined, resized_len - new_byte_count);
124 return old_mem.ptr[0..resized_len];124 return old_mem.ptr[0..resized_len];
125 } else |_| { }125 } else |_| {}
126 }126 }
127 if (new_byte_count <= old_mem.len and new_alignment <= old_alignment) {127 if (new_byte_count <= old_mem.len and new_alignment <= old_alignment) {
128 return error.OutOfMemory;128 return error.OutOfMemory;
...@@ -156,7 +156,7 @@ pub const Allocator = struct {...@@ -156,7 +156,7 @@ pub const Allocator = struct {
156156
157 /// `ptr` should be the return value of `create`, or otherwise157 /// `ptr` should be the return value of `create`, or otherwise
158 /// have the same address and alignment property.158 /// 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 {
160 const T = @TypeOf(ptr).Child;160 const T = @TypeOf(ptr).Child;
161 if (@sizeOf(T) == 0) return;161 if (@sizeOf(T) == 0) return;
162 const non_const_ptr = @intToPtr([*]u8, @ptrToInt(ptr));162 const non_const_ptr = @intToPtr([*]u8, @ptrToInt(ptr));
...@@ -225,7 +225,7 @@ pub const Allocator = struct {...@@ -225,7 +225,7 @@ pub const Allocator = struct {
225 return self.allocAdvanced(T, alignment, n, .exact);225 return self.allocAdvanced(T, alignment, n, .exact);
226 }226 }
227227
228 const Exact = enum {exact,at_least};228 const Exact = enum { exact, at_least };
229 pub fn allocAdvanced(229 pub fn allocAdvanced(
230 self: *Allocator,230 self: *Allocator,
231 comptime T: type,231 comptime T: type,
...@@ -272,7 +272,7 @@ pub const Allocator = struct {...@@ -272,7 +272,7 @@ pub const Allocator = struct {
272 /// in `std.ArrayList.shrink`.272 /// in `std.ArrayList.shrink`.
273 /// If you need guaranteed success, call `shrink`.273 /// If you need guaranteed success, call `shrink`.
274 /// If `new_n` is 0, this is the same as `free` and it always succeeds.274 /// 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: {
276 const Slice = @typeInfo(@TypeOf(old_mem)).Pointer;276 const Slice = @typeInfo(@TypeOf(old_mem)).Pointer;
277 break :t Error![]align(Slice.alignment) Slice.child;277 break :t Error![]align(Slice.alignment) Slice.child;
278 } {278 } {
...@@ -280,7 +280,7 @@ pub const Allocator = struct {...@@ -280,7 +280,7 @@ pub const Allocator = struct {
280 return self.reallocAdvanced(old_mem, old_alignment, new_n, .exact);280 return self.reallocAdvanced(old_mem, old_alignment, new_n, .exact);
281 }281 }
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: {
284 const Slice = @typeInfo(@TypeOf(old_mem)).Pointer;284 const Slice = @typeInfo(@TypeOf(old_mem)).Pointer;
285 break :t Error![]align(Slice.alignment) Slice.child;285 break :t Error![]align(Slice.alignment) Slice.child;
286 } {286 } {
...@@ -291,7 +291,7 @@ pub const Allocator = struct {...@@ -291,7 +291,7 @@ pub const Allocator = struct {
291 // Deprecated: use `reallocAdvanced`291 // Deprecated: use `reallocAdvanced`
292 pub fn alignedRealloc(292 pub fn alignedRealloc(
293 self: *Allocator,293 self: *Allocator,
294 old_mem: var,294 old_mem: anytype,
295 comptime new_alignment: u29,295 comptime new_alignment: u29,
296 new_n: usize,296 new_n: usize,
297 ) Error![]align(new_alignment) @typeInfo(@TypeOf(old_mem)).Pointer.child {297 ) Error![]align(new_alignment) @typeInfo(@TypeOf(old_mem)).Pointer.child {
...@@ -303,7 +303,7 @@ pub const Allocator = struct {...@@ -303,7 +303,7 @@ pub const Allocator = struct {
303 /// allocation.303 /// allocation.
304 pub fn reallocAdvanced(304 pub fn reallocAdvanced(
305 self: *Allocator,305 self: *Allocator,
306 old_mem: var,306 old_mem: anytype,
307 comptime new_alignment: u29,307 comptime new_alignment: u29,
308 new_n: usize,308 new_n: usize,
309 exact: Exact,309 exact: Exact,
...@@ -321,8 +321,7 @@ pub const Allocator = struct {...@@ -321,8 +321,7 @@ pub const Allocator = struct {
321 const old_byte_slice = mem.sliceAsBytes(old_mem);321 const old_byte_slice = mem.sliceAsBytes(old_mem);
322 const byte_count = math.mul(usize, @sizeOf(T), new_n) catch return Error.OutOfMemory;322 const byte_count = math.mul(usize, @sizeOf(T), new_n) catch return Error.OutOfMemory;
323 // Note: can't set shrunk memory to undefined as memory shouldn't be modified on realloc failure323 // 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,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));
325 if (exact == .exact) @as(u29, 0) else @sizeOf(T));
326 return mem.bytesAsSlice(T, @alignCast(new_alignment, new_byte_slice));325 return mem.bytesAsSlice(T, @alignCast(new_alignment, new_byte_slice));
327 }326 }
328327
...@@ -331,7 +330,7 @@ pub const Allocator = struct {...@@ -331,7 +330,7 @@ pub const Allocator = struct {
331 /// Shrink always succeeds, and `new_n` must be <= `old_mem.len`.330 /// Shrink always succeeds, and `new_n` must be <= `old_mem.len`.
332 /// Returned slice has same alignment as old_mem.331 /// Returned slice has same alignment as old_mem.
333 /// Shrinking to 0 is the same as calling `free`.332 /// 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: {
335 const Slice = @typeInfo(@TypeOf(old_mem)).Pointer;334 const Slice = @typeInfo(@TypeOf(old_mem)).Pointer;
336 break :t []align(Slice.alignment) Slice.child;335 break :t []align(Slice.alignment) Slice.child;
337 } {336 } {
...@@ -344,7 +343,7 @@ pub const Allocator = struct {...@@ -344,7 +343,7 @@ pub const Allocator = struct {
344 /// allocation.343 /// allocation.
345 pub fn alignedShrink(344 pub fn alignedShrink(
346 self: *Allocator,345 self: *Allocator,
347 old_mem: var,346 old_mem: anytype,
348 comptime new_alignment: u29,347 comptime new_alignment: u29,
349 new_n: usize,348 new_n: usize,
350 ) []align(new_alignment) @typeInfo(@TypeOf(old_mem)).Pointer.child {349 ) []align(new_alignment) @typeInfo(@TypeOf(old_mem)).Pointer.child {
...@@ -368,7 +367,7 @@ pub const Allocator = struct {...@@ -368,7 +367,7 @@ pub const Allocator = struct {
368367
369 /// Free an array allocated with `alloc`. To free a single item,368 /// Free an array allocated with `alloc`. To free a single item,
370 /// see `destroy`.369 /// see `destroy`.
371 pub fn free(self: *Allocator, memory: var) void {370 pub fn free(self: *Allocator, memory: anytype) void {
372 const Slice = @typeInfo(@TypeOf(memory)).Pointer;371 const Slice = @typeInfo(@TypeOf(memory)).Pointer;
373 const bytes = mem.sliceAsBytes(memory);372 const bytes = mem.sliceAsBytes(memory);
374 const bytes_len = bytes.len + if (Slice.sentinel != null) @sizeOf(Slice.child) else 0;373 const bytes_len = bytes.len + if (Slice.sentinel != null) @sizeOf(Slice.child) else 0;
...@@ -396,67 +395,69 @@ pub const Allocator = struct {...@@ -396,67 +395,69 @@ pub const Allocator = struct {
396395
397/// Detects and asserts if the std.mem.Allocator interface is violated by the caller396/// Detects and asserts if the std.mem.Allocator interface is violated by the caller
398/// or the allocator.397/// or the allocator.
399pub fn ValidationAllocator(comptime T: type) type { return struct {398pub fn ValidationAllocator(comptime T: type) type {
400 const Self = @This();399 return struct {
401 allocator: Allocator,400 const Self = @This();
402 underlying_allocator: T,401 allocator: Allocator,
403 pub fn init(allocator: T) @This() {402 underlying_allocator: T,
404 return .{403 pub fn init(allocator: T) @This() {
405 .allocator = .{404 return .{
406 .allocFn = alloc,405 .allocator = .{
407 .resizeFn = resize,406 .allocFn = alloc,
408 },407 .resizeFn = resize,
409 .underlying_allocator = allocator,408 },
410 };409 .underlying_allocator = allocator,
411 }410 };
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));
433 }411 }
434 return result;412 fn getUnderlyingAllocatorPtr(self: *@This()) *Allocator {
435 }413 if (T == *Allocator) return self.underlying_allocator;
436 pub fn resize(allocator: *Allocator, buf: []u8, new_len: usize, len_align: u29) Allocator.Error!usize {414 if (*T == *Allocator) return &self.underlying_allocator;
437 assert(buf.len > 0);415 return &self.underlying_allocator.allocator;
438 if (len_align != 0) {
439 assert(mem.isAlignedAnyAlign(new_len, len_align));
440 assert(new_len >= len_align);
441 }416 }
442 const self = @fieldParentPtr(@This(), "allocator", allocator);417 pub fn alloc(allocator: *Allocator, n: usize, ptr_align: u29, len_align: u29) Allocator.Error![]u8 {
443 const result = try self.getUnderlyingAllocatorPtr().callResizeFn(buf, new_len, len_align);418 assert(n > 0);
444 if (len_align == 0) {419 assert(mem.isValidAlign(ptr_align));
445 assert(result == new_len);420 if (len_align != 0) {
446 } else {421 assert(mem.isAlignedAnyAlign(n, len_align));
447 assert(result >= new_len);422 assert(n >= len_align);
448 assert(mem.isAlignedAnyAlign(result, 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;
449 }435 }
450 return result;436 pub fn resize(allocator: *Allocator, buf: []u8, new_len: usize, len_align: u29) Allocator.Error!usize {
451 }437 assert(buf.len > 0);
452 pub usingnamespace if (T == *Allocator or !@hasDecl(T, "reset")) struct {} else struct {438 if (len_align != 0) {
453 pub fn reset(self: *Self) void {439 assert(mem.isAlignedAnyAlign(new_len, len_align));
454 self.underlying_allocator.reset();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;
455 }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();
455 }
456 };
456 };457 };
457};}458}
458459
459pub fn validationWrap(allocator: var) ValidationAllocator(@TypeOf(allocator)) {460pub fn validationWrap(allocator: anytype) ValidationAllocator(@TypeOf(allocator)) {
460 return ValidationAllocator(@TypeOf(allocator)).init(allocator);461 return ValidationAllocator(@TypeOf(allocator)).init(allocator);
461}462}
462463
...@@ -465,14 +466,14 @@ pub fn validationWrap(allocator: var) ValidationAllocator(@TypeOf(allocator)) {...@@ -465,14 +466,14 @@ pub fn validationWrap(allocator: var) ValidationAllocator(@TypeOf(allocator)) {
465/// than the `len` that was requsted. This function should only be used by allocators466/// than the `len` that was requsted. This function should only be used by allocators
466/// that are unaffected by `len_align`.467/// that are unaffected by `len_align`.
467pub fn alignAllocLen(full_len: usize, alloc_len: usize, len_align: u29) usize {468pub fn alignAllocLen(full_len: usize, alloc_len: usize, len_align: u29) usize {
468 assert(alloc_len > 0);469 assert(alloc_len > 0);
469 assert(alloc_len >= len_align);470 assert(alloc_len >= len_align);
470 assert(full_len >= alloc_len);471 assert(full_len >= alloc_len);
471 if (len_align == 0)472 if (len_align == 0)
472 return alloc_len;473 return alloc_len;
473 const adjusted = alignBackwardAnyAlign(full_len, len_align);474 const adjusted = alignBackwardAnyAlign(full_len, len_align);
474 assert(adjusted >= alloc_len);475 assert(adjusted >= alloc_len);
475 return adjusted;476 return adjusted;
476}477}
477478
478var failAllocator = Allocator{479var failAllocator = Allocator{
...@@ -695,7 +696,7 @@ test "mem.secureZero" {...@@ -695,7 +696,7 @@ test "mem.secureZero" {
695/// Initializes all fields of the struct with their default value, or zero values if no default value is present.696/// Initializes all fields of the struct with their default value, or zero values if no default value is present.
696/// If the field is present in the provided initial values, it will have that value instead.697/// If the field is present in the provided initial values, it will have that value instead.
697/// Structs are initialized recursively.698/// Structs are initialized recursively.
698pub fn zeroInit(comptime T: type, init: var) T {699pub fn zeroInit(comptime T: type, init: anytype) T {
699 comptime const Init = @TypeOf(init);700 comptime const Init = @TypeOf(init);
700701
701 switch (@typeInfo(T)) {702 switch (@typeInfo(T)) {
...@@ -895,7 +896,7 @@ test "Span" {...@@ -895,7 +896,7 @@ test "Span" {
895///896///
896/// When there is both a sentinel and an array length or slice length, the897/// When there is both a sentinel and an array length or slice length, the
897/// length value is used instead of the sentinel.898/// length value is used instead of the sentinel.
898pub fn span(ptr: var) Span(@TypeOf(ptr)) {899pub fn span(ptr: anytype) Span(@TypeOf(ptr)) {
899 if (@typeInfo(@TypeOf(ptr)) == .Optional) {900 if (@typeInfo(@TypeOf(ptr)) == .Optional) {
900 if (ptr) |non_null| {901 if (ptr) |non_null| {
901 return span(non_null);902 return span(non_null);
...@@ -923,7 +924,7 @@ test "span" {...@@ -923,7 +924,7 @@ test "span" {
923/// Same as `span`, except when there is both a sentinel and an array924/// Same as `span`, except when there is both a sentinel and an array
924/// length or slice length, scans the memory for the sentinel value925/// length or slice length, scans the memory for the sentinel value
925/// rather than using the length.926/// rather than using the length.
926pub fn spanZ(ptr: var) Span(@TypeOf(ptr)) {927pub fn spanZ(ptr: anytype) Span(@TypeOf(ptr)) {
927 if (@typeInfo(@TypeOf(ptr)) == .Optional) {928 if (@typeInfo(@TypeOf(ptr)) == .Optional) {
928 if (ptr) |non_null| {929 if (ptr) |non_null| {
929 return spanZ(non_null);930 return spanZ(non_null);
...@@ -952,7 +953,7 @@ test "spanZ" {...@@ -952,7 +953,7 @@ test "spanZ" {
952/// or a slice, and returns the length.953/// or a slice, and returns the length.
953/// In the case of a sentinel-terminated array, it uses the array length.954/// In the case of a sentinel-terminated array, it uses the array length.
954/// For C pointers it assumes it is a pointer-to-many with a 0 sentinel.955/// 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 {
956 return switch (@typeInfo(@TypeOf(value))) {957 return switch (@typeInfo(@TypeOf(value))) {
957 .Array => |info| info.len,958 .Array => |info| info.len,
958 .Vector => |info| info.len,959 .Vector => |info| info.len,
...@@ -1000,7 +1001,7 @@ test "len" {...@@ -1000,7 +1001,7 @@ test "len" {
1000/// In the case of a sentinel-terminated array, it scans the array1001/// In the case of a sentinel-terminated array, it scans the array
1001/// for a sentinel and uses that for the length, rather than using the array length.1002/// for a sentinel and uses that for the length, rather than using the array length.
1002/// For C pointers it assumes it is a pointer-to-many with a 0 sentinel.1003/// 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 {
1004 return switch (@typeInfo(@TypeOf(ptr))) {1005 return switch (@typeInfo(@TypeOf(ptr))) {
1005 .Array => |info| if (info.sentinel) |sentinel|1006 .Array => |info| if (info.sentinel) |sentinel|
1006 indexOfSentinel(info.child, sentinel, &ptr)1007 indexOfSentinel(info.child, sentinel, &ptr)
...@@ -2031,7 +2032,7 @@ fn AsBytesReturnType(comptime P: type) type {...@@ -2031,7 +2032,7 @@ fn AsBytesReturnType(comptime P: type) type {
2031}2032}
20322033
2033/// Given a pointer to a single item, returns a slice of the underlying bytes, preserving constness.2034/// 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)) {
2035 const P = @TypeOf(ptr);2036 const P = @TypeOf(ptr);
2036 return @ptrCast(AsBytesReturnType(P), ptr);2037 return @ptrCast(AsBytesReturnType(P), ptr);
2037}2038}
...@@ -2071,7 +2072,7 @@ test "asBytes" {...@@ -2071,7 +2072,7 @@ test "asBytes" {
2071}2072}
20722073
2073///Given any value, returns a copy of its bytes in an array.2074///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 {
2075 return asBytes(&value).*;2076 return asBytes(&value).*;
2076}2077}
20772078
...@@ -2106,7 +2107,7 @@ fn BytesAsValueReturnType(comptime T: type, comptime B: type) type {...@@ -2106,7 +2107,7 @@ fn BytesAsValueReturnType(comptime T: type, comptime B: type) type {
21062107
2107///Given a pointer to an array of bytes, returns a pointer to a value of the specified type2108///Given a pointer to an array of bytes, returns a pointer to a value of the specified type
2108/// backed by those bytes, preserving constness.2109/// 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)) {
2110 return @ptrCast(BytesAsValueReturnType(T, @TypeOf(bytes)), bytes);2111 return @ptrCast(BytesAsValueReturnType(T, @TypeOf(bytes)), bytes);
2111}2112}
21122113
...@@ -2149,7 +2150,7 @@ test "bytesAsValue" {...@@ -2149,7 +2150,7 @@ test "bytesAsValue" {
21492150
2150///Given a pointer to an array of bytes, returns a value of the specified type backed by a2151///Given a pointer to an array of bytes, returns a value of the specified type backed by a
2151/// copy of those bytes.2152/// copy of those bytes.
2152pub fn bytesToValue(comptime T: type, bytes: var) T {2153pub fn bytesToValue(comptime T: type, bytes: anytype) T {
2153 return bytesAsValue(T, bytes).*;2154 return bytesAsValue(T, bytes).*;
2154}2155}
2155test "bytesToValue" {2156test "bytesToValue" {
...@@ -2177,7 +2178,7 @@ fn BytesAsSliceReturnType(comptime T: type, comptime bytesType: type) type {...@@ -2177,7 +2178,7 @@ fn BytesAsSliceReturnType(comptime T: type, comptime bytesType: type) type {
2177 return if (trait.isConstPtr(bytesType)) []align(alignment) const T else []align(alignment) T;2178 return if (trait.isConstPtr(bytesType)) []align(alignment) const T else []align(alignment) T;
2178}2179}
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)) {
2181 // let's not give an undefined pointer to @ptrCast2182 // let's not give an undefined pointer to @ptrCast
2182 // it may be equal to zero and fail a null check2183 // it may be equal to zero and fail a null check
2183 if (bytes.len == 0) {2184 if (bytes.len == 0) {
...@@ -2256,7 +2257,7 @@ fn SliceAsBytesReturnType(comptime sliceType: type) type {...@@ -2256,7 +2257,7 @@ fn SliceAsBytesReturnType(comptime sliceType: type) type {
2256 return if (trait.isConstPtr(sliceType)) []align(alignment) const u8 else []align(alignment) u8;2257 return if (trait.isConstPtr(sliceType)) []align(alignment) const u8 else []align(alignment) u8;
2257}2258}
22582259
2259pub fn sliceAsBytes(slice: var) SliceAsBytesReturnType(@TypeOf(slice)) {2260pub fn sliceAsBytes(slice: anytype) SliceAsBytesReturnType(@TypeOf(slice)) {
2260 const Slice = @TypeOf(slice);2261 const Slice = @TypeOf(slice);
22612262
2262 // let's not give an undefined pointer to @ptrCast2263 // 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");...@@ -9,7 +9,7 @@ pub const trait = @import("meta/trait.zig");
99
10const TypeInfo = builtin.TypeInfo;10const TypeInfo = builtin.TypeInfo;
1111
12pub fn tagName(v: var) []const u8 {12pub fn tagName(v: anytype) []const u8 {
13 const T = @TypeOf(v);13 const T = @TypeOf(v);
14 switch (@typeInfo(T)) {14 switch (@typeInfo(T)) {
15 .ErrorSet => return @errorName(v),15 .ErrorSet => return @errorName(v),
...@@ -430,7 +430,7 @@ test "std.meta.TagType" {...@@ -430,7 +430,7 @@ test "std.meta.TagType" {
430}430}
431431
432///Returns the active tag of a tagged union432///Returns the active tag of a tagged union
433pub fn activeTag(u: var) @TagType(@TypeOf(u)) {433pub fn activeTag(u: anytype) @TagType(@TypeOf(u)) {
434 const T = @TypeOf(u);434 const T = @TypeOf(u);
435 return @as(@TagType(T), u);435 return @as(@TagType(T), u);
436}436}
...@@ -480,7 +480,7 @@ test "std.meta.TagPayloadType" {...@@ -480,7 +480,7 @@ test "std.meta.TagPayloadType" {
480480
481/// Compares two of any type for equality. Containers are compared on a field-by-field basis,481/// Compares two of any type for equality. Containers are compared on a field-by-field basis,
482/// where possible. Pointers are not followed.482/// where possible. Pointers are not followed.
483pub fn eql(a: var, b: @TypeOf(a)) bool {483pub fn eql(a: anytype, b: @TypeOf(a)) bool {
484 const T = @TypeOf(a);484 const T = @TypeOf(a);
485485
486 switch (@typeInfo(T)) {486 switch (@typeInfo(T)) {
...@@ -627,7 +627,7 @@ test "intToEnum with error return" {...@@ -627,7 +627,7 @@ test "intToEnum with error return" {
627627
628pub const IntToEnumError = error{InvalidEnumTag};628pub 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 {
631 inline for (@typeInfo(Tag).Enum.fields) |f| {631 inline for (@typeInfo(Tag).Enum.fields) |f| {
632 const this_tag_value = @field(Tag, f.name);632 const this_tag_value = @field(Tag, f.name);
633 if (tag_int == @enumToInt(this_tag_value)) {633 if (tag_int == @enumToInt(this_tag_value)) {
...@@ -696,7 +696,7 @@ pub fn Vector(comptime len: u32, comptime child: type) type {...@@ -696,7 +696,7 @@ pub fn Vector(comptime len: u32, comptime child: type) type {
696696
697/// Given a type and value, cast the value to the type as c would.697/// Given a type and value, cast the value to the type as c would.
698/// This is for translate-c and is not intended for general use.698/// 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 {
700 const TargetType = @TypeOf(target);700 const TargetType = @TypeOf(target);
701 switch (@typeInfo(DestType)) {701 switch (@typeInfo(DestType)) {
702 .Pointer => {702 .Pointer => {
lib/std/meta/trait.zig+4-4
...@@ -9,7 +9,7 @@ const meta = @import("../meta.zig");...@@ -9,7 +9,7 @@ const meta = @import("../meta.zig");
99
10pub const TraitFn = fn (type) bool;10pub const TraitFn = fn (type) bool;
1111
12pub fn multiTrait(comptime traits: var) TraitFn {12pub fn multiTrait(comptime traits: anytype) TraitFn {
13 const Closure = struct {13 const Closure = struct {
14 pub fn trait(comptime T: type) bool {14 pub fn trait(comptime T: type) bool {
15 inline for (traits) |t|15 inline for (traits) |t|
...@@ -342,7 +342,7 @@ test "std.meta.trait.isContainer" {...@@ -342,7 +342,7 @@ test "std.meta.trait.isContainer" {
342 testing.expect(!isContainer(u8));342 testing.expect(!isContainer(u8));
343}343}
344344
345pub fn hasDecls(comptime T: type, comptime names: var) bool {345pub fn hasDecls(comptime T: type, comptime names: anytype) bool {
346 inline for (names) |name| {346 inline for (names) |name| {
347 if (!@hasDecl(T, name))347 if (!@hasDecl(T, name))
348 return false;348 return false;
...@@ -368,7 +368,7 @@ test "std.meta.trait.hasDecls" {...@@ -368,7 +368,7 @@ test "std.meta.trait.hasDecls" {
368 testing.expect(!hasDecls(TestStruct2, tuple));368 testing.expect(!hasDecls(TestStruct2, tuple));
369}369}
370370
371pub fn hasFields(comptime T: type, comptime names: var) bool {371pub fn hasFields(comptime T: type, comptime names: anytype) bool {
372 inline for (names) |name| {372 inline for (names) |name| {
373 if (!@hasField(T, name))373 if (!@hasField(T, name))
374 return false;374 return false;
...@@ -394,7 +394,7 @@ test "std.meta.trait.hasFields" {...@@ -394,7 +394,7 @@ test "std.meta.trait.hasFields" {
394 testing.expect(!hasFields(TestStruct2, .{ "a", "b", "useless" }));394 testing.expect(!hasFields(TestStruct2, .{ "a", "b", "useless" }));
395}395}
396396
397pub fn hasFunctions(comptime T: type, comptime names: var) bool {397pub fn hasFunctions(comptime T: type, comptime names: anytype) bool {
398 inline for (names) |name| {398 inline for (names) |name| {
399 if (!hasFn(name)(T))399 if (!hasFn(name)(T))
400 return false;400 return false;
lib/std/net.zig+3-3
...@@ -427,7 +427,7 @@ pub const Address = extern union {...@@ -427,7 +427,7 @@ pub const Address = extern union {
427 self: Address,427 self: Address,
428 comptime fmt: []const u8,428 comptime fmt: []const u8,
429 options: std.fmt.FormatOptions,429 options: std.fmt.FormatOptions,
430 out_stream: var,430 out_stream: anytype,
431 ) !void {431 ) !void {
432 switch (self.any.family) {432 switch (self.any.family) {
433 os.AF_INET => {433 os.AF_INET => {
...@@ -1404,8 +1404,8 @@ fn resMSendRc(...@@ -1404,8 +1404,8 @@ fn resMSendRc(
14041404
1405fn dnsParse(1405fn dnsParse(
1406 r: []const u8,1406 r: []const u8,
1407 ctx: var,1407 ctx: anytype,
1408 comptime callback: var,1408 comptime callback: anytype,
1409) !void {1409) !void {
1410 // This implementation is ported from musl libc.1410 // This implementation is ported from musl libc.
1411 // A more idiomatic "ziggy" implementation would be welcome.1411 // 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 {...@@ -4068,7 +4068,7 @@ pub fn nanosleep(seconds: u64, nanoseconds: u64) void {
4068}4068}
40694069
4070pub fn dl_iterate_phdr(4070pub fn dl_iterate_phdr(
4071 context: var,4071 context: anytype,
4072 comptime Error: type,4072 comptime Error: type,
4073 comptime callback: fn (info: *dl_phdr_info, size: usize, context: @TypeOf(context)) Error!void,4073 comptime callback: fn (info: *dl_phdr_info, size: usize, context: @TypeOf(context)) Error!void,
4074) Error!void {4074) Error!void {
lib/std/os/uefi.zig+1-1
...@@ -28,7 +28,7 @@ pub const Guid = extern struct {...@@ -28,7 +28,7 @@ pub const Guid = extern struct {
28 self: @This(),28 self: @This(),
29 comptime f: []const u8,29 comptime f: []const u8,
30 options: std.fmt.FormatOptions,30 options: std.fmt.FormatOptions,
31 out_stream: var,31 out_stream: anytype,
32 ) Errors!void {32 ) Errors!void {
33 if (f.len == 0) {33 if (f.len == 0) {
34 return std.fmt.format(out_stream, "{x:0>8}-{x:0>4}-{x:0>4}-{x:0>2}{x:0>2}-{x:0>12}", .{34 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 {...@@ -224,7 +224,7 @@ pub const Progress = struct {
224 self.prev_refresh_timestamp = self.timer.read();224 self.prev_refresh_timestamp = self.timer.read();
225 }225 }
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 {
228 const file = self.terminal orelse return;228 const file = self.terminal orelse return;
229 self.refresh();229 self.refresh();
230 file.outStream().print(format, args) catch {230 file.outStream().print(format, args) catch {
...@@ -234,7 +234,7 @@ pub const Progress = struct {...@@ -234,7 +234,7 @@ pub const Progress = struct {
234 self.columns_written = 0;234 self.columns_written = 0;
235 }235 }
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 {
238 if (std.fmt.bufPrint(self.output_buffer[end.*..], format, args)) |written| {238 if (std.fmt.bufPrint(self.output_buffer[end.*..], format, args)) |written| {
239 const amt = written.len;239 const amt = written.len;
240 end.* += amt;240 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...@@ -122,7 +122,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
122 self.* = undefined;122 self.* = undefined;
123 }123 }
124124
125 pub fn at(self: var, i: usize) AtType(@TypeOf(self)) {125 pub fn at(self: anytype, i: usize) AtType(@TypeOf(self)) {
126 assert(i < self.len);126 assert(i < self.len);
127 return self.uncheckedAt(i);127 return self.uncheckedAt(i);
128 }128 }
...@@ -241,7 +241,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type...@@ -241,7 +241,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type
241 }241 }
242 }242 }
243243
244 pub fn uncheckedAt(self: var, index: usize) AtType(@TypeOf(self)) {244 pub fn uncheckedAt(self: anytype, index: usize) AtType(@TypeOf(self)) {
245 if (index < prealloc_item_count) {245 if (index < prealloc_item_count) {
246 return &self.prealloc_segment[index];246 return &self.prealloc_segment[index];
247 }247 }
lib/std/sort.zig+19-19
...@@ -9,7 +9,7 @@ pub fn binarySearch(...@@ -9,7 +9,7 @@ pub fn binarySearch(
9 comptime T: type,9 comptime T: type,
10 key: T,10 key: T,
11 items: []const T,11 items: []const T,
12 context: var,12 context: anytype,
13 comptime compareFn: fn (context: @TypeOf(context), lhs: T, rhs: T) math.Order,13 comptime compareFn: fn (context: @TypeOf(context), lhs: T, rhs: T) math.Order,
14) ?usize {14) ?usize {
15 var left: usize = 0;15 var left: usize = 0;
...@@ -76,7 +76,7 @@ test "binarySearch" {...@@ -76,7 +76,7 @@ test "binarySearch" {
76pub fn insertionSort(76pub fn insertionSort(
77 comptime T: type,77 comptime T: type,
78 items: []T,78 items: []T,
79 context: var,79 context: anytype,
80 comptime lessThan: fn (context: @TypeOf(context), lhs: T, rhs: T) bool,80 comptime lessThan: fn (context: @TypeOf(context), lhs: T, rhs: T) bool,
81) void {81) void {
82 var i: usize = 1;82 var i: usize = 1;
...@@ -182,7 +182,7 @@ const Pull = struct {...@@ -182,7 +182,7 @@ const Pull = struct {
182pub fn sort(182pub fn sort(
183 comptime T: type,183 comptime T: type,
184 items: []T,184 items: []T,
185 context: var,185 context: anytype,
186 comptime lessThan: fn (context: @TypeOf(context), lhs: T, rhs: T) bool,186 comptime lessThan: fn (context: @TypeOf(context), lhs: T, rhs: T) bool,
187) void {187) void {
188 // Implementation ported from https://github.com/BonzaiThePenguin/WikiSort/blob/master/WikiSort.c188 // Implementation ported from https://github.com/BonzaiThePenguin/WikiSort/blob/master/WikiSort.c
...@@ -813,7 +813,7 @@ fn mergeInPlace(...@@ -813,7 +813,7 @@ fn mergeInPlace(
813 items: []T,813 items: []T,
814 A_arg: Range,814 A_arg: Range,
815 B_arg: Range,815 B_arg: Range,
816 context: var,816 context: anytype,
817 comptime lessThan: fn (@TypeOf(context), T, T) bool,817 comptime lessThan: fn (@TypeOf(context), T, T) bool,
818) void {818) void {
819 if (A_arg.length() == 0 or B_arg.length() == 0) return;819 if (A_arg.length() == 0 or B_arg.length() == 0) return;
...@@ -862,7 +862,7 @@ fn mergeInternal(...@@ -862,7 +862,7 @@ fn mergeInternal(
862 items: []T,862 items: []T,
863 A: Range,863 A: Range,
864 B: Range,864 B: Range,
865 context: var,865 context: anytype,
866 comptime lessThan: fn (@TypeOf(context), T, T) bool,866 comptime lessThan: fn (@TypeOf(context), T, T) bool,
867 buffer: Range,867 buffer: Range,
868) void {868) void {
...@@ -906,7 +906,7 @@ fn findFirstForward(...@@ -906,7 +906,7 @@ fn findFirstForward(
906 items: []T,906 items: []T,
907 value: T,907 value: T,
908 range: Range,908 range: Range,
909 context: var,909 context: anytype,
910 comptime lessThan: fn (@TypeOf(context), T, T) bool,910 comptime lessThan: fn (@TypeOf(context), T, T) bool,
911 unique: usize,911 unique: usize,
912) usize {912) usize {
...@@ -928,7 +928,7 @@ fn findFirstBackward(...@@ -928,7 +928,7 @@ fn findFirstBackward(
928 items: []T,928 items: []T,
929 value: T,929 value: T,
930 range: Range,930 range: Range,
931 context: var,931 context: anytype,
932 comptime lessThan: fn (@TypeOf(context), T, T) bool,932 comptime lessThan: fn (@TypeOf(context), T, T) bool,
933 unique: usize,933 unique: usize,
934) usize {934) usize {
...@@ -950,7 +950,7 @@ fn findLastForward(...@@ -950,7 +950,7 @@ fn findLastForward(
950 items: []T,950 items: []T,
951 value: T,951 value: T,
952 range: Range,952 range: Range,
953 context: var,953 context: anytype,
954 comptime lessThan: fn (@TypeOf(context), T, T) bool,954 comptime lessThan: fn (@TypeOf(context), T, T) bool,
955 unique: usize,955 unique: usize,
956) usize {956) usize {
...@@ -972,7 +972,7 @@ fn findLastBackward(...@@ -972,7 +972,7 @@ fn findLastBackward(
972 items: []T,972 items: []T,
973 value: T,973 value: T,
974 range: Range,974 range: Range,
975 context: var,975 context: anytype,
976 comptime lessThan: fn (@TypeOf(context), T, T) bool,976 comptime lessThan: fn (@TypeOf(context), T, T) bool,
977 unique: usize,977 unique: usize,
978) usize {978) usize {
...@@ -994,7 +994,7 @@ fn binaryFirst(...@@ -994,7 +994,7 @@ fn binaryFirst(
994 items: []T,994 items: []T,
995 value: T,995 value: T,
996 range: Range,996 range: Range,
997 context: var,997 context: anytype,
998 comptime lessThan: fn (@TypeOf(context), T, T) bool,998 comptime lessThan: fn (@TypeOf(context), T, T) bool,
999) usize {999) usize {
1000 var curr = range.start;1000 var curr = range.start;
...@@ -1017,7 +1017,7 @@ fn binaryLast(...@@ -1017,7 +1017,7 @@ fn binaryLast(
1017 items: []T,1017 items: []T,
1018 value: T,1018 value: T,
1019 range: Range,1019 range: Range,
1020 context: var,1020 context: anytype,
1021 comptime lessThan: fn (@TypeOf(context), T, T) bool,1021 comptime lessThan: fn (@TypeOf(context), T, T) bool,
1022) usize {1022) usize {
1023 var curr = range.start;1023 var curr = range.start;
...@@ -1040,7 +1040,7 @@ fn mergeInto(...@@ -1040,7 +1040,7 @@ fn mergeInto(
1040 from: []T,1040 from: []T,
1041 A: Range,1041 A: Range,
1042 B: Range,1042 B: Range,
1043 context: var,1043 context: anytype,
1044 comptime lessThan: fn (@TypeOf(context), T, T) bool,1044 comptime lessThan: fn (@TypeOf(context), T, T) bool,
1045 into: []T,1045 into: []T,
1046) void {1046) void {
...@@ -1078,7 +1078,7 @@ fn mergeExternal(...@@ -1078,7 +1078,7 @@ fn mergeExternal(
1078 items: []T,1078 items: []T,
1079 A: Range,1079 A: Range,
1080 B: Range,1080 B: Range,
1081 context: var,1081 context: anytype,
1082 comptime lessThan: fn (@TypeOf(context), T, T) bool,1082 comptime lessThan: fn (@TypeOf(context), T, T) bool,
1083 cache: []T,1083 cache: []T,
1084) void {1084) void {
...@@ -1112,7 +1112,7 @@ fn mergeExternal(...@@ -1112,7 +1112,7 @@ fn mergeExternal(
1112fn swap(1112fn swap(
1113 comptime T: type,1113 comptime T: type,
1114 items: []T,1114 items: []T,
1115 context: var,1115 context: anytype,
1116 comptime lessThan: fn (@TypeOf(context), lhs: T, rhs: T) bool,1116 comptime lessThan: fn (@TypeOf(context), lhs: T, rhs: T) bool,
1117 order: *[8]u8,1117 order: *[8]u8,
1118 x: usize,1118 x: usize,
...@@ -1358,7 +1358,7 @@ fn fuzzTest(rng: *std.rand.Random) !void {...@@ -1358,7 +1358,7 @@ fn fuzzTest(rng: *std.rand.Random) !void {
1358pub fn argMin(1358pub fn argMin(
1359 comptime T: type,1359 comptime T: type,
1360 items: []const T,1360 items: []const T,
1361 context: var,1361 context: anytype,
1362 comptime lessThan: fn (@TypeOf(context), lhs: T, rhs: T) bool,1362 comptime lessThan: fn (@TypeOf(context), lhs: T, rhs: T) bool,
1363) ?usize {1363) ?usize {
1364 if (items.len == 0) {1364 if (items.len == 0) {
...@@ -1390,7 +1390,7 @@ test "argMin" {...@@ -1390,7 +1390,7 @@ test "argMin" {
1390pub fn min(1390pub fn min(
1391 comptime T: type,1391 comptime T: type,
1392 items: []const T,1392 items: []const T,
1393 context: var,1393 context: anytype,
1394 comptime lessThan: fn (context: @TypeOf(context), lhs: T, rhs: T) bool,1394 comptime lessThan: fn (context: @TypeOf(context), lhs: T, rhs: T) bool,
1395) ?T {1395) ?T {
1396 const i = argMin(T, items, context, lessThan) orelse return null;1396 const i = argMin(T, items, context, lessThan) orelse return null;
...@@ -1410,7 +1410,7 @@ test "min" {...@@ -1410,7 +1410,7 @@ test "min" {
1410pub fn argMax(1410pub fn argMax(
1411 comptime T: type,1411 comptime T: type,
1412 items: []const T,1412 items: []const T,
1413 context: var,1413 context: anytype,
1414 comptime lessThan: fn (context: @TypeOf(context), lhs: T, rhs: T) bool,1414 comptime lessThan: fn (context: @TypeOf(context), lhs: T, rhs: T) bool,
1415) ?usize {1415) ?usize {
1416 if (items.len == 0) {1416 if (items.len == 0) {
...@@ -1442,7 +1442,7 @@ test "argMax" {...@@ -1442,7 +1442,7 @@ test "argMax" {
1442pub fn max(1442pub fn max(
1443 comptime T: type,1443 comptime T: type,
1444 items: []const T,1444 items: []const T,
1445 context: var,1445 context: anytype,
1446 comptime lessThan: fn (context: @TypeOf(context), lhs: T, rhs: T) bool,1446 comptime lessThan: fn (context: @TypeOf(context), lhs: T, rhs: T) bool,
1447) ?T {1447) ?T {
1448 const i = argMax(T, items, context, lessThan) orelse return null;1448 const i = argMax(T, items, context, lessThan) orelse return null;
...@@ -1462,7 +1462,7 @@ test "max" {...@@ -1462,7 +1462,7 @@ test "max" {
1462pub fn isSorted(1462pub fn isSorted(
1463 comptime T: type,1463 comptime T: type,
1464 items: []const T,1464 items: []const T,
1465 context: var,1465 context: anytype,
1466 comptime lessThan: fn (context: @TypeOf(context), lhs: T, rhs: T) bool,1466 comptime lessThan: fn (context: @TypeOf(context), lhs: T, rhs: T) bool,
1467) bool {1467) bool {
1468 var i: usize = 1;1468 var i: usize = 1;
lib/std/special/build_runner.zig+2-2
...@@ -135,7 +135,7 @@ fn runBuild(builder: *Builder) anyerror!void {...@@ -135,7 +135,7 @@ fn runBuild(builder: *Builder) anyerror!void {
135 }135 }
136}136}
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 {
139 // run the build script to collect the options139 // run the build script to collect the options
140 if (!already_ran_build) {140 if (!already_ran_build) {
141 builder.setInstallPrefix(null);141 builder.setInstallPrefix(null);
...@@ -202,7 +202,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {...@@ -202,7 +202,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {
202 );202 );
203}203}
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 {
206 usage(builder, already_ran_build, out_stream) catch {};206 usage(builder, already_ran_build, out_stream) catch {};
207 process.exit(1);207 process.exit(1);
208}208}
lib/std/special/test_runner.zig+2-2
...@@ -79,9 +79,9 @@ pub fn log(...@@ -79,9 +79,9 @@ pub fn log(
79 comptime message_level: std.log.Level,79 comptime message_level: std.log.Level,
80 comptime scope: @Type(.EnumLiteral),80 comptime scope: @Type(.EnumLiteral),
81 comptime format: []const u8,81 comptime format: []const u8,
82 args: var,82 args: anytype,
83) void {83) void {
84 if (@enumToInt(message_level) <= @enumToInt(std.testing.log_level)) {84 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);
86 }86 }
87}87}
lib/std/target.zig+6-13
...@@ -108,23 +108,16 @@ pub const Target = struct {...@@ -108,23 +108,16 @@ pub const Target = struct {
108 self: WindowsVersion,108 self: WindowsVersion,
109 comptime fmt: []const u8,109 comptime fmt: []const u8,
110 options: std.fmt.FormatOptions,110 options: std.fmt.FormatOptions,
111 out_stream: var,111 out_stream: anytype,
112 ) !void {112 ) !void {
113 if (fmt.len > 0 and fmt[0] == 's') { 113 if (fmt.len > 0 and fmt[0] == 's') {
114 if (114 if (@enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.win10_19h1)) {
115 @enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.win10_19h1)
116 ) {
117 try std.fmt.format(out_stream, ".{}", .{@tagName(self)});115 try std.fmt.format(out_stream, ".{}", .{@tagName(self)});
118 } else {116 } else {
119 try std.fmt.format(out_stream,117 try std.fmt.format(out_stream, "@intToEnum(Target.Os.WindowsVersion, {})", .{@enumToInt(self)});
120 "@intToEnum(Target.Os.WindowsVersion, {})",
121 .{ @enumToInt(self) }
122 );
123 }118 }
124 } else {119 } else {
125 if (120 if (@enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.win10_19h1)) {
126 @enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.win10_19h1)
127 ) {
128 try std.fmt.format(out_stream, "WindowsVersion.{}", .{@tagName(self)});121 try std.fmt.format(out_stream, "WindowsVersion.{}", .{@tagName(self)});
129 } else {122 } else {
130 try std.fmt.format(out_stream, "WindowsVersion(", .{@typeName(@This())});123 try std.fmt.format(out_stream, "WindowsVersion(", .{@typeName(@This())});
...@@ -1198,7 +1191,7 @@ pub const Target = struct {...@@ -1198,7 +1191,7 @@ pub const Target = struct {
1198 pub fn standardDynamicLinkerPath(self: Target) DynamicLinker {1191 pub fn standardDynamicLinkerPath(self: Target) DynamicLinker {
1199 var result: DynamicLinker = .{};1192 var result: DynamicLinker = .{};
1200 const S = struct {1193 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 {
1202 r.max_byte = @intCast(u8, (std.fmt.bufPrint(&r.buffer, fmt, args) catch unreachable).len - 1);1195 r.max_byte = @intCast(u8, (std.fmt.bufPrint(&r.buffer, fmt, args) catch unreachable).len - 1);
1203 return r.*;1196 return r.*;
1204 }1197 }
lib/std/testing.zig+2-2
...@@ -19,7 +19,7 @@ pub var log_level = std.log.Level.warn;...@@ -19,7 +19,7 @@ pub var log_level = std.log.Level.warn;
1919
20/// This function is intended to be used only in tests. It prints diagnostics to stderr20/// This function is intended to be used only in tests. It prints diagnostics to stderr
21/// and then aborts when actual_error_union is not expected_error.21/// 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 {
23 if (actual_error_union) |actual_payload| {23 if (actual_error_union) |actual_payload| {
24 std.debug.panic("expected error.{}, found {}", .{ @errorName(expected_error), actual_payload });24 std.debug.panic("expected error.{}, found {}", .{ @errorName(expected_error), actual_payload });
25 } else |actual_error| {25 } else |actual_error| {
...@@ -36,7 +36,7 @@ pub fn expectError(expected_error: anyerror, actual_error_union: var) void {...@@ -36,7 +36,7 @@ pub fn expectError(expected_error: anyerror, actual_error_union: var) void {
36/// equal, prints diagnostics to stderr to show exactly how they are not equal,36/// equal, prints diagnostics to stderr to show exactly how they are not equal,
37/// then aborts.37/// then aborts.
38/// The types must match exactly.38/// The types must match exactly.
39pub fn expectEqual(expected: var, actual: @TypeOf(expected)) void {39pub fn expectEqual(expected: anytype, actual: @TypeOf(expected)) void {
40 switch (@typeInfo(@TypeOf(actual))) {40 switch (@typeInfo(@TypeOf(actual))) {
41 .NoReturn,41 .NoReturn,
42 .BoundFn,42 .BoundFn,
lib/std/thread.zig+1-1
...@@ -143,7 +143,7 @@ pub const Thread = struct {...@@ -143,7 +143,7 @@ pub const Thread = struct {
143 /// fn startFn(@TypeOf(context)) T143 /// fn startFn(@TypeOf(context)) T
144 /// where T is u8, noreturn, void, or !void144 /// where T is u8, noreturn, void, or !void
145 /// caller must call wait on the returned thread145 /// 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 {
147 if (builtin.single_threaded) @compileError("cannot spawn thread when building in single-threaded mode");147 if (builtin.single_threaded) @compileError("cannot spawn thread when building in single-threaded mode");
148 // TODO compile-time call graph analysis to determine stack upper bound148 // TODO compile-time call graph analysis to determine stack upper bound
149 // https://github.com/ziglang/zig/issues/157149 // https://github.com/ziglang/zig/issues/157
lib/std/zig/ast.zig+20-20
...@@ -29,7 +29,7 @@ pub const Tree = struct {...@@ -29,7 +29,7 @@ pub const Tree = struct {
29 self.arena.promote(self.gpa).deinit();29 self.arena.promote(self.gpa).deinit();
30 }30 }
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 {
33 return parse_error.render(self.token_ids, stream);33 return parse_error.render(self.token_ids, stream);
34 }34 }
3535
...@@ -167,7 +167,7 @@ pub const Error = union(enum) {...@@ -167,7 +167,7 @@ pub const Error = union(enum) {
167 DeclBetweenFields: DeclBetweenFields,167 DeclBetweenFields: DeclBetweenFields,
168 InvalidAnd: InvalidAnd,168 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 {
171 switch (self.*) {171 switch (self.*) {
172 .InvalidToken => |*x| return x.render(tokens, stream),172 .InvalidToken => |*x| return x.render(tokens, stream),
173 .ExpectedContainerMembers => |*x| return x.render(tokens, stream),173 .ExpectedContainerMembers => |*x| return x.render(tokens, stream),
...@@ -322,7 +322,7 @@ pub const Error = union(enum) {...@@ -322,7 +322,7 @@ pub const Error = union(enum) {
322 pub const ExpectedCall = struct {322 pub const ExpectedCall = struct {
323 node: *Node,323 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 {
326 return stream.print("expected " ++ @tagName(Node.Id.Call) ++ ", found {}", .{326 return stream.print("expected " ++ @tagName(Node.Id.Call) ++ ", found {}", .{
327 @tagName(self.node.id),327 @tagName(self.node.id),
328 });328 });
...@@ -332,7 +332,7 @@ pub const Error = union(enum) {...@@ -332,7 +332,7 @@ pub const Error = union(enum) {
332 pub const ExpectedCallOrFnProto = struct {332 pub const ExpectedCallOrFnProto = struct {
333 node: *Node,333 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 {
336 return stream.print("expected " ++ @tagName(Node.Id.Call) ++ " or " ++336 return stream.print("expected " ++ @tagName(Node.Id.Call) ++ " or " ++
337 @tagName(Node.Id.FnProto) ++ ", found {}", .{@tagName(self.node.id)});337 @tagName(Node.Id.FnProto) ++ ", found {}", .{@tagName(self.node.id)});
338 }338 }
...@@ -342,7 +342,7 @@ pub const Error = union(enum) {...@@ -342,7 +342,7 @@ pub const Error = union(enum) {
342 token: TokenIndex,342 token: TokenIndex,
343 expected_id: Token.Id,343 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 {
346 const found_token = tokens[self.token];346 const found_token = tokens[self.token];
347 switch (found_token) {347 switch (found_token) {
348 .Invalid => {348 .Invalid => {
...@@ -360,7 +360,7 @@ pub const Error = union(enum) {...@@ -360,7 +360,7 @@ pub const Error = union(enum) {
360 token: TokenIndex,360 token: TokenIndex,
361 end_id: Token.Id,361 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 {
364 const actual_token = tokens[self.token];364 const actual_token = tokens[self.token];
365 return stream.print("expected ',' or '{}', found '{}'", .{365 return stream.print("expected ',' or '{}', found '{}'", .{
366 self.end_id.symbol(),366 self.end_id.symbol(),
...@@ -375,7 +375,7 @@ pub const Error = union(enum) {...@@ -375,7 +375,7 @@ pub const Error = union(enum) {
375375
376 token: TokenIndex,376 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 {
379 const actual_token = tokens[self.token];379 const actual_token = tokens[self.token];
380 return stream.print(msg, .{actual_token.symbol()});380 return stream.print(msg, .{actual_token.symbol()});
381 }381 }
...@@ -388,7 +388,7 @@ pub const Error = union(enum) {...@@ -388,7 +388,7 @@ pub const Error = union(enum) {
388388
389 token: TokenIndex,389 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 {
392 return stream.writeAll(msg);392 return stream.writeAll(msg);
393 }393 }
394 };394 };
...@@ -434,7 +434,7 @@ pub const Node = struct {...@@ -434,7 +434,7 @@ pub const Node = struct {
434 Suspend,434 Suspend,
435435
436 // Type expressions436 // Type expressions
437 VarType,437 AnyType,
438 ErrorType,438 ErrorType,
439 FnProto,439 FnProto,
440 AnyFrameType,440 AnyFrameType,
...@@ -993,7 +993,7 @@ pub const Node = struct {...@@ -993,7 +993,7 @@ pub const Node = struct {
993 param_type: ParamType,993 param_type: ParamType,
994994
995 pub const ParamType = union(enum) {995 pub const ParamType = union(enum) {
996 var_type: *Node,996 any_type: *Node,
997 var_args: TokenIndex,997 var_args: TokenIndex,
998 type_expr: *Node,998 type_expr: *Node,
999 };999 };
...@@ -1004,7 +1004,7 @@ pub const Node = struct {...@@ -1004,7 +1004,7 @@ pub const Node = struct {
1004 if (i < 1) {1004 if (i < 1) {
1005 switch (self.param_type) {1005 switch (self.param_type) {
1006 .var_args => return null,1006 .var_args => return null,
1007 .var_type, .type_expr => |node| return node,1007 .any_type, .type_expr => |node| return node,
1008 }1008 }
1009 }1009 }
1010 i -= 1;1010 i -= 1;
...@@ -1018,14 +1018,14 @@ pub const Node = struct {...@@ -1018,14 +1018,14 @@ pub const Node = struct {
1018 if (self.name_token) |name_token| return name_token;1018 if (self.name_token) |name_token| return name_token;
1019 switch (self.param_type) {1019 switch (self.param_type) {
1020 .var_args => |tok| return tok,1020 .var_args => |tok| return tok,
1021 .var_type, .type_expr => |node| return node.firstToken(),1021 .any_type, .type_expr => |node| return node.firstToken(),
1022 }1022 }
1023 }1023 }
10241024
1025 pub fn lastToken(self: *const ParamDecl) TokenIndex {1025 pub fn lastToken(self: *const ParamDecl) TokenIndex {
1026 switch (self.param_type) {1026 switch (self.param_type) {
1027 .var_args => |tok| return tok,1027 .var_args => |tok| return tok,
1028 .var_type, .type_expr => |node| return node.lastToken(),1028 .any_type, .type_expr => |node| return node.lastToken(),
1029 }1029 }
1030 }1030 }
1031 };1031 };
...@@ -1052,12 +1052,12 @@ pub const Node = struct {...@@ -1052,12 +1052,12 @@ pub const Node = struct {
1052 const params_len: usize = if (self.params_len == 0)1052 const params_len: usize = if (self.params_len == 0)
1053 01053 0
1054 else switch (self.paramsConst()[self.params_len - 1].param_type) {1054 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,
1056 .var_args => self.params_len - 1,1056 .var_args => self.params_len - 1,
1057 };1057 };
1058 if (i < params_len) {1058 if (i < params_len) {
1059 switch (self.paramsConst()[i].param_type) {1059 switch (self.paramsConst()[i].param_type) {
1060 .var_type => |n| return n,1060 .any_type => |n| return n,
1061 .var_args => unreachable,1061 .var_args => unreachable,
1062 .type_expr => |n| return n,1062 .type_expr => |n| return n,
1063 }1063 }
...@@ -2732,19 +2732,19 @@ pub const Node = struct {...@@ -2732,19 +2732,19 @@ pub const Node = struct {
2732 }2732 }
2733 };2733 };
27342734
2735 pub const VarType = struct {2735 pub const AnyType = struct {
2736 base: Node = Node{ .id = .VarType },2736 base: Node = Node{ .id = .AnyType },
2737 token: TokenIndex,2737 token: TokenIndex,
27382738
2739 pub fn iterate(self: *const VarType, index: usize) ?*Node {2739 pub fn iterate(self: *const AnyType, index: usize) ?*Node {
2740 return null;2740 return null;
2741 }2741 }
27422742
2743 pub fn firstToken(self: *const VarType) TokenIndex {2743 pub fn firstToken(self: *const AnyType) TokenIndex {
2744 return self.token;2744 return self.token;
2745 }2745 }
27462746
2747 pub fn lastToken(self: *const VarType) TokenIndex {2747 pub fn lastToken(self: *const AnyType) TokenIndex {
2748 return self.token;2748 return self.token;
2749 }2749 }
2750 };2750 };
lib/std/zig/parse.zig+12-11
...@@ -488,7 +488,7 @@ const Parser = struct {...@@ -488,7 +488,7 @@ const Parser = struct {
488 return p.parseUse();488 return p.parseUse();
489 }489 }
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)
492 fn parseFnProto(p: *Parser) !?*Node {492 fn parseFnProto(p: *Parser) !?*Node {
493 // TODO: Remove once extern/async fn rewriting is493 // TODO: Remove once extern/async fn rewriting is
494 var is_async = false;494 var is_async = false;
...@@ -519,7 +519,7 @@ const Parser = struct {...@@ -519,7 +519,7 @@ const Parser = struct {
519 const callconv_expr = try p.parseCallconv();519 const callconv_expr = try p.parseCallconv();
520 const exclamation_token = p.eatToken(.Bang);520 const exclamation_token = p.eatToken(.Bang);
521521
522 const return_type_expr = (try p.parseVarType()) orelse522 const return_type_expr = (try p.parseAnyType()) orelse
523 try p.expectNodeRecoverable(parseTypeExpr, .{523 try p.expectNodeRecoverable(parseTypeExpr, .{
524 // most likely the user forgot to specify the return type.524 // most likely the user forgot to specify the return type.
525 // Mark return type as invalid and try to continue.525 // Mark return type as invalid and try to continue.
...@@ -618,9 +618,9 @@ const Parser = struct {...@@ -618,9 +618,9 @@ const Parser = struct {
618 var align_expr: ?*Node = null;618 var align_expr: ?*Node = null;
619 var type_expr: ?*Node = null;619 var type_expr: ?*Node = null;
620 if (p.eatToken(.Colon)) |_| {620 if (p.eatToken(.Colon)) |_| {
621 if (p.eatToken(.Keyword_var)) |var_tok| {621 if (p.eatToken(.Keyword_anytype) orelse p.eatToken(.Keyword_var)) |anytype_tok| {
622 const node = try p.arena.allocator.create(Node.VarType);622 const node = try p.arena.allocator.create(Node.AnyType);
623 node.* = .{ .token = var_tok };623 node.* = .{ .token = anytype_tok };
624 type_expr = &node.base;624 type_expr = &node.base;
625 } else {625 } else {
626 type_expr = try p.expectNode(parseTypeExpr, .{626 type_expr = try p.expectNode(parseTypeExpr, .{
...@@ -2022,13 +2022,13 @@ const Parser = struct {...@@ -2022,13 +2022,13 @@ const Parser = struct {
2022 }2022 }
20232023
2024 /// ParamType2024 /// ParamType
2025 /// <- KEYWORD_var2025 /// <- Keyword_anytype
2026 /// / DOT32026 /// / DOT3
2027 /// / TypeExpr2027 /// / TypeExpr
2028 fn parseParamType(p: *Parser) !?Node.FnProto.ParamDecl.ParamType {2028 fn parseParamType(p: *Parser) !?Node.FnProto.ParamDecl.ParamType {
2029 // TODO cast from tuple to error union is broken2029 // TODO cast from tuple to error union is broken
2030 const P = Node.FnProto.ParamDecl.ParamType;2030 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 };
2032 if (p.eatToken(.Ellipsis3)) |token| return P{ .var_args = token };2032 if (p.eatToken(.Ellipsis3)) |token| return P{ .var_args = token };
2033 if (try p.parseTypeExpr()) |node| return P{ .type_expr = node };2033 if (try p.parseTypeExpr()) |node| return P{ .type_expr = node };
2034 return null;2034 return null;
...@@ -2955,7 +2955,7 @@ const Parser = struct {...@@ -2955,7 +2955,7 @@ const Parser = struct {
29552955
2956 const NodeParseFn = fn (p: *Parser) Error!?*Node;2956 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) {
2959 return struct {2959 return struct {
2960 pub fn parse(p: *Parser) ![]E {2960 pub fn parse(p: *Parser) ![]E {
2961 var list = std.ArrayList(E).init(p.gpa);2961 var list = std.ArrayList(E).init(p.gpa);
...@@ -3057,9 +3057,10 @@ const Parser = struct {...@@ -3057,9 +3057,10 @@ const Parser = struct {
3057 return &node.base;3057 return &node.base;
3058 }3058 }
30593059
3060 fn parseVarType(p: *Parser) !?*Node {3060 fn parseAnyType(p: *Parser) !?*Node {
3061 const token = p.eatToken(.Keyword_var) orelse return null;3061 const token = p.eatToken(.Keyword_anytype) orelse
3062 const node = try p.arena.allocator.create(Node.VarType);3062 p.eatToken(.Keyword_var) orelse return null; // TODO remove in next release cycle
3063 const node = try p.arena.allocator.create(Node.AnyType);
3063 node.* = .{3064 node.* = .{
3064 .token = token,3065 .token = token,
3065 };3066 };
lib/std/zig/parser_test.zig+21-5
...@@ -422,10 +422,10 @@ test "zig fmt: asm expression with comptime content" {...@@ -422,10 +422,10 @@ test "zig fmt: asm expression with comptime content" {
422 );422 );
423}423}
424424
425test "zig fmt: var struct field" {425test "zig fmt: anytype struct field" {
426 try testCanonical(426 try testCanonical(
427 \\pub const Pointer = struct {427 \\pub const Pointer = struct {
428 \\ sentinel: var,428 \\ sentinel: anytype,
429 \\};429 \\};
430 \\430 \\
431 );431 );
...@@ -1932,7 +1932,7 @@ test "zig fmt: preserve spacing" {...@@ -1932,7 +1932,7 @@ test "zig fmt: preserve spacing" {
1932test "zig fmt: return types" {1932test "zig fmt: return types" {
1933 try testCanonical(1933 try testCanonical(
1934 \\pub fn main() !void {}1934 \\pub fn main() !void {}
1935 \\pub fn main() var {}1935 \\pub fn main() anytype {}
1936 \\pub fn main() i32 {}1936 \\pub fn main() i32 {}
1937 \\1937 \\
1938 );1938 );
...@@ -2140,9 +2140,9 @@ test "zig fmt: call expression" {...@@ -2140,9 +2140,9 @@ test "zig fmt: call expression" {
2140 );2140 );
2141}2141}
21422142
2143test "zig fmt: var type" {2143test "zig fmt: anytype type" {
2144 try testCanonical(2144 try testCanonical(
2145 \\fn print(args: var) var {}2145 \\fn print(args: anytype) anytype {}
2146 \\2146 \\
2147 );2147 );
2148}2148}
...@@ -3180,6 +3180,22 @@ test "zig fmt: convert extern fn proto into callconv(.C)" {...@@ -3180,6 +3180,22 @@ test "zig fmt: convert extern fn proto into callconv(.C)" {
3180 );3180 );
3181}3181}
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
3183const std = @import("std");3199const std = @import("std");
3184const mem = std.mem;3200const mem = std.mem;
3185const warn = std.debug.warn;3201const warn = std.debug.warn;
lib/std/zig/render.zig+28-22
...@@ -12,7 +12,7 @@ pub const Error = error{...@@ -12,7 +12,7 @@ pub const Error = error{
12};12};
1313
14/// Returns whether anything changed14/// 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 {
16 // cannot render an invalid tree16 // cannot render an invalid tree
17 std.debug.assert(tree.errors.len == 0);17 std.debug.assert(tree.errors.len == 0);
1818
...@@ -64,7 +64,7 @@ pub fn render(allocator: *mem.Allocator, stream: var, tree: *ast.Tree) (@TypeOf(...@@ -64,7 +64,7 @@ pub fn render(allocator: *mem.Allocator, stream: var, tree: *ast.Tree) (@TypeOf(
6464
65fn renderRoot(65fn renderRoot(
66 allocator: *mem.Allocator,66 allocator: *mem.Allocator,
67 stream: var,67 stream: anytype,
68 tree: *ast.Tree,68 tree: *ast.Tree,
69) (@TypeOf(stream).Error || Error)!void {69) (@TypeOf(stream).Error || Error)!void {
70 // render all the line comments at the beginning of the file70 // render all the line comments at the beginning of the file
...@@ -191,13 +191,13 @@ fn renderRoot(...@@ -191,13 +191,13 @@ fn renderRoot(
191 }191 }
192}192}
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 {
195 return renderExtraNewlineToken(tree, stream, start_col, node.firstToken());195 return renderExtraNewlineToken(tree, stream, start_col, node.firstToken());
196}196}
197197
198fn renderExtraNewlineToken(198fn renderExtraNewlineToken(
199 tree: *ast.Tree,199 tree: *ast.Tree,
200 stream: var,200 stream: anytype,
201 start_col: *usize,201 start_col: *usize,
202 first_token: ast.TokenIndex,202 first_token: ast.TokenIndex,
203) @TypeOf(stream).Error!void {203) @TypeOf(stream).Error!void {
...@@ -218,11 +218,11 @@ fn renderExtraNewlineToken(...@@ -218,11 +218,11 @@ fn renderExtraNewlineToken(
218 }218 }
219}219}
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 {
222 try renderContainerDecl(allocator, stream, tree, indent, start_col, decl, .Newline);222 try renderContainerDecl(allocator, stream, tree, indent, start_col, decl, .Newline);
223}223}
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 {
226 switch (decl.id) {226 switch (decl.id) {
227 .FnProto => {227 .FnProto => {
228 const fn_proto = @fieldParentPtr(ast.Node.FnProto, "base", decl);228 const fn_proto = @fieldParentPtr(ast.Node.FnProto, "base", decl);
...@@ -358,7 +358,7 @@ fn renderContainerDecl(allocator: *mem.Allocator, stream: var, tree: *ast.Tree,...@@ -358,7 +358,7 @@ fn renderContainerDecl(allocator: *mem.Allocator, stream: var, tree: *ast.Tree,
358358
359fn renderExpression(359fn renderExpression(
360 allocator: *mem.Allocator,360 allocator: *mem.Allocator,
361 stream: var,361 stream: anytype,
362 tree: *ast.Tree,362 tree: *ast.Tree,
363 indent: usize,363 indent: usize,
364 start_col: *usize,364 start_col: *usize,
...@@ -1179,9 +1179,15 @@ fn renderExpression(...@@ -1179,9 +1179,15 @@ fn renderExpression(
1179 const error_type = @fieldParentPtr(ast.Node.ErrorType, "base", base);1179 const error_type = @fieldParentPtr(ast.Node.ErrorType, "base", base);
1180 return renderToken(tree, stream, error_type.token, indent, start_col, space);1180 return renderToken(tree, stream, error_type.token, indent, start_col, space);
1181 },1181 },
1182 .VarType => {1182 .AnyType => {
1183 const var_type = @fieldParentPtr(ast.Node.VarType, "base", base);1183 const any_type = @fieldParentPtr(ast.Node.AnyType, "base", base);
1184 return renderToken(tree, stream, var_type.token, indent, start_col, space);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);
1185 },1191 },
1186 .ContainerDecl => {1192 .ContainerDecl => {
1187 const container_decl = @fieldParentPtr(ast.Node.ContainerDecl, "base", base);1193 const container_decl = @fieldParentPtr(ast.Node.ContainerDecl, "base", base);
...@@ -2053,7 +2059,7 @@ fn renderExpression(...@@ -2053,7 +2059,7 @@ fn renderExpression(
20532059
2054fn renderAsmOutput(2060fn renderAsmOutput(
2055 allocator: *mem.Allocator,2061 allocator: *mem.Allocator,
2056 stream: var,2062 stream: anytype,
2057 tree: *ast.Tree,2063 tree: *ast.Tree,
2058 indent: usize,2064 indent: usize,
2059 start_col: *usize,2065 start_col: *usize,
...@@ -2081,7 +2087,7 @@ fn renderAsmOutput(...@@ -2081,7 +2087,7 @@ fn renderAsmOutput(
20812087
2082fn renderAsmInput(2088fn renderAsmInput(
2083 allocator: *mem.Allocator,2089 allocator: *mem.Allocator,
2084 stream: var,2090 stream: anytype,
2085 tree: *ast.Tree,2091 tree: *ast.Tree,
2086 indent: usize,2092 indent: usize,
2087 start_col: *usize,2093 start_col: *usize,
...@@ -2099,7 +2105,7 @@ fn renderAsmInput(...@@ -2099,7 +2105,7 @@ fn renderAsmInput(
20992105
2100fn renderVarDecl(2106fn renderVarDecl(
2101 allocator: *mem.Allocator,2107 allocator: *mem.Allocator,
2102 stream: var,2108 stream: anytype,
2103 tree: *ast.Tree,2109 tree: *ast.Tree,
2104 indent: usize,2110 indent: usize,
2105 start_col: *usize,2111 start_col: *usize,
...@@ -2171,7 +2177,7 @@ fn renderVarDecl(...@@ -2171,7 +2177,7 @@ fn renderVarDecl(
21712177
2172fn renderParamDecl(2178fn renderParamDecl(
2173 allocator: *mem.Allocator,2179 allocator: *mem.Allocator,
2174 stream: var,2180 stream: anytype,
2175 tree: *ast.Tree,2181 tree: *ast.Tree,
2176 indent: usize,2182 indent: usize,
2177 start_col: *usize,2183 start_col: *usize,
...@@ -2192,13 +2198,13 @@ fn renderParamDecl(...@@ -2192,13 +2198,13 @@ fn renderParamDecl(
2192 }2198 }
2193 switch (param_decl.param_type) {2199 switch (param_decl.param_type) {
2194 .var_args => |token| try renderToken(tree, stream, token, indent, start_col, space),2200 .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),
2196 }2202 }
2197}2203}
21982204
2199fn renderStatement(2205fn renderStatement(
2200 allocator: *mem.Allocator,2206 allocator: *mem.Allocator,
2201 stream: var,2207 stream: anytype,
2202 tree: *ast.Tree,2208 tree: *ast.Tree,
2203 indent: usize,2209 indent: usize,
2204 start_col: *usize,2210 start_col: *usize,
...@@ -2236,7 +2242,7 @@ const Space = enum {...@@ -2236,7 +2242,7 @@ const Space = enum {
22362242
2237fn renderTokenOffset(2243fn renderTokenOffset(
2238 tree: *ast.Tree,2244 tree: *ast.Tree,
2239 stream: var,2245 stream: anytype,
2240 token_index: ast.TokenIndex,2246 token_index: ast.TokenIndex,
2241 indent: usize,2247 indent: usize,
2242 start_col: *usize,2248 start_col: *usize,
...@@ -2434,7 +2440,7 @@ fn renderTokenOffset(...@@ -2434,7 +2440,7 @@ fn renderTokenOffset(
24342440
2435fn renderToken(2441fn renderToken(
2436 tree: *ast.Tree,2442 tree: *ast.Tree,
2437 stream: var,2443 stream: anytype,
2438 token_index: ast.TokenIndex,2444 token_index: ast.TokenIndex,
2439 indent: usize,2445 indent: usize,
2440 start_col: *usize,2446 start_col: *usize,
...@@ -2445,8 +2451,8 @@ fn renderToken(...@@ -2445,8 +2451,8 @@ fn renderToken(
24452451
2446fn renderDocComments(2452fn renderDocComments(
2447 tree: *ast.Tree,2453 tree: *ast.Tree,
2448 stream: var,2454 stream: anytype,
2449 node: var,2455 node: anytype,
2450 indent: usize,2456 indent: usize,
2451 start_col: *usize,2457 start_col: *usize,
2452) (@TypeOf(stream).Error || Error)!void {2458) (@TypeOf(stream).Error || Error)!void {
...@@ -2456,7 +2462,7 @@ fn renderDocComments(...@@ -2456,7 +2462,7 @@ fn renderDocComments(
24562462
2457fn renderDocCommentsToken(2463fn renderDocCommentsToken(
2458 tree: *ast.Tree,2464 tree: *ast.Tree,
2459 stream: var,2465 stream: anytype,
2460 comment: *ast.Node.DocComment,2466 comment: *ast.Node.DocComment,
2461 first_token: ast.TokenIndex,2467 first_token: ast.TokenIndex,
2462 indent: usize,2468 indent: usize,
...@@ -2532,7 +2538,7 @@ const FindByteOutStream = struct {...@@ -2532,7 +2538,7 @@ const FindByteOutStream = struct {
2532 }2538 }
2533};2539};
25342540
2535fn copyFixingWhitespace(stream: var, slice: []const u8) @TypeOf(stream).Error!void {2541fn copyFixingWhitespace(stream: anytype, slice: []const u8) @TypeOf(stream).Error!void {
2536 for (slice) |byte| switch (byte) {2542 for (slice) |byte| switch (byte) {
2537 '\t' => try stream.writeAll(" "),2543 '\t' => try stream.writeAll(" "),
2538 '\r' => {},2544 '\r' => {},
lib/std/zig/string_literal.zig+1-1
...@@ -125,7 +125,7 @@ test "parse" {...@@ -125,7 +125,7 @@ test "parse" {
125}125}
126126
127/// Writes a Zig-syntax escaped string literal to the stream. Includes the double quotes.127/// 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 {
129 try out_stream.writeByte('"');129 try out_stream.writeByte('"');
130 for (utf8) |byte| switch (byte) {130 for (utf8) |byte| switch (byte) {
131 '\n' => try out_stream.writeAll("\\n"),131 '\n' => try out_stream.writeAll("\\n"),
lib/std/zig/system.zig+4-4
...@@ -130,7 +130,7 @@ pub const NativePaths = struct {...@@ -130,7 +130,7 @@ pub const NativePaths = struct {
130 return self.appendArray(&self.include_dirs, s);130 return self.appendArray(&self.include_dirs, s);
131 }131 }
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 {
134 const item = try std.fmt.allocPrint0(self.include_dirs.allocator, fmt, args);134 const item = try std.fmt.allocPrint0(self.include_dirs.allocator, fmt, args);
135 errdefer self.include_dirs.allocator.free(item);135 errdefer self.include_dirs.allocator.free(item);
136 try self.include_dirs.append(item);136 try self.include_dirs.append(item);
...@@ -140,7 +140,7 @@ pub const NativePaths = struct {...@@ -140,7 +140,7 @@ pub const NativePaths = struct {
140 return self.appendArray(&self.lib_dirs, s);140 return self.appendArray(&self.lib_dirs, s);
141 }141 }
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 {
144 const item = try std.fmt.allocPrint0(self.lib_dirs.allocator, fmt, args);144 const item = try std.fmt.allocPrint0(self.lib_dirs.allocator, fmt, args);
145 errdefer self.lib_dirs.allocator.free(item);145 errdefer self.lib_dirs.allocator.free(item);
146 try self.lib_dirs.append(item);146 try self.lib_dirs.append(item);
...@@ -150,7 +150,7 @@ pub const NativePaths = struct {...@@ -150,7 +150,7 @@ pub const NativePaths = struct {
150 return self.appendArray(&self.warnings, s);150 return self.appendArray(&self.warnings, s);
151 }151 }
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 {
154 const item = try std.fmt.allocPrint0(self.warnings.allocator, fmt, args);154 const item = try std.fmt.allocPrint0(self.warnings.allocator, fmt, args);
155 errdefer self.warnings.allocator.free(item);155 errdefer self.warnings.allocator.free(item);
156 try self.warnings.append(item);156 try self.warnings.append(item);
...@@ -887,7 +887,7 @@ pub const NativeTargetInfo = struct {...@@ -887,7 +887,7 @@ pub const NativeTargetInfo = struct {
887 abi: Target.Abi,887 abi: Target.Abi,
888 };888 };
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) {
891 if (is_64) {891 if (is_64) {
892 if (need_bswap) {892 if (need_bswap) {
893 return @byteSwap(@TypeOf(int_64), int_64);893 return @byteSwap(@TypeOf(int_64), int_64);
lib/std/zig/tokenizer.zig+4-1
...@@ -15,6 +15,7 @@ pub const Token = struct {...@@ -15,6 +15,7 @@ pub const Token = struct {
15 .{ "allowzero", .Keyword_allowzero },15 .{ "allowzero", .Keyword_allowzero },
16 .{ "and", .Keyword_and },16 .{ "and", .Keyword_and },
17 .{ "anyframe", .Keyword_anyframe },17 .{ "anyframe", .Keyword_anyframe },
18 .{ "anytype", .Keyword_anytype },
18 .{ "asm", .Keyword_asm },19 .{ "asm", .Keyword_asm },
19 .{ "async", .Keyword_async },20 .{ "async", .Keyword_async },
20 .{ "await", .Keyword_await },21 .{ "await", .Keyword_await },
...@@ -140,6 +141,8 @@ pub const Token = struct {...@@ -140,6 +141,8 @@ pub const Token = struct {
140 Keyword_align,141 Keyword_align,
141 Keyword_allowzero,142 Keyword_allowzero,
142 Keyword_and,143 Keyword_and,
144 Keyword_anyframe,
145 Keyword_anytype,
143 Keyword_asm,146 Keyword_asm,
144 Keyword_async,147 Keyword_async,
145 Keyword_await,148 Keyword_await,
...@@ -168,7 +171,6 @@ pub const Token = struct {...@@ -168,7 +171,6 @@ pub const Token = struct {
168 Keyword_or,171 Keyword_or,
169 Keyword_orelse,172 Keyword_orelse,
170 Keyword_packed,173 Keyword_packed,
171 Keyword_anyframe,
172 Keyword_pub,174 Keyword_pub,
173 Keyword_resume,175 Keyword_resume,
174 Keyword_return,176 Keyword_return,
...@@ -263,6 +265,7 @@ pub const Token = struct {...@@ -263,6 +265,7 @@ pub const Token = struct {
263 .Keyword_allowzero => "allowzero",265 .Keyword_allowzero => "allowzero",
264 .Keyword_and => "and",266 .Keyword_and => "and",
265 .Keyword_anyframe => "anyframe",267 .Keyword_anyframe => "anyframe",
268 .Keyword_anytype => "anytype",
266 .Keyword_asm => "asm",269 .Keyword_asm => "asm",
267 .Keyword_async => "async",270 .Keyword_async => "async",
268 .Keyword_await => "await",271 .Keyword_await => "await",
src-self-hosted/Module.zig+6-6
...@@ -1132,7 +1132,7 @@ fn astGenAndAnalyzeDecl(self: *Module, decl: *Decl) !bool {...@@ -1132,7 +1132,7 @@ fn astGenAndAnalyzeDecl(self: *Module, decl: *Decl) !bool {
1132 const param_types = try fn_type_scope.arena.alloc(*zir.Inst, param_decls.len);1132 const param_types = try fn_type_scope.arena.alloc(*zir.Inst, param_decls.len);
1133 for (param_decls) |param_decl, i| {1133 for (param_decls) |param_decl, i| {
1134 const param_type_node = switch (param_decl.param_type) {1134 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", .{}),
1136 .var_args => |tok| return self.failTok(&fn_type_scope.base, tok, "TODO implement var args", .{}),1136 .var_args => |tok| return self.failTok(&fn_type_scope.base, tok, "TODO implement var args", .{}),
1137 .type_expr => |node| node,1137 .type_expr => |node| node,
1138 };1138 };
...@@ -3575,7 +3575,7 @@ fn coerceArrayPtrToSlice(self: *Module, scope: *Scope, dest_type: Type, inst: *I...@@ -3575,7 +3575,7 @@ fn coerceArrayPtrToSlice(self: *Module, scope: *Scope, dest_type: Type, inst: *I
3575 return self.fail(scope, inst.src, "TODO implement coerceArrayPtrToSlice runtime instruction", .{});3575 return self.fail(scope, inst.src, "TODO implement coerceArrayPtrToSlice runtime instruction", .{});
3576}3576}
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 {
3579 @setCold(true);3579 @setCold(true);
3580 const err_msg = try ErrorMsg.create(self.gpa, src, format, args);3580 const err_msg = try ErrorMsg.create(self.gpa, src, format, args);
3581 return self.failWithOwnedErrorMsg(scope, src, err_msg);3581 return self.failWithOwnedErrorMsg(scope, src, err_msg);
...@@ -3586,7 +3586,7 @@ fn failTok(...@@ -3586,7 +3586,7 @@ fn failTok(
3586 scope: *Scope,3586 scope: *Scope,
3587 token_index: ast.TokenIndex,3587 token_index: ast.TokenIndex,
3588 comptime format: []const u8,3588 comptime format: []const u8,
3589 args: var,3589 args: anytype,
3590) InnerError {3590) InnerError {
3591 @setCold(true);3591 @setCold(true);
3592 const src = scope.tree().token_locs[token_index].start;3592 const src = scope.tree().token_locs[token_index].start;
...@@ -3598,7 +3598,7 @@ fn failNode(...@@ -3598,7 +3598,7 @@ fn failNode(
3598 scope: *Scope,3598 scope: *Scope,
3599 ast_node: *ast.Node,3599 ast_node: *ast.Node,
3600 comptime format: []const u8,3600 comptime format: []const u8,
3601 args: var,3601 args: anytype,
3602) InnerError {3602) InnerError {
3603 @setCold(true);3603 @setCold(true);
3604 const src = scope.tree().token_locs[ast_node.firstToken()].start;3604 const src = scope.tree().token_locs[ast_node.firstToken()].start;
...@@ -3662,7 +3662,7 @@ pub const ErrorMsg = struct {...@@ -3662,7 +3662,7 @@ pub const ErrorMsg = struct {
3662 byte_offset: usize,3662 byte_offset: usize,
3663 msg: []const u8,3663 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 {
3666 const self = try gpa.create(ErrorMsg);3666 const self = try gpa.create(ErrorMsg);
3667 errdefer gpa.destroy(self);3667 errdefer gpa.destroy(self);
3668 self.* = try init(gpa, byte_offset, format, args);3668 self.* = try init(gpa, byte_offset, format, args);
...@@ -3675,7 +3675,7 @@ pub const ErrorMsg = struct {...@@ -3675,7 +3675,7 @@ pub const ErrorMsg = struct {
3675 gpa.destroy(self);3675 gpa.destroy(self);
3676 }3676 }
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 {
3679 return ErrorMsg{3679 return ErrorMsg{
3680 .byte_offset = byte_offset,3680 .byte_offset = byte_offset,
3681 .msg = try std.fmt.allocPrint(gpa, format, args),3681 .msg = try std.fmt.allocPrint(gpa, format, args),
src-self-hosted/codegen.zig+11-10
...@@ -230,7 +230,7 @@ pub fn generateSymbol(...@@ -230,7 +230,7 @@ pub fn generateSymbol(
230 }230 }
231}231}
232232
233const InnerError = error {233const InnerError = error{
234 OutOfMemory,234 OutOfMemory,
235 CodegenFail,235 CodegenFail,
236};236};
...@@ -673,9 +673,9 @@ const Function = struct {...@@ -673,9 +673,9 @@ const Function = struct {
673 try self.genX8664BinMathCode(inst.base.src, dst_mcv, src_mcv, 7, 0x38);673 try self.genX8664BinMathCode(inst.base.src, dst_mcv, src_mcv, 7, 0x38);
674 const info = inst.args.lhs.ty.intInfo(self.target.*);674 const info = inst.args.lhs.ty.intInfo(self.target.*);
675 if (info.signed) {675 if (info.signed) {
676 return MCValue{.compare_flags_signed = inst.args.op};676 return MCValue{ .compare_flags_signed = inst.args.op };
677 } else {677 } else {
678 return MCValue{.compare_flags_unsigned = inst.args.op};678 return MCValue{ .compare_flags_unsigned = inst.args.op };
679 }679 }
680 },680 },
681 else => return self.fail(inst.base.src, "TODO implement cmp for {}", .{self.target.cpu.arch}),681 else => return self.fail(inst.base.src, "TODO implement cmp for {}", .{self.target.cpu.arch}),
...@@ -721,7 +721,7 @@ const Function = struct {...@@ -721,7 +721,7 @@ const Function = struct {
721 }721 }
722722
723 fn genX86CondBr(self: *Function, inst: *ir.Inst.CondBr, opcode: u8, comptime arch: std.Target.Cpu.Arch) !MCValue {723 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 });
725 const reloc = Reloc{ .rel32 = self.code.items.len };725 const reloc = Reloc{ .rel32 = self.code.items.len };
726 self.code.items.len += 4;726 self.code.items.len += 4;
727 try self.genBody(inst.args.true_body, arch);727 try self.genBody(inst.args.true_body, arch);
...@@ -1081,10 +1081,12 @@ const Function = struct {...@@ -1081,10 +1081,12 @@ const Function = struct {
1081 switch (mcv) {1081 switch (mcv) {
1082 .immediate => |imm| {1082 .immediate => |imm| {
1083 // This immediate is unsigned.1083 // This immediate is unsigned.
1084 const U = @Type(.{ .Int = .{1084 const U = @Type(.{
1085 .bits = ti.bits - @boolToInt(ti.is_signed),1085 .Int = .{
1086 .is_signed = false,1086 .bits = ti.bits - @boolToInt(ti.is_signed),
1087 }});1087 .is_signed = false,
1088 },
1089 });
1088 if (imm >= std.math.maxInt(U)) {1090 if (imm >= std.math.maxInt(U)) {
1089 return self.copyToNewRegister(inst);1091 return self.copyToNewRegister(inst);
1090 }1092 }
...@@ -1094,7 +1096,6 @@ const Function = struct {...@@ -1094,7 +1096,6 @@ const Function = struct {
1094 return mcv;1096 return mcv;
1095 }1097 }
10961098
1097
1098 fn genTypedValue(self: *Function, src: usize, typed_value: TypedValue) !MCValue {1099 fn genTypedValue(self: *Function, src: usize, typed_value: TypedValue) !MCValue {
1099 const ptr_bits = self.target.cpu.arch.ptrBitWidth();1100 const ptr_bits = self.target.cpu.arch.ptrBitWidth();
1100 const ptr_bytes: u64 = @divExact(ptr_bits, 8);1101 const ptr_bytes: u64 = @divExact(ptr_bits, 8);
...@@ -1121,7 +1122,7 @@ const Function = struct {...@@ -1121,7 +1122,7 @@ const Function = struct {
1121 }1122 }
1122 }1123 }
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 } {
1125 @setCold(true);1126 @setCold(true);
1126 assert(self.err_msg == null);1127 assert(self.err_msg == null);
1127 self.err_msg = try ErrorMsg.create(self.bin_file.allocator, src, format, args);1128 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 {...@@ -299,12 +299,12 @@ pub const Tokenizer = struct {
299 return null;299 return null;
300 }300 }
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 {
303 self.error_text = try std.fmt.allocPrintZ(&self.arena.allocator, fmt, args);303 self.error_text = try std.fmt.allocPrintZ(&self.arena.allocator, fmt, args);
304 return Error.InvalidInput;304 return Error.InvalidInput;
305 }305 }
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 {
308 var buffer = try std.ArrayListSentineled(u8, 0).initSize(&self.arena.allocator, 0);308 var buffer = try std.ArrayListSentineled(u8, 0).initSize(&self.arena.allocator, 0);
309 try buffer.outStream().print(fmt, args);309 try buffer.outStream().print(fmt, args);
310 try buffer.appendSlice(" '");310 try buffer.appendSlice(" '");
...@@ -316,7 +316,7 @@ pub const Tokenizer = struct {...@@ -316,7 +316,7 @@ pub const Tokenizer = struct {
316 return Error.InvalidInput;316 return Error.InvalidInput;
317 }317 }
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 {
320 var buffer = try std.ArrayListSentineled(u8, 0).initSize(&self.arena.allocator, 0);320 var buffer = try std.ArrayListSentineled(u8, 0).initSize(&self.arena.allocator, 0);
321 try buffer.appendSlice("illegal char ");321 try buffer.appendSlice("illegal char ");
322 try printUnderstandableChar(&buffer, char);322 try printUnderstandableChar(&buffer, char);
...@@ -883,7 +883,7 @@ fn depTokenizer(input: []const u8, expect: []const u8) !void {...@@ -883,7 +883,7 @@ fn depTokenizer(input: []const u8, expect: []const u8) !void {
883 testing.expect(false);883 testing.expect(false);
884}884}
885885
886fn printSection(out: var, label: []const u8, bytes: []const u8) !void {886fn printSection(out: anytype, label: []const u8, bytes: []const u8) !void {
887 try printLabel(out, label, bytes);887 try printLabel(out, label, bytes);
888 try hexDump(out, bytes);888 try hexDump(out, bytes);
889 try printRuler(out);889 try printRuler(out);
...@@ -891,7 +891,7 @@ fn printSection(out: var, label: []const u8, bytes: []const u8) !void {...@@ -891,7 +891,7 @@ fn printSection(out: var, label: []const u8, bytes: []const u8) !void {
891 try out.write("\n");891 try out.write("\n");
892}892}
893893
894fn printLabel(out: var, label: []const u8, bytes: []const u8) !void {894fn printLabel(out: anytype, label: []const u8, bytes: []const u8) !void {
895 var buf: [80]u8 = undefined;895 var buf: [80]u8 = undefined;
896 var text = try std.fmt.bufPrint(buf[0..], "{} {} bytes ", .{ label, bytes.len });896 var text = try std.fmt.bufPrint(buf[0..], "{} {} bytes ", .{ label, bytes.len });
897 try out.write(text);897 try out.write(text);
...@@ -903,7 +903,7 @@ fn printLabel(out: var, label: []const u8, bytes: []const u8) !void {...@@ -903,7 +903,7 @@ fn printLabel(out: var, label: []const u8, bytes: []const u8) !void {
903 try out.write("\n");903 try out.write("\n");
904}904}
905905
906fn printRuler(out: var) !void {906fn printRuler(out: anytype) !void {
907 var i: usize = 0;907 var i: usize = 0;
908 const end = 79;908 const end = 79;
909 while (i < 79) : (i += 1) {909 while (i < 79) : (i += 1) {
...@@ -912,7 +912,7 @@ fn printRuler(out: var) !void {...@@ -912,7 +912,7 @@ fn printRuler(out: var) !void {
912 try out.write("\n");912 try out.write("\n");
913}913}
914914
915fn hexDump(out: var, bytes: []const u8) !void {915fn hexDump(out: anytype, bytes: []const u8) !void {
916 const n16 = bytes.len >> 4;916 const n16 = bytes.len >> 4;
917 var line: usize = 0;917 var line: usize = 0;
918 var offset: usize = 0;918 var offset: usize = 0;
...@@ -959,7 +959,7 @@ fn hexDump(out: var, bytes: []const u8) !void {...@@ -959,7 +959,7 @@ fn hexDump(out: var, bytes: []const u8) !void {
959 try out.write("\n");959 try out.write("\n");
960}960}
961961
962fn hexDump16(out: var, offset: usize, bytes: []const u8) !void {962fn hexDump16(out: anytype, offset: usize, bytes: []const u8) !void {
963 try printDecValue(out, offset, 8);963 try printDecValue(out, offset, 8);
964 try out.write(":");964 try out.write(":");
965 try out.write(" ");965 try out.write(" ");
...@@ -977,19 +977,19 @@ fn hexDump16(out: var, offset: usize, bytes: []const u8) !void {...@@ -977,19 +977,19 @@ fn hexDump16(out: var, offset: usize, bytes: []const u8) !void {
977 try out.write("|\n");977 try out.write("|\n");
978}978}
979979
980fn printDecValue(out: var, value: u64, width: u8) !void {980fn printDecValue(out: anytype, value: u64, width: u8) !void {
981 var buffer: [20]u8 = undefined;981 var buffer: [20]u8 = undefined;
982 const len = std.fmt.formatIntBuf(buffer[0..], value, 10, false, width);982 const len = std.fmt.formatIntBuf(buffer[0..], value, 10, false, width);
983 try out.write(buffer[0..len]);983 try out.write(buffer[0..len]);
984}984}
985985
986fn printHexValue(out: var, value: u64, width: u8) !void {986fn printHexValue(out: anytype, value: u64, width: u8) !void {
987 var buffer: [16]u8 = undefined;987 var buffer: [16]u8 = undefined;
988 const len = std.fmt.formatIntBuf(buffer[0..], value, 16, false, width);988 const len = std.fmt.formatIntBuf(buffer[0..], value, 16, false, width);
989 try out.write(buffer[0..len]);989 try out.write(buffer[0..len]);
990}990}
991991
992fn printCharValues(out: var, bytes: []const u8) !void {992fn printCharValues(out: anytype, bytes: []const u8) !void {
993 for (bytes) |b| {993 for (bytes) |b| {
994 try out.write(&[_]u8{printable_char_tab[b]});994 try out.write(&[_]u8{printable_char_tab[b]});
995 }995 }
...@@ -1020,13 +1020,13 @@ comptime {...@@ -1020,13 +1020,13 @@ comptime {
1020// output: must be a function that takes a `self` idiom parameter1020// output: must be a function that takes a `self` idiom parameter
1021// and a bytes parameter1021// and a bytes parameter
1022// context: must be that self1022// 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)) {
1024 return Output(output, @TypeOf(context)){1024 return Output(output, @TypeOf(context)){
1025 .context = context,1025 .context = context,
1026 };1026 };
1027}1027}
10281028
1029fn Output(comptime output_func: var, comptime Context: type) type {1029fn Output(comptime output_func: anytype, comptime Context: type) type {
1030 return struct {1030 return struct {
1031 context: Context,1031 context: Context,
10321032
src-self-hosted/ir.zig+1-1
...@@ -13,7 +13,7 @@ const codegen = @import("codegen.zig");...@@ -13,7 +13,7 @@ const codegen = @import("codegen.zig");
13pub const Inst = struct {13pub const Inst = struct {
14 tag: Tag,14 tag: Tag,
15 /// Each bit represents the index of an `Inst` parameter in the `args` field.15 /// 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
17 /// instruction parameter. For example, 0b000_00101 means that the first and17 /// instruction parameter. For example, 0b000_00101 means that the first and
18 /// third `Inst` parameters' lifetimes end after this instruction, and will18 /// third `Inst` parameters' lifetimes end after this instruction, and will
19 /// not have any more following references.19 /// not have any more following references.
src-self-hosted/libc_installation.zig+2-2
...@@ -37,7 +37,7 @@ pub const LibCInstallation = struct {...@@ -37,7 +37,7 @@ pub const LibCInstallation = struct {
37 pub fn parse(37 pub fn parse(
38 allocator: *Allocator,38 allocator: *Allocator,
39 libc_file: []const u8,39 libc_file: []const u8,
40 stderr: var,40 stderr: anytype,
41 ) !LibCInstallation {41 ) !LibCInstallation {
42 var self: LibCInstallation = .{};42 var self: LibCInstallation = .{};
4343
...@@ -115,7 +115,7 @@ pub const LibCInstallation = struct {...@@ -115,7 +115,7 @@ pub const LibCInstallation = struct {
115 return self;115 return self;
116 }116 }
117117
118 pub fn render(self: LibCInstallation, out: var) !void {118 pub fn render(self: LibCInstallation, out: anytype) !void {
119 @setEvalBranchQuota(4000);119 @setEvalBranchQuota(4000);
120 const include_dir = self.include_dir orelse "";120 const include_dir = self.include_dir orelse "";
121 const sys_include_dir = self.sys_include_dir orelse "";121 const sys_include_dir = self.sys_include_dir orelse "";
src-self-hosted/link.zig+4-4
...@@ -244,7 +244,7 @@ pub const File = struct {...@@ -244,7 +244,7 @@ pub const File = struct {
244 need_noreturn: bool = false,244 need_noreturn: bool = false,
245 error_msg: *Module.ErrorMsg = undefined,245 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 {
248 self.error_msg = try Module.ErrorMsg.create(self.allocator, src, format, args);248 self.error_msg = try Module.ErrorMsg.create(self.allocator, src, format, args);
249 return error.CGenFailure;249 return error.CGenFailure;
250 }250 }
...@@ -1167,10 +1167,10 @@ pub const File = struct {...@@ -1167,10 +1167,10 @@ pub const File = struct {
1167 try self.offset_table_free_list.ensureCapacity(self.allocator, self.local_symbols.items.len);1167 try self.offset_table_free_list.ensureCapacity(self.allocator, self.local_symbols.items.len);
11681168
1169 if (self.local_symbol_free_list.popOrNull()) |i| {1169 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 });
1171 decl.link.local_sym_index = i;1171 decl.link.local_sym_index = i;
1172 } else {1172 } 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 });
1174 decl.link.local_sym_index = @intCast(u32, self.local_symbols.items.len);1174 decl.link.local_sym_index = @intCast(u32, self.local_symbols.items.len);
1175 _ = self.local_symbols.addOneAssumeCapacity();1175 _ = self.local_symbols.addOneAssumeCapacity();
1176 }1176 }
...@@ -1657,7 +1657,7 @@ fn openBinFileInner(allocator: *Allocator, file: fs.File, options: Options) !Fil...@@ -1657,7 +1657,7 @@ fn openBinFileInner(allocator: *Allocator, file: fs.File, options: Options) !Fil
1657}1657}
16581658
1659/// Saturating multiplication1659/// Saturating multiplication
1660fn satMul(a: var, b: var) @TypeOf(a, b) {1660fn satMul(a: anytype, b: anytype) @TypeOf(a, b) {
1661 const T = @TypeOf(a, b);1661 const T = @TypeOf(a, b);
1662 return std.math.mul(T, a, b) catch std.math.maxInt(T);1662 return std.math.mul(T, a, b) catch std.math.maxInt(T);
1663}1663}
src-self-hosted/liveness.zig+1-1
...@@ -135,5 +135,5 @@ fn analyzeInst(arena: *std.mem.Allocator, table: *std.AutoHashMap(*ir.Inst, void...@@ -135,5 +135,5 @@ fn analyzeInst(arena: *std.mem.Allocator, table: *std.AutoHashMap(*ir.Inst, void
135 }135 }
136 }136 }
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 });
139}139}
src-self-hosted/main.zig+1-1
...@@ -42,7 +42,7 @@ pub fn log(...@@ -42,7 +42,7 @@ pub fn log(
42 comptime level: std.log.Level,42 comptime level: std.log.Level,
43 comptime scope: @TypeOf(.EnumLiteral),43 comptime scope: @TypeOf(.EnumLiteral),
44 comptime format: []const u8,44 comptime format: []const u8,
45 args: var,45 args: anytype,
46) void {46) void {
47 if (@enumToInt(level) > @enumToInt(std.log.level))47 if (@enumToInt(level) > @enumToInt(std.log.level))
48 return;48 return;
src-self-hosted/print_targets.zig+1-1
...@@ -62,7 +62,7 @@ pub fn cmdTargets(...@@ -62,7 +62,7 @@ pub fn cmdTargets(
62 allocator: *Allocator,62 allocator: *Allocator,
63 args: []const []const u8,63 args: []const []const u8,
64 /// Output stream64 /// Output stream
65 stdout: var,65 stdout: anytype,
66 native_target: Target,66 native_target: Target,
67) !void {67) !void {
68 const available_glibcs = blk: {68 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...@@ -1117,7 +1117,7 @@ fn transEnumDecl(c: *Context, enum_decl: *const ZigClangEnumDecl) Error!?*ast.No
1117 return transCreateNodeIdentifier(c, name);1117 return transCreateNodeIdentifier(c, name);
1118}1118}
11191119
1120fn createAlias(c: *Context, alias: var) !void {1120fn createAlias(c: *Context, alias: anytype) !void {
1121 const node = try transCreateNodeVarDecl(c, true, true, alias.alias);1121 const node = try transCreateNodeVarDecl(c, true, true, alias.alias);
1122 node.eq_token = try appendToken(c, .Equal, "=");1122 node.eq_token = try appendToken(c, .Equal, "=");
1123 node.init_node = try transCreateNodeIdentifier(c, alias.name);1123 node.init_node = try transCreateNodeIdentifier(c, alias.name);
...@@ -2161,7 +2161,7 @@ fn transCreateNodeArrayType(...@@ -2161,7 +2161,7 @@ fn transCreateNodeArrayType(
2161 rp: RestorePoint,2161 rp: RestorePoint,
2162 source_loc: ZigClangSourceLocation,2162 source_loc: ZigClangSourceLocation,
2163 ty: *const ZigClangType,2163 ty: *const ZigClangType,
2164 len: var,2164 len: anytype,
2165) TransError!*ast.Node {2165) TransError!*ast.Node {
2166 var node = try transCreateNodePrefixOp(2166 var node = try transCreateNodePrefixOp(
2167 rp.c,2167 rp.c,
...@@ -4187,7 +4187,7 @@ fn transCreateNodeBoolLiteral(c: *Context, value: bool) !*ast.Node {...@@ -4187,7 +4187,7 @@ fn transCreateNodeBoolLiteral(c: *Context, value: bool) !*ast.Node {
4187 return &node.base;4187 return &node.base;
4188}4188}
41894189
4190fn transCreateNodeInt(c: *Context, int: var) !*ast.Node {4190fn transCreateNodeInt(c: *Context, int: anytype) !*ast.Node {
4191 const token = try appendTokenFmt(c, .IntegerLiteral, "{}", .{int});4191 const token = try appendTokenFmt(c, .IntegerLiteral, "{}", .{int});
4192 const node = try c.arena.create(ast.Node.IntegerLiteral);4192 const node = try c.arena.create(ast.Node.IntegerLiteral);
4193 node.* = .{4193 node.* = .{
...@@ -4196,7 +4196,7 @@ fn transCreateNodeInt(c: *Context, int: var) !*ast.Node {...@@ -4196,7 +4196,7 @@ fn transCreateNodeInt(c: *Context, int: var) !*ast.Node {
4196 return &node.base;4196 return &node.base;
4197}4197}
41984198
4199fn transCreateNodeFloat(c: *Context, int: var) !*ast.Node {4199fn transCreateNodeFloat(c: *Context, int: anytype) !*ast.Node {
4200 const token = try appendTokenFmt(c, .FloatLiteral, "{}", .{int});4200 const token = try appendTokenFmt(c, .FloatLiteral, "{}", .{int});
4201 const node = try c.arena.create(ast.Node.FloatLiteral);4201 const node = try c.arena.create(ast.Node.FloatLiteral);
4202 node.* = .{4202 node.* = .{
...@@ -4907,22 +4907,22 @@ fn finishTransFnProto(...@@ -4907,22 +4907,22 @@ fn finishTransFnProto(
49074907
4908fn revertAndWarn(4908fn revertAndWarn(
4909 rp: RestorePoint,4909 rp: RestorePoint,
4910 err: var,4910 err: anytype,
4911 source_loc: ZigClangSourceLocation,4911 source_loc: ZigClangSourceLocation,
4912 comptime format: []const u8,4912 comptime format: []const u8,
4913 args: var,4913 args: anytype,
4914) (@TypeOf(err) || error{OutOfMemory}) {4914) (@TypeOf(err) || error{OutOfMemory}) {
4915 rp.activate();4915 rp.activate();
4916 try emitWarning(rp.c, source_loc, format, args);4916 try emitWarning(rp.c, source_loc, format, args);
4917 return err;4917 return err;
4918}4918}
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 {
4921 const args_prefix = .{c.locStr(loc)};4921 const args_prefix = .{c.locStr(loc)};
4922 _ = try appendTokenFmt(c, .LineComment, "// {}: warning: " ++ format, args_prefix ++ args);4922 _ = try appendTokenFmt(c, .LineComment, "// {}: warning: " ++ format, args_prefix ++ args);
4923}4923}
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 {
4926 // pub const name = @compileError(msg);4926 // pub const name = @compileError(msg);
4927 const pub_tok = try appendToken(c, .Keyword_pub, "pub");4927 const pub_tok = try appendToken(c, .Keyword_pub, "pub");
4928 const const_tok = try appendToken(c, .Keyword_const, "const");4928 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...@@ -4973,7 +4973,7 @@ fn appendToken(c: *Context, token_id: Token.Id, bytes: []const u8) !ast.TokenInd
4973 return appendTokenFmt(c, token_id, "{}", .{bytes});4973 return appendTokenFmt(c, token_id, "{}", .{bytes});
4974}4974}
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 {
4977 assert(token_id != .Invalid);4977 assert(token_id != .Invalid);
49784978
4979 try c.token_ids.ensureCapacity(c.gpa, c.token_ids.items.len + 1);4979 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,...@@ -5215,10 +5215,9 @@ fn transMacroFnDefine(c: *Context, it: *CTokenList.Iterator, source: []const u8,
5215 const param_name_tok = try appendIdentifier(c, mangled_name);5215 const param_name_tok = try appendIdentifier(c, mangled_name);
5216 _ = try appendToken(c, .Colon, ":");5216 _ = try appendToken(c, .Colon, ":");
52175217
5218 const token_index = try appendToken(c, .Keyword_var, "var");5218 const any_type = try c.arena.create(ast.Node.AnyType);
5219 const identifier = try c.arena.create(ast.Node.Identifier);5219 any_type.* = .{
5220 identifier.* = .{5220 .token = try appendToken(c, .Keyword_anytype, "anytype"),
5221 .token = token_index,
5222 };5221 };
52235222
5224 (try fn_params.addOne()).* = .{5223 (try fn_params.addOne()).* = .{
...@@ -5226,7 +5225,7 @@ fn transMacroFnDefine(c: *Context, it: *CTokenList.Iterator, source: []const u8,...@@ -5226,7 +5225,7 @@ fn transMacroFnDefine(c: *Context, it: *CTokenList.Iterator, source: []const u8,
5226 .comptime_token = null,5225 .comptime_token = null,
5227 .noalias_token = null,5226 .noalias_token = null,
5228 .name_token = param_name_tok,5227 .name_token = param_name_tok,
5229 .param_type = .{ .type_expr = &identifier.base },5228 .param_type = .{ .any_type = &any_type.base },
5230 };5229 };
52315230
5232 if (it.peek().?.id != .Comma)5231 if (it.peek().?.id != .Comma)
src-self-hosted/type.zig+1-2
...@@ -277,7 +277,7 @@ pub const Type = extern union {...@@ -277,7 +277,7 @@ pub const Type = extern union {
277 self: Type,277 self: Type,
278 comptime fmt: []const u8,278 comptime fmt: []const u8,
279 options: std.fmt.FormatOptions,279 options: std.fmt.FormatOptions,
280 out_stream: var,280 out_stream: anytype,
281 ) @TypeOf(out_stream).Error!void {281 ) @TypeOf(out_stream).Error!void {
282 comptime assert(fmt.len == 0);282 comptime assert(fmt.len == 0);
283 var ty = self;283 var ty = self;
...@@ -591,7 +591,6 @@ pub const Type = extern union {...@@ -591,7 +591,6 @@ pub const Type = extern union {
591591
592 .anyerror => return 2, // TODO revisit this when we have the concept of the error tag type592 .anyerror => return 2, // TODO revisit this when we have the concept of the error tag type
593593
594
595 .int_signed, .int_unsigned => {594 .int_signed, .int_unsigned => {
596 const bits: u16 = if (self.cast(Payload.IntSigned)) |pl|595 const bits: u16 = if (self.cast(Payload.IntSigned)) |pl|
597 pl.bits596 pl.bits
src-self-hosted/value.zig+1-1
...@@ -227,7 +227,7 @@ pub const Value = extern union {...@@ -227,7 +227,7 @@ pub const Value = extern union {
227 self: Value,227 self: Value,
228 comptime fmt: []const u8,228 comptime fmt: []const u8,
229 options: std.fmt.FormatOptions,229 options: std.fmt.FormatOptions,
230 out_stream: var,230 out_stream: anytype,
231 ) !void {231 ) !void {
232 comptime assert(fmt.len == 0);232 comptime assert(fmt.len == 0);
233 var val = self;233 var val = self;
src-self-hosted/zir.zig+6-7
...@@ -655,7 +655,7 @@ pub const Module = struct {...@@ -655,7 +655,7 @@ pub const Module = struct {
655655
656 /// The allocator is used for temporary storage, but this function always returns656 /// The allocator is used for temporary storage, but this function always returns
657 /// with no resources allocated.657 /// 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 {
659 var write = Writer{659 var write = Writer{
660 .module = &self,660 .module = &self,
661 .inst_table = InstPtrTable.init(allocator),661 .inst_table = InstPtrTable.init(allocator),
...@@ -686,7 +686,6 @@ pub const Module = struct {...@@ -686,7 +686,6 @@ pub const Module = struct {
686 try stream.writeByte('\n');686 try stream.writeByte('\n');
687 }687 }
688 }688 }
689
690};689};
691690
692const InstPtrTable = std.AutoHashMap(*Inst, struct { inst: *Inst, index: ?usize, name: []const u8 });691const InstPtrTable = std.AutoHashMap(*Inst, struct { inst: *Inst, index: ?usize, name: []const u8 });
...@@ -700,7 +699,7 @@ const Writer = struct {...@@ -700,7 +699,7 @@ const Writer = struct {
700699
701 fn writeInstToStream(700 fn writeInstToStream(
702 self: *Writer,701 self: *Writer,
703 stream: var,702 stream: anytype,
704 inst: *Inst,703 inst: *Inst,
705 ) (@TypeOf(stream).Error || error{OutOfMemory})!void {704 ) (@TypeOf(stream).Error || error{OutOfMemory})!void {
706 // TODO I tried implementing this with an inline for loop and hit a compiler bug705 // TODO I tried implementing this with an inline for loop and hit a compiler bug
...@@ -746,7 +745,7 @@ const Writer = struct {...@@ -746,7 +745,7 @@ const Writer = struct {
746745
747 fn writeInstToStreamGeneric(746 fn writeInstToStreamGeneric(
748 self: *Writer,747 self: *Writer,
749 stream: var,748 stream: anytype,
750 comptime inst_tag: Inst.Tag,749 comptime inst_tag: Inst.Tag,
751 base: *Inst,750 base: *Inst,
752 ) (@TypeOf(stream).Error || error{OutOfMemory})!void {751 ) (@TypeOf(stream).Error || error{OutOfMemory})!void {
...@@ -783,7 +782,7 @@ const Writer = struct {...@@ -783,7 +782,7 @@ const Writer = struct {
783 try stream.writeByte(')');782 try stream.writeByte(')');
784 }783 }
785784
786 fn writeParamToStream(self: *Writer, stream: var, param: var) !void {785 fn writeParamToStream(self: *Writer, stream: anytype, param: anytype) !void {
787 if (@typeInfo(@TypeOf(param)) == .Enum) {786 if (@typeInfo(@TypeOf(param)) == .Enum) {
788 return stream.writeAll(@tagName(param));787 return stream.writeAll(@tagName(param));
789 }788 }
...@@ -829,7 +828,7 @@ const Writer = struct {...@@ -829,7 +828,7 @@ const Writer = struct {
829 }828 }
830 }829 }
831830
832 fn writeInstParamToStream(self: *Writer, stream: var, inst: *Inst) !void {831 fn writeInstParamToStream(self: *Writer, stream: anytype, inst: *Inst) !void {
833 if (self.inst_table.get(inst)) |info| {832 if (self.inst_table.get(inst)) |info| {
834 if (info.index) |i| {833 if (info.index) |i| {
835 try stream.print("%{}", .{info.index});834 try stream.print("%{}", .{info.index});
...@@ -1062,7 +1061,7 @@ const Parser = struct {...@@ -1062,7 +1061,7 @@ const Parser = struct {
1062 }1061 }
1063 }1062 }
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 {
1066 @setCold(true);1065 @setCold(true);
1067 self.error_msg = ErrorMsg{1066 self.error_msg = ErrorMsg{
1068 .byte_offset = self.i,1067 .byte_offset = self.i,
src/all_types.hpp+4-4
...@@ -692,7 +692,7 @@ enum NodeType {...@@ -692,7 +692,7 @@ enum NodeType {
692 NodeTypeSuspend,692 NodeTypeSuspend,
693 NodeTypeAnyFrameType,693 NodeTypeAnyFrameType,
694 NodeTypeEnumLiteral,694 NodeTypeEnumLiteral,
695 NodeTypeVarFieldType,695 NodeTypeAnyTypeField,
696};696};
697697
698enum FnInline {698enum FnInline {
...@@ -705,7 +705,7 @@ struct AstNodeFnProto {...@@ -705,7 +705,7 @@ struct AstNodeFnProto {
705 Buf *name;705 Buf *name;
706 ZigList<AstNode *> params;706 ZigList<AstNode *> params;
707 AstNode *return_type;707 AstNode *return_type;
708 Token *return_var_token;708 Token *return_anytype_token;
709 AstNode *fn_def_node;709 AstNode *fn_def_node;
710 // populated if this is an extern declaration710 // populated if this is an extern declaration
711 Buf *lib_name;711 Buf *lib_name;
...@@ -734,7 +734,7 @@ struct AstNodeFnDef {...@@ -734,7 +734,7 @@ struct AstNodeFnDef {
734struct AstNodeParamDecl {734struct AstNodeParamDecl {
735 Buf *name;735 Buf *name;
736 AstNode *type;736 AstNode *type;
737 Token *var_token;737 Token *anytype_token;
738 Buf doc_comments;738 Buf doc_comments;
739 bool is_noalias;739 bool is_noalias;
740 bool is_comptime;740 bool is_comptime;
...@@ -2145,7 +2145,7 @@ struct CodeGen {...@@ -2145,7 +2145,7 @@ struct CodeGen {
2145 ZigType *entry_num_lit_float;2145 ZigType *entry_num_lit_float;
2146 ZigType *entry_undef;2146 ZigType *entry_undef;
2147 ZigType *entry_null;2147 ZigType *entry_null;
2148 ZigType *entry_var;2148 ZigType *entry_anytype;
2149 ZigType *entry_global_error_set;2149 ZigType *entry_global_error_set;
2150 ZigType *entry_enum_literal;2150 ZigType *entry_enum_literal;
2151 ZigType *entry_any_frame;2151 ZigType *entry_any_frame;
src/analyze.cpp+10-10
...@@ -1129,7 +1129,7 @@ ZigValue *analyze_const_value(CodeGen *g, Scope *scope, AstNode *node, ZigType *...@@ -1129,7 +1129,7 @@ ZigValue *analyze_const_value(CodeGen *g, Scope *scope, AstNode *node, ZigType *
1129 ZigValue *result = g->pass1_arena->create<ZigValue>();1129 ZigValue *result = g->pass1_arena->create<ZigValue>();
1130 ZigValue *result_ptr = g->pass1_arena->create<ZigValue>();1130 ZigValue *result_ptr = g->pass1_arena->create<ZigValue>();
1131 result->special = ConstValSpecialUndef;1131 result->special = ConstValSpecialUndef;
1132 result->type = (type_entry == nullptr) ? g->builtin_types.entry_var : type_entry;1132 result->type = (type_entry == nullptr) ? g->builtin_types.entry_anytype : type_entry;
1133 result_ptr->special = ConstValSpecialStatic;1133 result_ptr->special = ConstValSpecialStatic;
1134 result_ptr->type = get_pointer_to_type(g, result->type, false);1134 result_ptr->type = get_pointer_to_type(g, result->type, false);
1135 result_ptr->data.x_ptr.mut = ConstPtrMutComptimeVar;1135 result_ptr->data.x_ptr.mut = ConstPtrMutComptimeVar;
...@@ -1230,7 +1230,7 @@ Error type_val_resolve_zero_bits(CodeGen *g, ZigValue *type_val, ZigType *parent...@@ -1230,7 +1230,7 @@ Error type_val_resolve_zero_bits(CodeGen *g, ZigValue *type_val, ZigType *parent
1230Error type_val_resolve_is_opaque_type(CodeGen *g, ZigValue *type_val, bool *is_opaque_type) {1230Error type_val_resolve_is_opaque_type(CodeGen *g, ZigValue *type_val, bool *is_opaque_type) {
1231 if (type_val->special != ConstValSpecialLazy) {1231 if (type_val->special != ConstValSpecialLazy) {
1232 assert(type_val->special == ConstValSpecialStatic);1232 assert(type_val->special == ConstValSpecialStatic);
1233 if (type_val->data.x_type == g->builtin_types.entry_var) {1233 if (type_val->data.x_type == g->builtin_types.entry_anytype) {
1234 *is_opaque_type = false;1234 *is_opaque_type = false;
1235 return ErrorNone;1235 return ErrorNone;
1236 }1236 }
...@@ -1511,13 +1511,13 @@ ZigType *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id) {...@@ -1511,13 +1511,13 @@ ZigType *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
1511 }1511 }
1512 for (; i < fn_type_id->param_count; i += 1) {1512 for (; i < fn_type_id->param_count; i += 1) {
1513 const char *comma_str = (i == 0) ? "" : ",";1513 const char *comma_str = (i == 0) ? "" : ",";
1514 buf_appendf(&fn_type->name, "%svar", comma_str);1514 buf_appendf(&fn_type->name, "%sanytype", comma_str);
1515 }1515 }
1516 buf_append_str(&fn_type->name, ")");1516 buf_append_str(&fn_type->name, ")");
1517 if (fn_type_id->cc != CallingConventionUnspecified) {1517 if (fn_type_id->cc != CallingConventionUnspecified) {
1518 buf_appendf(&fn_type->name, " callconv(.%s)", calling_convention_name(fn_type_id->cc));1518 buf_appendf(&fn_type->name, " callconv(.%s)", calling_convention_name(fn_type_id->cc));
1519 }1519 }
1520 buf_append_str(&fn_type->name, " var");1520 buf_append_str(&fn_type->name, " anytype");
15211521
1522 fn_type->data.fn.fn_type_id = *fn_type_id;1522 fn_type->data.fn.fn_type_id = *fn_type_id;
1523 fn_type->data.fn.is_generic = true;1523 fn_type->data.fn.is_generic = true;
...@@ -1853,10 +1853,10 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc...@@ -1853,10 +1853,10 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc
1853 buf_sprintf("var args only allowed in functions with C calling convention"));1853 buf_sprintf("var args only allowed in functions with C calling convention"));
1854 return g->builtin_types.entry_invalid;1854 return g->builtin_types.entry_invalid;
1855 }1855 }
1856 } else if (param_node->data.param_decl.var_token != nullptr) {1856 } else if (param_node->data.param_decl.anytype_token != nullptr) {
1857 if (!calling_convention_allows_zig_types(fn_type_id.cc)) {1857 if (!calling_convention_allows_zig_types(fn_type_id.cc)) {
1858 add_node_error(g, param_node,1858 add_node_error(g, param_node,
1859 buf_sprintf("parameter of type 'var' not allowed in function with calling convention '%s'",1859 buf_sprintf("parameter of type 'anytype' not allowed in function with calling convention '%s'",
1860 calling_convention_name(fn_type_id.cc)));1860 calling_convention_name(fn_type_id.cc)));
1861 return g->builtin_types.entry_invalid;1861 return g->builtin_types.entry_invalid;
1862 }1862 }
...@@ -1942,10 +1942,10 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc...@@ -1942,10 +1942,10 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc
1942 fn_entry->align_bytes = fn_type_id.alignment;1942 fn_entry->align_bytes = fn_type_id.alignment;
1943 }1943 }
19441944
1945 if (fn_proto->return_var_token != nullptr) {1945 if (fn_proto->return_anytype_token != nullptr) {
1946 if (!calling_convention_allows_zig_types(fn_type_id.cc)) {1946 if (!calling_convention_allows_zig_types(fn_type_id.cc)) {
1947 add_node_error(g, fn_proto->return_type,1947 add_node_error(g, fn_proto->return_type,
1948 buf_sprintf("return type 'var' not allowed in function with calling convention '%s'",1948 buf_sprintf("return type 'anytype' not allowed in function with calling convention '%s'",
1949 calling_convention_name(fn_type_id.cc)));1949 calling_convention_name(fn_type_id.cc)));
1950 return g->builtin_types.entry_invalid;1950 return g->builtin_types.entry_invalid;
1951 }1951 }
...@@ -3802,7 +3802,7 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) {...@@ -3802,7 +3802,7 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) {
3802 case NodeTypeEnumLiteral:3802 case NodeTypeEnumLiteral:
3803 case NodeTypeAnyFrameType:3803 case NodeTypeAnyFrameType:
3804 case NodeTypeErrorSetField:3804 case NodeTypeErrorSetField:
3805 case NodeTypeVarFieldType:3805 case NodeTypeAnyTypeField:
3806 zig_unreachable();3806 zig_unreachable();
3807 }3807 }
3808}3808}
...@@ -5868,7 +5868,7 @@ ZigValue *get_the_one_possible_value(CodeGen *g, ZigType *type_entry) {...@@ -5868,7 +5868,7 @@ ZigValue *get_the_one_possible_value(CodeGen *g, ZigType *type_entry) {
58685868
5869ReqCompTime type_requires_comptime(CodeGen *g, ZigType *ty) {5869ReqCompTime type_requires_comptime(CodeGen *g, ZigType *ty) {
5870 Error err;5870 Error err;
5871 if (ty == g->builtin_types.entry_var) {5871 if (ty == g->builtin_types.entry_anytype) {
5872 return ReqCompTimeYes;5872 return ReqCompTimeYes;
5873 }5873 }
5874 switch (ty->id) {5874 switch (ty->id) {
src/ast_render.cpp+8-8
...@@ -270,8 +270,8 @@ static const char *node_type_str(NodeType node_type) {...@@ -270,8 +270,8 @@ static const char *node_type_str(NodeType node_type) {
270 return "EnumLiteral";270 return "EnumLiteral";
271 case NodeTypeErrorSetField:271 case NodeTypeErrorSetField:
272 return "ErrorSetField";272 return "ErrorSetField";
273 case NodeTypeVarFieldType:273 case NodeTypeAnyTypeField:
274 return "VarFieldType";274 return "AnyTypeField";
275 }275 }
276 zig_unreachable();276 zig_unreachable();
277}277}
...@@ -466,8 +466,8 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {...@@ -466,8 +466,8 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {
466 }466 }
467 if (param_decl->data.param_decl.is_var_args) {467 if (param_decl->data.param_decl.is_var_args) {
468 fprintf(ar->f, "...");468 fprintf(ar->f, "...");
469 } else if (param_decl->data.param_decl.var_token != nullptr) {469 } else if (param_decl->data.param_decl.anytype_token != nullptr) {
470 fprintf(ar->f, "var");470 fprintf(ar->f, "anytype");
471 } else {471 } else {
472 render_node_grouped(ar, param_decl->data.param_decl.type);472 render_node_grouped(ar, param_decl->data.param_decl.type);
473 }473 }
...@@ -496,8 +496,8 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {...@@ -496,8 +496,8 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {
496 fprintf(ar->f, ")");496 fprintf(ar->f, ")");
497 }497 }
498498
499 if (node->data.fn_proto.return_var_token != nullptr) {499 if (node->data.fn_proto.return_anytype_token != nullptr) {
500 fprintf(ar->f, "var");500 fprintf(ar->f, "anytype");
501 } else {501 } else {
502 AstNode *return_type_node = node->data.fn_proto.return_type;502 AstNode *return_type_node = node->data.fn_proto.return_type;
503 assert(return_type_node != nullptr);503 assert(return_type_node != nullptr);
...@@ -1216,8 +1216,8 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {...@@ -1216,8 +1216,8 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {
1216 fprintf(ar->f, ".%s", buf_ptr(&node->data.enum_literal.identifier->data.str_lit.str));1216 fprintf(ar->f, ".%s", buf_ptr(&node->data.enum_literal.identifier->data.str_lit.str));
1217 break;1217 break;
1218 }1218 }
1219 case NodeTypeVarFieldType: {1219 case NodeTypeAnyTypeField: {
1220 fprintf(ar->f, "var");1220 fprintf(ar->f, "anytype");
1221 break;1221 break;
1222 }1222 }
1223 case NodeTypeParamDecl:1223 case NodeTypeParamDecl:
src/codegen.cpp+2-2
...@@ -8448,8 +8448,8 @@ static void define_builtin_types(CodeGen *g) {...@@ -8448,8 +8448,8 @@ static void define_builtin_types(CodeGen *g) {
8448 }8448 }
8449 {8449 {
8450 ZigType *entry = new_type_table_entry(ZigTypeIdOpaque);8450 ZigType *entry = new_type_table_entry(ZigTypeIdOpaque);
8451 buf_init_from_str(&entry->name, "(var)");8451 buf_init_from_str(&entry->name, "(anytype)");
8452 g->builtin_types.entry_var = entry;8452 g->builtin_types.entry_anytype = entry;
8453 }8453 }
84548454
8455 for (size_t i = 0; i < array_length(c_int_type_infos); i += 1) {8455 for (size_t i = 0; i < array_length(c_int_type_infos); i += 1) {
src/ir.cpp+32-27
...@@ -9942,7 +9942,7 @@ static IrInstSrc *ir_gen_fn_proto(IrBuilderSrc *irb, Scope *parent_scope, AstNod...@@ -9942,7 +9942,7 @@ static IrInstSrc *ir_gen_fn_proto(IrBuilderSrc *irb, Scope *parent_scope, AstNod
9942 is_var_args = true;9942 is_var_args = true;
9943 break;9943 break;
9944 }9944 }
9945 if (param_node->data.param_decl.var_token == nullptr) {9945 if (param_node->data.param_decl.anytype_token == nullptr) {
9946 AstNode *type_node = param_node->data.param_decl.type;9946 AstNode *type_node = param_node->data.param_decl.type;
9947 IrInstSrc *type_value = ir_gen_node(irb, type_node, parent_scope);9947 IrInstSrc *type_value = ir_gen_node(irb, type_node, parent_scope);
9948 if (type_value == irb->codegen->invalid_inst_src)9948 if (type_value == irb->codegen->invalid_inst_src)
...@@ -9968,7 +9968,7 @@ static IrInstSrc *ir_gen_fn_proto(IrBuilderSrc *irb, Scope *parent_scope, AstNod...@@ -9968,7 +9968,7 @@ static IrInstSrc *ir_gen_fn_proto(IrBuilderSrc *irb, Scope *parent_scope, AstNod
9968 }9968 }
99699969
9970 IrInstSrc *return_type;9970 IrInstSrc *return_type;
9971 if (node->data.fn_proto.return_var_token == nullptr) {9971 if (node->data.fn_proto.return_anytype_token == nullptr) {
9972 if (node->data.fn_proto.return_type == nullptr) {9972 if (node->data.fn_proto.return_type == nullptr) {
9973 return_type = ir_build_const_type(irb, parent_scope, node, irb->codegen->builtin_types.entry_void);9973 return_type = ir_build_const_type(irb, parent_scope, node, irb->codegen->builtin_types.entry_void);
9974 } else {9974 } else {
...@@ -10226,9 +10226,9 @@ static IrInstSrc *ir_gen_node_raw(IrBuilderSrc *irb, AstNode *node, Scope *scope...@@ -10226,9 +10226,9 @@ static IrInstSrc *ir_gen_node_raw(IrBuilderSrc *irb, AstNode *node, Scope *scope
10226 add_node_error(irb->codegen, node,10226 add_node_error(irb->codegen, node,
10227 buf_sprintf("inferred array size invalid here"));10227 buf_sprintf("inferred array size invalid here"));
10228 return irb->codegen->invalid_inst_src;10228 return irb->codegen->invalid_inst_src;
10229 case NodeTypeVarFieldType:10229 case NodeTypeAnyTypeField:
10230 return ir_lval_wrap(irb, scope,10230 return ir_lval_wrap(irb, scope,
10231 ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_var), lval, result_loc);10231 ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_anytype), lval, result_loc);
10232 }10232 }
10233 zig_unreachable();10233 zig_unreachable();
10234}10234}
...@@ -10296,7 +10296,7 @@ static IrInstSrc *ir_gen_node_extra(IrBuilderSrc *irb, AstNode *node, Scope *sco...@@ -10296,7 +10296,7 @@ static IrInstSrc *ir_gen_node_extra(IrBuilderSrc *irb, AstNode *node, Scope *sco
10296 case NodeTypeSuspend:10296 case NodeTypeSuspend:
10297 case NodeTypeEnumLiteral:10297 case NodeTypeEnumLiteral:
10298 case NodeTypeInferredArrayType:10298 case NodeTypeInferredArrayType:
10299 case NodeTypeVarFieldType:10299 case NodeTypeAnyTypeField:
10300 case NodeTypePrefixOpExpr:10300 case NodeTypePrefixOpExpr:
10301 add_node_error(irb->codegen, node,10301 add_node_error(irb->codegen, node,
10302 buf_sprintf("invalid left-hand side to assignment"));10302 buf_sprintf("invalid left-hand side to assignment"));
...@@ -10518,7 +10518,7 @@ ZigValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ZigValue *const_va...@@ -10518,7 +10518,7 @@ ZigValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ZigValue *const_va
10518 if (val == nullptr) return nullptr;10518 if (val == nullptr) return nullptr;
10519 assert(const_val->type->id == ZigTypeIdPointer);10519 assert(const_val->type->id == ZigTypeIdPointer);
10520 ZigType *expected_type = const_val->type->data.pointer.child_type;10520 ZigType *expected_type = const_val->type->data.pointer.child_type;
10521 if (expected_type == codegen->builtin_types.entry_var) {10521 if (expected_type == codegen->builtin_types.entry_anytype) {
10522 return val;10522 return val;
10523 }10523 }
10524 switch (type_has_one_possible_value(codegen, expected_type)) {10524 switch (type_has_one_possible_value(codegen, expected_type)) {
...@@ -15040,7 +15040,7 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, IrInst *source_instr,...@@ -15040,7 +15040,7 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, IrInst *source_instr,
15040 }15040 }
1504115041
15042 // This means the wanted type is anything.15042 // This means the wanted type is anything.
15043 if (wanted_type == ira->codegen->builtin_types.entry_var) {15043 if (wanted_type == ira->codegen->builtin_types.entry_anytype) {
15044 return value;15044 return value;
15045 }15045 }
1504615046
...@@ -15635,7 +15635,7 @@ static IrInstGen *ir_implicit_cast(IrAnalyze *ira, IrInstGen *value, ZigType *ex...@@ -15635,7 +15635,7 @@ static IrInstGen *ir_implicit_cast(IrAnalyze *ira, IrInstGen *value, ZigType *ex
15635static ZigType *get_ptr_elem_type(CodeGen *g, IrInstGen *ptr) {15635static ZigType *get_ptr_elem_type(CodeGen *g, IrInstGen *ptr) {
15636 ir_assert_gen(ptr->value->type->id == ZigTypeIdPointer, ptr);15636 ir_assert_gen(ptr->value->type->id == ZigTypeIdPointer, ptr);
15637 ZigType *elem_type = ptr->value->type->data.pointer.child_type;15637 ZigType *elem_type = ptr->value->type->data.pointer.child_type;
15638 if (elem_type != g->builtin_types.entry_var)15638 if (elem_type != g->builtin_types.entry_anytype)
15639 return elem_type;15639 return elem_type;
1564015640
15641 if (ir_resolve_lazy(g, ptr->base.source_node, ptr->value))15641 if (ir_resolve_lazy(g, ptr->base.source_node, ptr->value))
...@@ -15687,7 +15687,7 @@ static IrInstGen *ir_get_deref(IrAnalyze *ira, IrInst* source_instruction, IrIns...@@ -15687,7 +15687,7 @@ static IrInstGen *ir_get_deref(IrAnalyze *ira, IrInst* source_instruction, IrIns
15687 }15687 }
15688 if (ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) {15688 if (ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) {
15689 ZigValue *pointee = const_ptr_pointee_unchecked(ira->codegen, ptr->value);15689 ZigValue *pointee = const_ptr_pointee_unchecked(ira->codegen, ptr->value);
15690 if (child_type == ira->codegen->builtin_types.entry_var) {15690 if (child_type == ira->codegen->builtin_types.entry_anytype) {
15691 child_type = pointee->type;15691 child_type = pointee->type;
15692 }15692 }
15693 if (pointee->special != ConstValSpecialRuntime) {15693 if (pointee->special != ConstValSpecialRuntime) {
...@@ -19087,7 +19087,7 @@ static Error ir_result_has_type(IrAnalyze *ira, ResultLoc *result_loc, bool *out...@@ -19087,7 +19087,7 @@ static Error ir_result_has_type(IrAnalyze *ira, ResultLoc *result_loc, bool *out
19087 ZigType *dest_type = ir_resolve_type(ira, result_cast->base.source_instruction->child);19087 ZigType *dest_type = ir_resolve_type(ira, result_cast->base.source_instruction->child);
19088 if (type_is_invalid(dest_type))19088 if (type_is_invalid(dest_type))
19089 return ErrorSemanticAnalyzeFail;19089 return ErrorSemanticAnalyzeFail;
19090 *out = (dest_type != ira->codegen->builtin_types.entry_var);19090 *out = (dest_type != ira->codegen->builtin_types.entry_anytype);
19091 return ErrorNone;19091 return ErrorNone;
19092 }19092 }
19093 case ResultLocIdVar:19093 case ResultLocIdVar:
...@@ -19293,7 +19293,7 @@ static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInst *suspend_source_i...@@ -19293,7 +19293,7 @@ static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInst *suspend_source_i
19293 if (type_is_invalid(dest_type))19293 if (type_is_invalid(dest_type))
19294 return ira->codegen->invalid_inst_gen;19294 return ira->codegen->invalid_inst_gen;
1929519295
19296 if (dest_type == ira->codegen->builtin_types.entry_var) {19296 if (dest_type == ira->codegen->builtin_types.entry_anytype) {
19297 return ir_resolve_no_result_loc(ira, suspend_source_instr, result_loc, value_type);19297 return ir_resolve_no_result_loc(ira, suspend_source_instr, result_loc, value_type);
19298 }19298 }
1929919299
...@@ -19439,7 +19439,7 @@ static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInst *suspend_source_i...@@ -19439,7 +19439,7 @@ static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInst *suspend_source_i
19439 return ira->codegen->invalid_inst_gen;19439 return ira->codegen->invalid_inst_gen;
19440 }19440 }
1944119441
19442 if (child_type != ira->codegen->builtin_types.entry_var) {19442 if (child_type != ira->codegen->builtin_types.entry_anytype) {
19443 if (type_size(ira->codegen, child_type) != type_size(ira->codegen, value_type)) {19443 if (type_size(ira->codegen, child_type) != type_size(ira->codegen, value_type)) {
19444 // pointer cast won't work; we need a temporary location.19444 // pointer cast won't work; we need a temporary location.
19445 result_bit_cast->parent->written = parent_was_written;19445 result_bit_cast->parent->written = parent_was_written;
...@@ -19600,9 +19600,9 @@ static IrInstGen *ir_analyze_instruction_resolve_result(IrAnalyze *ira, IrInstSr...@@ -19600,9 +19600,9 @@ static IrInstGen *ir_analyze_instruction_resolve_result(IrAnalyze *ira, IrInstSr
19600 if (type_is_invalid(implicit_elem_type))19600 if (type_is_invalid(implicit_elem_type))
19601 return ira->codegen->invalid_inst_gen;19601 return ira->codegen->invalid_inst_gen;
19602 } else {19602 } else {
19603 implicit_elem_type = ira->codegen->builtin_types.entry_var;19603 implicit_elem_type = ira->codegen->builtin_types.entry_anytype;
19604 }19604 }
19605 if (implicit_elem_type == ira->codegen->builtin_types.entry_var) {19605 if (implicit_elem_type == ira->codegen->builtin_types.entry_anytype) {
19606 Buf *bare_name = buf_alloc();19606 Buf *bare_name = buf_alloc();
19607 Buf *name = get_anon_type_name(ira->codegen, nullptr, container_string(ContainerKindStruct),19607 Buf *name = get_anon_type_name(ira->codegen, nullptr, container_string(ContainerKindStruct),
19608 instruction->base.base.scope, instruction->base.base.source_node, bare_name);19608 instruction->base.base.scope, instruction->base.base.source_node, bare_name);
...@@ -19759,7 +19759,7 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node...@@ -19759,7 +19759,7 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node
19759 assert(param_decl_node->type == NodeTypeParamDecl);19759 assert(param_decl_node->type == NodeTypeParamDecl);
1976019760
19761 IrInstGen *casted_arg;19761 IrInstGen *casted_arg;
19762 if (param_decl_node->data.param_decl.var_token == nullptr) {19762 if (param_decl_node->data.param_decl.anytype_token == nullptr) {
19763 AstNode *param_type_node = param_decl_node->data.param_decl.type;19763 AstNode *param_type_node = param_decl_node->data.param_decl.type;
19764 ZigType *param_type = ir_analyze_type_expr(ira, *exec_scope, param_type_node);19764 ZigType *param_type = ir_analyze_type_expr(ira, *exec_scope, param_type_node);
19765 if (type_is_invalid(param_type))19765 if (type_is_invalid(param_type))
...@@ -19799,7 +19799,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod...@@ -19799,7 +19799,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod
19799 arg_part_of_generic_id = true;19799 arg_part_of_generic_id = true;
19800 casted_arg = arg;19800 casted_arg = arg;
19801 } else {19801 } else {
19802 if (param_decl_node->data.param_decl.var_token == nullptr) {19802 if (param_decl_node->data.param_decl.anytype_token == nullptr) {
19803 AstNode *param_type_node = param_decl_node->data.param_decl.type;19803 AstNode *param_type_node = param_decl_node->data.param_decl.type;
19804 ZigType *param_type = ir_analyze_type_expr(ira, *child_scope, param_type_node);19804 ZigType *param_type = ir_analyze_type_expr(ira, *child_scope, param_type_node);
19805 if (type_is_invalid(param_type))19805 if (type_is_invalid(param_type))
...@@ -20011,7 +20011,7 @@ static IrInstGen *ir_analyze_store_ptr(IrAnalyze *ira, IrInst* source_instr,...@@ -20011,7 +20011,7 @@ static IrInstGen *ir_analyze_store_ptr(IrAnalyze *ira, IrInst* source_instr,
20011 }20011 }
2001220012
20013 if (ptr->value->type->data.pointer.inferred_struct_field != nullptr &&20013 if (ptr->value->type->data.pointer.inferred_struct_field != nullptr &&
20014 child_type == ira->codegen->builtin_types.entry_var)20014 child_type == ira->codegen->builtin_types.entry_anytype)
20015 {20015 {
20016 child_type = ptr->value->type->data.pointer.inferred_struct_field->inferred_struct_type;20016 child_type = ptr->value->type->data.pointer.inferred_struct_field->inferred_struct_type;
20017 }20017 }
...@@ -20202,6 +20202,11 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,...@@ -20202,6 +20202,11 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,
20202 }20202 }
2020320203
20204 AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type;20204 AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type;
20205 if (return_type_node == nullptr) {
20206 ir_add_error(ira, &fn_ref->base,
20207 buf_sprintf("TODO implement inferred return types https://github.com/ziglang/zig/issues/447"));
20208 return ira->codegen->invalid_inst_gen;
20209 }
20205 ZigType *specified_return_type = ir_analyze_type_expr(ira, exec_scope, return_type_node);20210 ZigType *specified_return_type = ir_analyze_type_expr(ira, exec_scope, return_type_node);
20206 if (type_is_invalid(specified_return_type))20211 if (type_is_invalid(specified_return_type))
20207 return ira->codegen->invalid_inst_gen;20212 return ira->codegen->invalid_inst_gen;
...@@ -20364,7 +20369,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,...@@ -20364,7 +20369,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,
20364 inst_fn_type_id.alignment = align_bytes;20369 inst_fn_type_id.alignment = align_bytes;
20365 }20370 }
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) {
20368 AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type;20373 AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type;
20369 ZigType *specified_return_type = ir_analyze_type_expr(ira, impl_fn->child_scope, return_type_node);20374 ZigType *specified_return_type = ir_analyze_type_expr(ira, impl_fn->child_scope, return_type_node);
20370 if (type_is_invalid(specified_return_type))20375 if (type_is_invalid(specified_return_type))
...@@ -20463,7 +20468,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,...@@ -20463,7 +20468,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,
20463 if (type_is_invalid(dummy_result->value->type))20468 if (type_is_invalid(dummy_result->value->type))
20464 return ira->codegen->invalid_inst_gen;20469 return ira->codegen->invalid_inst_gen;
20465 ZigType *res_child_type = result_loc->value->type->data.pointer.child_type;20470 ZigType *res_child_type = result_loc->value->type->data.pointer.child_type;
20466 if (res_child_type == ira->codegen->builtin_types.entry_var) {20471 if (res_child_type == ira->codegen->builtin_types.entry_anytype) {
20467 res_child_type = impl_fn_type_id->return_type;20472 res_child_type = impl_fn_type_id->return_type;
20468 }20473 }
20469 if (!handle_is_ptr(ira->codegen, res_child_type)) {20474 if (!handle_is_ptr(ira->codegen, res_child_type)) {
...@@ -20606,7 +20611,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,...@@ -20606,7 +20611,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr,
20606 if (type_is_invalid(dummy_result->value->type))20611 if (type_is_invalid(dummy_result->value->type))
20607 return ira->codegen->invalid_inst_gen;20612 return ira->codegen->invalid_inst_gen;
20608 ZigType *res_child_type = result_loc->value->type->data.pointer.child_type;20613 ZigType *res_child_type = result_loc->value->type->data.pointer.child_type;
20609 if (res_child_type == ira->codegen->builtin_types.entry_var) {20614 if (res_child_type == ira->codegen->builtin_types.entry_anytype) {
20610 res_child_type = return_type;20615 res_child_type = return_type;
20611 }20616 }
20612 if (!handle_is_ptr(ira->codegen, res_child_type)) {20617 if (!handle_is_ptr(ira->codegen, res_child_type)) {
...@@ -22337,7 +22342,7 @@ static IrInstGen *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_name,...@@ -22337,7 +22342,7 @@ static IrInstGen *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_name,
22337 inferred_struct_field->inferred_struct_type = container_type;22342 inferred_struct_field->inferred_struct_type = container_type;
22338 inferred_struct_field->field_name = field_name;22343 inferred_struct_field->field_name = field_name;
2233922344
22340 ZigType *elem_type = ira->codegen->builtin_types.entry_var;22345 ZigType *elem_type = ira->codegen->builtin_types.entry_anytype;
22341 ZigType *field_ptr_type = get_pointer_to_type_extra2(ira->codegen, elem_type,22346 ZigType *field_ptr_type = get_pointer_to_type_extra2(ira->codegen, elem_type,
22342 container_ptr_type->data.pointer.is_const, container_ptr_type->data.pointer.is_volatile,22347 container_ptr_type->data.pointer.is_const, container_ptr_type->data.pointer.is_volatile,
22343 PtrLenSingle, 0, 0, 0, false, VECTOR_INDEX_NONE, inferred_struct_field, nullptr);22348 PtrLenSingle, 0, 0, 0, false, VECTOR_INDEX_NONE, inferred_struct_field, nullptr);
...@@ -25115,7 +25120,7 @@ static ZigValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_type_ent...@@ -25115,7 +25120,7 @@ static ZigValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_type_ent
25115 fields[5]->special = ConstValSpecialStatic;25120 fields[5]->special = ConstValSpecialStatic;
25116 fields[5]->type = ira->codegen->builtin_types.entry_bool;25121 fields[5]->type = ira->codegen->builtin_types.entry_bool;
25117 fields[5]->data.x_bool = attrs_type->data.pointer.allow_zero;25122 fields[5]->data.x_bool = attrs_type->data.pointer.allow_zero;
25118 // sentinel: var25123 // sentinel: anytype
25119 ensure_field_index(result->type, "sentinel", 6);25124 ensure_field_index(result->type, "sentinel", 6);
25120 fields[6]->special = ConstValSpecialStatic;25125 fields[6]->special = ConstValSpecialStatic;
25121 if (attrs_type->data.pointer.child_type->id != ZigTypeIdOpaque) {25126 if (attrs_type->data.pointer.child_type->id != ZigTypeIdOpaque) {
...@@ -25243,7 +25248,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy...@@ -25243,7 +25248,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy
25243 fields[1]->special = ConstValSpecialStatic;25248 fields[1]->special = ConstValSpecialStatic;
25244 fields[1]->type = ira->codegen->builtin_types.entry_type;25249 fields[1]->type = ira->codegen->builtin_types.entry_type;
25245 fields[1]->data.x_type = type_entry->data.array.child_type;25250 fields[1]->data.x_type = type_entry->data.array.child_type;
25246 // sentinel: var25251 // sentinel: anytype
25247 fields[2]->special = ConstValSpecialStatic;25252 fields[2]->special = ConstValSpecialStatic;
25248 fields[2]->type = get_optional_type(ira->codegen, type_entry->data.array.child_type);25253 fields[2]->type = get_optional_type(ira->codegen, type_entry->data.array.child_type);
25249 fields[2]->data.x_optional = type_entry->data.array.sentinel;25254 fields[2]->data.x_optional = type_entry->data.array.sentinel;
...@@ -25598,7 +25603,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy...@@ -25598,7 +25603,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy
25598 inner_fields[2]->type = ira->codegen->builtin_types.entry_type;25603 inner_fields[2]->type = ira->codegen->builtin_types.entry_type;
25599 inner_fields[2]->data.x_type = struct_field->type_entry;25604 inner_fields[2]->data.x_type = struct_field->type_entry;
2560025605
25601 // default_value: var25606 // default_value: anytype
25602 inner_fields[3]->special = ConstValSpecialStatic;25607 inner_fields[3]->special = ConstValSpecialStatic;
25603 inner_fields[3]->type = get_optional_type2(ira->codegen, struct_field->type_entry);25608 inner_fields[3]->type = get_optional_type2(ira->codegen, struct_field->type_entry);
25604 if (inner_fields[3]->type == nullptr) return ErrorSemanticAnalyzeFail;25609 if (inner_fields[3]->type == nullptr) return ErrorSemanticAnalyzeFail;
...@@ -25736,7 +25741,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy...@@ -25736,7 +25741,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy
25736 ZigValue **fields = alloc_const_vals_ptrs(ira->codegen, 1);25741 ZigValue **fields = alloc_const_vals_ptrs(ira->codegen, 1);
25737 result->data.x_struct.fields = fields;25742 result->data.x_struct.fields = fields;
25738 ZigFn *fn = type_entry->data.frame.fn;25743 ZigFn *fn = type_entry->data.frame.fn;
25739 // function: var25744 // function: anytype
25740 ensure_field_index(result->type, "function", 0);25745 ensure_field_index(result->type, "function", 0);
25741 fields[0] = create_const_fn(ira->codegen, fn);25746 fields[0] = create_const_fn(ira->codegen, fn);
25742 break;25747 break;
...@@ -29996,7 +30001,7 @@ static IrInstGen *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstSrcArgTy...@@ -29996,7 +30001,7 @@ static IrInstGen *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstSrcArgTy
29996 if (arg_index >= fn_type_id->param_count) {30001 if (arg_index >= fn_type_id->param_count) {
29997 if (instruction->allow_var) {30002 if (instruction->allow_var) {
29998 // TODO remove this with var args30003 // TODO remove this with var args
29999 return ir_const_type(ira, &instruction->base.base, ira->codegen->builtin_types.entry_var);30004 return ir_const_type(ira, &instruction->base.base, ira->codegen->builtin_types.entry_anytype);
30000 }30005 }
30001 ir_add_error(ira, &arg_index_inst->base,30006 ir_add_error(ira, &arg_index_inst->base,
30002 buf_sprintf("arg index %" ZIG_PRI_u64 " out of bounds; '%s' has %" ZIG_PRI_usize " arguments",30007 buf_sprintf("arg index %" ZIG_PRI_u64 " out of bounds; '%s' has %" ZIG_PRI_usize " arguments",
...@@ -30010,7 +30015,7 @@ static IrInstGen *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstSrcArgTy...@@ -30010,7 +30015,7 @@ static IrInstGen *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstSrcArgTy
30010 ir_assert(fn_type->data.fn.is_generic, &instruction->base.base);30015 ir_assert(fn_type->data.fn.is_generic, &instruction->base.base);
3001130016
30012 if (instruction->allow_var) {30017 if (instruction->allow_var) {
30013 return ir_const_type(ira, &instruction->base.base, ira->codegen->builtin_types.entry_var);30018 return ir_const_type(ira, &instruction->base.base, ira->codegen->builtin_types.entry_anytype);
30014 } else {30019 } else {
30015 ir_add_error(ira, &arg_index_inst->base,30020 ir_add_error(ira, &arg_index_inst->base,
30016 buf_sprintf("@ArgType could not resolve the type of arg %" ZIG_PRI_u64 " because '%s' is generic",30021 buf_sprintf("@ArgType could not resolve the type of arg %" ZIG_PRI_u64 " because '%s' is generic",
src/parser.cpp+13-13
...@@ -786,7 +786,7 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B...@@ -786,7 +786,7 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B
786 return nullptr;786 return nullptr;
787}787}
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)
790static AstNode *ast_parse_fn_proto(ParseContext *pc) {790static AstNode *ast_parse_fn_proto(ParseContext *pc) {
791 Token *first = eat_token_if(pc, TokenIdKeywordFn);791 Token *first = eat_token_if(pc, TokenIdKeywordFn);
792 if (first == nullptr) {792 if (first == nullptr) {
...@@ -801,10 +801,10 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) {...@@ -801,10 +801,10 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) {
801 AstNode *align_expr = ast_parse_byte_align(pc);801 AstNode *align_expr = ast_parse_byte_align(pc);
802 AstNode *section_expr = ast_parse_link_section(pc);802 AstNode *section_expr = ast_parse_link_section(pc);
803 AstNode *callconv_expr = ast_parse_callconv(pc);803 AstNode *callconv_expr = ast_parse_callconv(pc);
804 Token *var = eat_token_if(pc, TokenIdKeywordVar);804 Token *anytype = eat_token_if(pc, TokenIdKeywordAnyType);
805 Token *exmark = nullptr;805 Token *exmark = nullptr;
806 AstNode *return_type = nullptr;806 AstNode *return_type = nullptr;
807 if (var == nullptr) {807 if (anytype == nullptr) {
808 exmark = eat_token_if(pc, TokenIdBang);808 exmark = eat_token_if(pc, TokenIdBang);
809 return_type = ast_expect(pc, ast_parse_type_expr);809 return_type = ast_expect(pc, ast_parse_type_expr);
810 }810 }
...@@ -816,7 +816,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) {...@@ -816,7 +816,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) {
816 res->data.fn_proto.align_expr = align_expr;816 res->data.fn_proto.align_expr = align_expr;
817 res->data.fn_proto.section_expr = section_expr;817 res->data.fn_proto.section_expr = section_expr;
818 res->data.fn_proto.callconv_expr = callconv_expr;818 res->data.fn_proto.callconv_expr = callconv_expr;
819 res->data.fn_proto.return_var_token = var;819 res->data.fn_proto.return_anytype_token = anytype;
820 res->data.fn_proto.auto_err_set = exmark != nullptr;820 res->data.fn_proto.auto_err_set = exmark != nullptr;
821 res->data.fn_proto.return_type = return_type;821 res->data.fn_proto.return_type = return_type;
822822
...@@ -870,9 +870,9 @@ static AstNode *ast_parse_container_field(ParseContext *pc) {...@@ -870,9 +870,9 @@ static AstNode *ast_parse_container_field(ParseContext *pc) {
870870
871 AstNode *type_expr = nullptr;871 AstNode *type_expr = nullptr;
872 if (eat_token_if(pc, TokenIdColon) != nullptr) {872 if (eat_token_if(pc, TokenIdColon) != nullptr) {
873 Token *var_tok = eat_token_if(pc, TokenIdKeywordVar);873 Token *anytype_tok = eat_token_if(pc, TokenIdKeywordAnyType);
874 if (var_tok != nullptr) {874 if (anytype_tok != nullptr) {
875 type_expr = ast_create_node(pc, NodeTypeVarFieldType, var_tok);875 type_expr = ast_create_node(pc, NodeTypeAnyTypeField, anytype_tok);
876 } else {876 } else {
877 type_expr = ast_expect(pc, ast_parse_type_expr);877 type_expr = ast_expect(pc, ast_parse_type_expr);
878 }878 }
...@@ -2191,14 +2191,14 @@ static AstNode *ast_parse_param_decl(ParseContext *pc) {...@@ -2191,14 +2191,14 @@ static AstNode *ast_parse_param_decl(ParseContext *pc) {
2191}2191}
21922192
2193// ParamType2193// ParamType
2194// <- KEYWORD_var2194// <- KEYWORD_anytype
2195// / DOT32195// / DOT3
2196// / TypeExpr2196// / TypeExpr
2197static AstNode *ast_parse_param_type(ParseContext *pc) {2197static AstNode *ast_parse_param_type(ParseContext *pc) {
2198 Token *var_token = eat_token_if(pc, TokenIdKeywordVar);2198 Token *anytype_token = eat_token_if(pc, TokenIdKeywordAnyType);
2199 if (var_token != nullptr) {2199 if (anytype_token != nullptr) {
2200 AstNode *res = ast_create_node(pc, NodeTypeParamDecl, var_token);2200 AstNode *res = ast_create_node(pc, NodeTypeParamDecl, anytype_token);
2201 res->data.param_decl.var_token = var_token;2201 res->data.param_decl.anytype_token = anytype_token;
2202 return res;2202 return res;
2203 }2203 }
22042204
...@@ -3207,7 +3207,7 @@ void ast_visit_node_children(AstNode *node, void (*visit)(AstNode **, void *cont...@@ -3207,7 +3207,7 @@ void ast_visit_node_children(AstNode *node, void (*visit)(AstNode **, void *cont
3207 visit_field(&node->data.suspend.block, visit, context);3207 visit_field(&node->data.suspend.block, visit, context);
3208 break;3208 break;
3209 case NodeTypeEnumLiteral:3209 case NodeTypeEnumLiteral:
3210 case NodeTypeVarFieldType:3210 case NodeTypeAnyTypeField:
3211 break;3211 break;
3212 }3212 }
3213}3213}
src/tokenizer.cpp+2
...@@ -106,6 +106,7 @@ static const struct ZigKeyword zig_keywords[] = {...@@ -106,6 +106,7 @@ static const struct ZigKeyword zig_keywords[] = {
106 {"allowzero", TokenIdKeywordAllowZero},106 {"allowzero", TokenIdKeywordAllowZero},
107 {"and", TokenIdKeywordAnd},107 {"and", TokenIdKeywordAnd},
108 {"anyframe", TokenIdKeywordAnyFrame},108 {"anyframe", TokenIdKeywordAnyFrame},
109 {"anytype", TokenIdKeywordAnyType},
109 {"asm", TokenIdKeywordAsm},110 {"asm", TokenIdKeywordAsm},
110 {"async", TokenIdKeywordAsync},111 {"async", TokenIdKeywordAsync},
111 {"await", TokenIdKeywordAwait},112 {"await", TokenIdKeywordAwait},
...@@ -1569,6 +1570,7 @@ const char * token_name(TokenId id) {...@@ -1569,6 +1570,7 @@ const char * token_name(TokenId id) {
1569 case TokenIdKeywordAlign: return "align";1570 case TokenIdKeywordAlign: return "align";
1570 case TokenIdKeywordAnd: return "and";1571 case TokenIdKeywordAnd: return "and";
1571 case TokenIdKeywordAnyFrame: return "anyframe";1572 case TokenIdKeywordAnyFrame: return "anyframe";
1573 case TokenIdKeywordAnyType: return "anytype";
1572 case TokenIdKeywordAsm: return "asm";1574 case TokenIdKeywordAsm: return "asm";
1573 case TokenIdKeywordBreak: return "break";1575 case TokenIdKeywordBreak: return "break";
1574 case TokenIdKeywordCatch: return "catch";1576 case TokenIdKeywordCatch: return "catch";
src/tokenizer.hpp+1
...@@ -54,6 +54,7 @@ enum TokenId {...@@ -54,6 +54,7 @@ enum TokenId {
54 TokenIdKeywordAllowZero,54 TokenIdKeywordAllowZero,
55 TokenIdKeywordAnd,55 TokenIdKeywordAnd,
56 TokenIdKeywordAnyFrame,56 TokenIdKeywordAnyFrame,
57 TokenIdKeywordAnyType,
57 TokenIdKeywordAsm,58 TokenIdKeywordAsm,
58 TokenIdKeywordAsync,59 TokenIdKeywordAsync,
59 TokenIdKeywordAwait,60 TokenIdKeywordAwait,
test/compile_errors.zig+17-17
...@@ -42,7 +42,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -42,7 +42,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
42 \\fn foo() Foo {42 \\fn foo() Foo {
43 \\ return .{ .x = 42 };43 \\ return .{ .x = 42 };
44 \\}44 \\}
45 \\fn bar(val: var) Foo {45 \\fn bar(val: anytype) Foo {
46 \\ return .{ .x = val };46 \\ return .{ .x = val };
47 \\}47 \\}
48 \\export fn entry() void {48 \\export fn entry() void {
...@@ -1034,7 +1034,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1034,7 +1034,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1034 \\ storev(&v[i], 42);1034 \\ storev(&v[i], 42);
1035 \\}1035 \\}
1036 \\1036 \\
1037 \\fn storev(ptr: var, val: i32) void {1037 \\fn storev(ptr: anytype, val: i32) void {
1038 \\ ptr.* = val;1038 \\ ptr.* = val;
1039 \\}1039 \\}
1040 , &[_][]const u8{1040 , &[_][]const u8{
...@@ -1049,7 +1049,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1049,7 +1049,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1049 \\ var x = loadv(&v[i]);1049 \\ var x = loadv(&v[i]);
1050 \\}1050 \\}
1051 \\1051 \\
1052 \\fn loadv(ptr: var) i32 {1052 \\fn loadv(ptr: anytype) i32 {
1053 \\ return ptr.*;1053 \\ return ptr.*;
1054 \\}1054 \\}
1055 , &[_][]const u8{1055 , &[_][]const u8{
...@@ -1832,7 +1832,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -1832,7 +1832,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
1832 \\ while (true) {}1832 \\ while (true) {}
1833 \\}1833 \\}
1834 , &[_][]const u8{1834 , &[_][]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'",
1836 "note: only one of the functions is generic",1836 "note: only one of the functions is generic",
1837 });1837 });
18381838
...@@ -2032,11 +2032,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -2032,11 +2032,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
2032 });2032 });
20332033
2034 cases.add("export generic function",2034 cases.add("export generic function",
2035 \\export fn foo(num: var) i32 {2035 \\export fn foo(num: anytype) i32 {
2036 \\ return 0;2036 \\ return 0;
2037 \\}2037 \\}
2038 , &[_][]const u8{2038 , &[_][]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'",
2040 });2040 });
20412041
2042 cases.add("C pointer to c_void",2042 cases.add("C pointer to c_void",
...@@ -2836,7 +2836,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -2836,7 +2836,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
2836 });2836 });
28372837
2838 cases.add("missing parameter name of generic function",2838 cases.add("missing parameter name of generic function",
2839 \\fn dump(var) void {}2839 \\fn dump(anytype) void {}
2840 \\export fn entry() void {2840 \\export fn entry() void {
2841 \\ var a: u8 = 9;2841 \\ var a: u8 = 9;
2842 \\ dump(a);2842 \\ dump(a);
...@@ -2859,13 +2859,13 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -2859,13 +2859,13 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
2859 });2859 });
28602860
2861 cases.add("generic fn as parameter without comptime keyword",2861 cases.add("generic fn as parameter without comptime keyword",
2862 \\fn f(_: fn (var) void) void {}2862 \\fn f(_: fn (anytype) void) void {}
2863 \\fn g(_: var) void {}2863 \\fn g(_: anytype) void {}
2864 \\export fn entry() void {2864 \\export fn entry() void {
2865 \\ f(g);2865 \\ f(g);
2866 \\}2866 \\}
2867 , &[_][]const u8{2867 , &[_][]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",
2869 });2869 });
28702870
2871 cases.add("optional pointer to void in extern struct",2871 cases.add("optional pointer to void in extern struct",
...@@ -3165,7 +3165,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -3165,7 +3165,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
31653165
3166 cases.add("var makes structs required to be comptime known",3166 cases.add("var makes structs required to be comptime known",
3167 \\export fn entry() void {3167 \\export fn entry() void {
3168 \\ const S = struct{v: var};3168 \\ const S = struct{v: anytype};
3169 \\ var s = S{.v=@as(i32, 10)};3169 \\ var s = S{.v=@as(i32, 10)};
3170 \\}3170 \\}
3171 , &[_][]const u8{3171 , &[_][]const u8{
...@@ -6072,10 +6072,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -6072,10 +6072,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
6072 });6072 });
60736073
6074 cases.add("calling a generic function only known at runtime",6074 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 };
6076 \\6076 \\
6077 \\fn foo1(arg: var) void {}6077 \\fn foo1(arg: anytype) void {}
6078 \\fn foo2(arg: var) void {}6078 \\fn foo2(arg: anytype) void {}
6079 \\6079 \\
6080 \\pub fn main() !void {6080 \\pub fn main() !void {
6081 \\ foos[0](true);6081 \\ foos[0](true);
...@@ -6920,12 +6920,12 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -6920,12 +6920,12 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
6920 });6920 });
69216921
6922 cases.add("getting return type of generic function",6922 cases.add("getting return type of generic function",
6923 \\fn generic(a: var) void {}6923 \\fn generic(a: anytype) void {}
6924 \\comptime {6924 \\comptime {
6925 \\ _ = @TypeOf(generic).ReturnType;6925 \\ _ = @TypeOf(generic).ReturnType;
6926 \\}6926 \\}
6927 , &[_][]const u8{6927 , &[_][]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",
6929 });6929 });
69306930
6931 cases.add("unsupported modifier at start of asm output constraint",6931 cases.add("unsupported modifier at start of asm output constraint",
...@@ -7493,7 +7493,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -7493,7 +7493,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
7493 });7493 });
74947494
7495 cases.add("issue #5221: invalid struct init type referenced by @typeInfo and passed into function",7495 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 {}
7497 \\7497 \\
7498 \\export fn foo() void {7498 \\export fn foo() void {
7499 \\ const MyStruct = struct {7499 \\ const MyStruct = struct {
test/stage1/behavior/async_fn.zig+5-5
...@@ -1016,7 +1016,7 @@ test "@asyncCall using the result location inside the frame" {...@@ -1016,7 +1016,7 @@ test "@asyncCall using the result location inside the frame" {
10161016
1017test "@TypeOf an async function call of generic fn with error union type" {1017test "@TypeOf an async function call of generic fn with error union type" {
1018 const S = struct {1018 const S = struct {
1019 fn func(comptime x: var) anyerror!i32 {1019 fn func(comptime x: anytype) anyerror!i32 {
1020 const T = @TypeOf(async func(x));1020 const T = @TypeOf(async func(x));
1021 comptime expect(T == @TypeOf(@frame()).Child);1021 comptime expect(T == @TypeOf(@frame()).Child);
1022 return undefined;1022 return undefined;
...@@ -1032,7 +1032,7 @@ test "using @TypeOf on a generic function call" {...@@ -1032,7 +1032,7 @@ test "using @TypeOf on a generic function call" {
10321032
1033 var buf: [100]u8 align(16) = undefined;1033 var buf: [100]u8 align(16) = undefined;
10341034
1035 fn amain(x: var) void {1035 fn amain(x: anytype) void {
1036 if (x == 0) {1036 if (x == 0) {
1037 global_ok = true;1037 global_ok = true;
1038 return;1038 return;
...@@ -1057,7 +1057,7 @@ test "recursive call of await @asyncCall with struct return type" {...@@ -1057,7 +1057,7 @@ test "recursive call of await @asyncCall with struct return type" {
10571057
1058 var buf: [100]u8 align(16) = undefined;1058 var buf: [100]u8 align(16) = undefined;
10591059
1060 fn amain(x: var) Foo {1060 fn amain(x: anytype) Foo {
1061 if (x == 0) {1061 if (x == 0) {
1062 global_ok = true;1062 global_ok = true;
1063 return Foo{ .x = 1, .y = 2, .z = 3 };1063 return Foo{ .x = 1, .y = 2, .z = 3 };
...@@ -1336,7 +1336,7 @@ test "async function passed 0-bit arg after non-0-bit arg" {...@@ -1336,7 +1336,7 @@ test "async function passed 0-bit arg after non-0-bit arg" {
1336 bar(1, .{}) catch unreachable;1336 bar(1, .{}) catch unreachable;
1337 }1337 }
13381338
1339 fn bar(x: i32, args: var) anyerror!void {1339 fn bar(x: i32, args: anytype) anyerror!void {
1340 global_frame = @frame();1340 global_frame = @frame();
1341 suspend;1341 suspend;
1342 global_int = x;1342 global_int = x;
...@@ -1357,7 +1357,7 @@ test "async function passed align(16) arg after align(8) arg" {...@@ -1357,7 +1357,7 @@ test "async function passed align(16) arg after align(8) arg" {
1357 bar(10, .{a}) catch unreachable;1357 bar(10, .{a}) catch unreachable;
1358 }1358 }
13591359
1360 fn bar(x: u64, args: var) anyerror!void {1360 fn bar(x: u64, args: anytype) anyerror!void {
1361 expect(x == 10);1361 expect(x == 10);
1362 global_frame = @frame();1362 global_frame = @frame();
1363 suspend;1363 suspend;
test/stage1/behavior/bitcast.zig+2-2
...@@ -171,7 +171,7 @@ test "nested bitcast" {...@@ -171,7 +171,7 @@ test "nested bitcast" {
171171
172test "bitcast passed as tuple element" {172test "bitcast passed as tuple element" {
173 const S = struct {173 const S = struct {
174 fn foo(args: var) void {174 fn foo(args: anytype) void {
175 comptime expect(@TypeOf(args[0]) == f32);175 comptime expect(@TypeOf(args[0]) == f32);
176 expect(args[0] == 12.34);176 expect(args[0] == 12.34);
177 }177 }
...@@ -181,7 +181,7 @@ test "bitcast passed as tuple element" {...@@ -181,7 +181,7 @@ test "bitcast passed as tuple element" {
181181
182test "triple level result location with bitcast sandwich passed as tuple element" {182test "triple level result location with bitcast sandwich passed as tuple element" {
183 const S = struct {183 const S = struct {
184 fn foo(args: var) void {184 fn foo(args: anytype) void {
185 comptime expect(@TypeOf(args[0]) == f64);185 comptime expect(@TypeOf(args[0]) == f64);
186 expect(args[0] > 12.33 and args[0] < 12.35);186 expect(args[0] > 12.33 and args[0] < 12.35);
187 }187 }
test/stage1/behavior/bugs/2114.zig+1-1
...@@ -2,7 +2,7 @@ const std = @import("std");...@@ -2,7 +2,7 @@ const std = @import("std");
2const expect = std.testing.expect;2const expect = std.testing.expect;
3const math = std.math;3const math = std.math;
44
5fn ctz(x: var) usize {5fn ctz(x: anytype) usize {
6 return @ctz(@TypeOf(x), x);6 return @ctz(@TypeOf(x), x);
7}7}
88
test/stage1/behavior/bugs/3742.zig+1-1
...@@ -23,7 +23,7 @@ pub fn isCommand(comptime T: type) bool {...@@ -23,7 +23,7 @@ pub fn isCommand(comptime T: type) bool {
23}23}
2424
25pub const ArgSerializer = struct {25pub const ArgSerializer = struct {
26 pub fn serializeCommand(command: var) void {26 pub fn serializeCommand(command: anytype) void {
27 const CmdT = @TypeOf(command);27 const CmdT = @TypeOf(command);
2828
29 if (comptime isCommand(CmdT)) {29 if (comptime isCommand(CmdT)) {
test/stage1/behavior/bugs/4328.zig+4-4
...@@ -17,11 +17,11 @@ const S = extern struct {...@@ -17,11 +17,11 @@ const S = extern struct {
1717
18test "Extern function calls in @TypeOf" {18test "Extern function calls in @TypeOf" {
19 const Test = struct {19 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)) {
21 return 0;21 return 0;
22 }22 }
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)) {
25 return 1;25 return 1;
26 }26 }
2727
...@@ -56,7 +56,7 @@ test "Extern function calls, dereferences and field access in @TypeOf" {...@@ -56,7 +56,7 @@ test "Extern function calls, dereferences and field access in @TypeOf" {
56 return .{ .dummy_field = 0 };56 return .{ .dummy_field = 0 };
57 }57 }
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) {
60 return 255;60 return 255;
61 }61 }
6262
...@@ -68,4 +68,4 @@ test "Extern function calls, dereferences and field access in @TypeOf" {...@@ -68,4 +68,4 @@ test "Extern function calls, dereferences and field access in @TypeOf" {
6868
69 Test.doTheTest();69 Test.doTheTest();
70 comptime Test.doTheTest();70 comptime Test.doTheTest();
71}
\ No newline at end of file
71}
test/stage1/behavior/bugs/4769_a.zig+1-1
...@@ -1 +1 @@...@@ -1 +1 @@
1//
\ No newline at end of file
1//
test/stage1/behavior/bugs/4769_b.zig+1-1
...@@ -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 {...@@ -13,11 +13,11 @@ fn start() void {
13 foo("string literal");13 foo("string literal");
14}14}
1515
16fn foo(x: var) void {16fn foo(x: anytype) void {
17 bar(x);17 bar(x);
18}18}
1919
20fn bar(x: var) void {20fn bar(x: anytype) void {
21 result = x;21 result = x;
22}22}
2323
test/stage1/behavior/call.zig+1-1
...@@ -57,7 +57,7 @@ test "tuple parameters" {...@@ -57,7 +57,7 @@ test "tuple parameters" {
5757
58test "comptime call with bound function as parameter" {58test "comptime call with bound function as parameter" {
59 const S = struct {59 const S = struct {
60 fn ReturnType(func: var) type {60 fn ReturnType(func: anytype) type {
61 return switch (@typeInfo(@TypeOf(func))) {61 return switch (@typeInfo(@TypeOf(func))) {
62 .BoundFn => |info| info,62 .BoundFn => |info| info,
63 else => unreachable,63 else => unreachable,
test/stage1/behavior/enum.zig+1-1
...@@ -208,7 +208,7 @@ test "@tagName non-exhaustive enum" {...@@ -208,7 +208,7 @@ test "@tagName non-exhaustive enum" {
208 comptime expect(mem.eql(u8, testEnumTagNameBare(NonExhaustive.B), "B"));208 comptime expect(mem.eql(u8, testEnumTagNameBare(NonExhaustive.B), "B"));
209}209}
210210
211fn testEnumTagNameBare(n: var) []const u8 {211fn testEnumTagNameBare(n: anytype) []const u8 {
212 return @tagName(n);212 return @tagName(n);
213}213}
214214
test/stage1/behavior/error.zig+1-1
...@@ -227,7 +227,7 @@ test "error: Infer error set from literals" {...@@ -227,7 +227,7 @@ test "error: Infer error set from literals" {
227 _ = comptime intLiteral("n") catch |err| handleErrors(err);227 _ = comptime intLiteral("n") catch |err| handleErrors(err);
228}228}
229229
230fn handleErrors(err: var) noreturn {230fn handleErrors(err: anytype) noreturn {
231 switch (err) {231 switch (err) {
232 error.T => {},232 error.T => {},
233 }233 }
test/stage1/behavior/eval.zig+4-5
...@@ -670,10 +670,10 @@ fn loopNTimes(comptime n: usize) void {...@@ -670,10 +670,10 @@ fn loopNTimes(comptime n: usize) void {
670}670}
671671
672test "variable inside inline loop that has different types on different iterations" {672test "variable inside inline loop that has different types on different iterations" {
673 testVarInsideInlineLoop(.{true, @as(u32, 42)});673 testVarInsideInlineLoop(.{ true, @as(u32, 42) });
674}674}
675675
676fn testVarInsideInlineLoop(args: var) void {676fn testVarInsideInlineLoop(args: anytype) void {
677 comptime var i = 0;677 comptime var i = 0;
678 inline while (i < args.len) : (i += 1) {678 inline while (i < args.len) : (i += 1) {
679 const x = args[i];679 const x = args[i];
...@@ -814,17 +814,16 @@ test "two comptime calls with array default initialized to undefined" {...@@ -814,17 +814,16 @@ test "two comptime calls with array default initialized to undefined" {
814 dynamic_linker: DynamicLinker = DynamicLinker{},814 dynamic_linker: DynamicLinker = DynamicLinker{},
815815
816 pub fn parse() void {816 pub fn parse() void {
817 var result: CrossTarget = .{ };817 var result: CrossTarget = .{};
818 result.getCpuArch();818 result.getCpuArch();
819 }819 }
820820
821 pub fn getCpuArch(self: CrossTarget) void { }821 pub fn getCpuArch(self: CrossTarget) void {}
822 };822 };
823823
824 const DynamicLinker = struct {824 const DynamicLinker = struct {
825 buffer: [255]u8 = undefined,825 buffer: [255]u8 = undefined,
826 };826 };
827
828 };827 };
829828
830 comptime {829 comptime {
test/stage1/behavior/fn.zig+3-3
...@@ -104,7 +104,7 @@ test "number literal as an argument" {...@@ -104,7 +104,7 @@ test "number literal as an argument" {
104 comptime numberLiteralArg(3);104 comptime numberLiteralArg(3);
105}105}
106106
107fn numberLiteralArg(a: var) void {107fn numberLiteralArg(a: anytype) void {
108 expect(a == 3);108 expect(a == 3);
109}109}
110110
...@@ -132,7 +132,7 @@ test "pass by non-copying value through var arg" {...@@ -132,7 +132,7 @@ test "pass by non-copying value through var arg" {
132 expect(addPointCoordsVar(Point{ .x = 1, .y = 2 }) == 3);132 expect(addPointCoordsVar(Point{ .x = 1, .y = 2 }) == 3);
133}133}
134134
135fn addPointCoordsVar(pt: var) i32 {135fn addPointCoordsVar(pt: anytype) i32 {
136 comptime expect(@TypeOf(pt) == Point);136 comptime expect(@TypeOf(pt) == Point);
137 return pt.x + pt.y;137 return pt.x + pt.y;
138}138}
...@@ -267,7 +267,7 @@ test "ability to give comptime types and non comptime types to same parameter" {...@@ -267,7 +267,7 @@ test "ability to give comptime types and non comptime types to same parameter" {
267 expect(foo(i32) == 20);267 expect(foo(i32) == 20);
268 }268 }
269269
270 fn foo(arg: var) i32 {270 fn foo(arg: anytype) i32 {
271 if (@typeInfo(@TypeOf(arg)) == .Type and arg == i32) return 20;271 if (@typeInfo(@TypeOf(arg)) == .Type and arg == i32) return 20;
272 return 9 + arg;272 return 9 + arg;
273 }273 }
test/stage1/behavior/generics.zig+4-4
...@@ -47,7 +47,7 @@ comptime {...@@ -47,7 +47,7 @@ comptime {
47 expect(max_f64(1.2, 3.4) == 3.4);47 expect(max_f64(1.2, 3.4) == 3.4);
48}48}
4949
50fn max_var(a: var, b: var) @TypeOf(a + b) {50fn max_var(a: anytype, b: anytype) @TypeOf(a + b) {
51 return if (a > b) a else b;51 return if (a > b) a else b;
52}52}
5353
...@@ -133,15 +133,15 @@ fn getFirstByte(comptime T: type, mem: []const T) u8 {...@@ -133,15 +133,15 @@ fn getFirstByte(comptime T: type, mem: []const T) u8 {
133 return getByte(@ptrCast(*const u8, &mem[0]));133 return getByte(@ptrCast(*const u8, &mem[0]));
134}134}
135135
136const foos = [_]fn (var) bool{136const foos = [_]fn (anytype) bool{
137 foo1,137 foo1,
138 foo2,138 foo2,
139};139};
140140
141fn foo1(arg: var) bool {141fn foo1(arg: anytype) bool {
142 return arg;142 return arg;
143}143}
144fn foo2(arg: var) bool {144fn foo2(arg: anytype) bool {
145 return !arg;145 return !arg;
146}146}
147147
test/stage1/behavior/optional.zig+14-2
...@@ -67,8 +67,20 @@ fn test_cmp_optional_non_optional() void {...@@ -67,8 +67,20 @@ fn test_cmp_optional_non_optional() void {
67 // test evaluation is always lexical67 // test evaluation is always lexical
68 // ensure that the optional isn't always computed before the non-optional68 // ensure that the optional isn't always computed before the non-optional
69 var mutable_state: i32 = 0;69 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); };70 _ = blk1: {
71 _ = blk1: { mutable_state += 1; break :blk1 @as(f64, 10.0); } != blk2: { expect(mutable_state == 2); break :blk2 @as(?f64, 5.0); };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 };
72}84}
7385
74test "passing an optional integer as a parameter" {86test "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" {...@@ -713,7 +713,7 @@ test "packed struct field passed to generic function" {
713 a: u1,713 a: u1,
714 };714 };
715715
716 fn genericReadPackedField(ptr: var) u5 {716 fn genericReadPackedField(ptr: anytype) u5 {
717 return ptr.*;717 return ptr.*;
718 }718 }
719 };719 };
...@@ -754,7 +754,7 @@ test "fully anonymous struct" {...@@ -754,7 +754,7 @@ test "fully anonymous struct" {
754 .s = "hi",754 .s = "hi",
755 });755 });
756 }756 }
757 fn dump(args: var) void {757 fn dump(args: anytype) void {
758 expect(args.int == 1234);758 expect(args.int == 1234);
759 expect(args.float == 12.34);759 expect(args.float == 12.34);
760 expect(args.b);760 expect(args.b);
...@@ -771,7 +771,7 @@ test "fully anonymous list literal" {...@@ -771,7 +771,7 @@ test "fully anonymous list literal" {
771 fn doTheTest() void {771 fn doTheTest() void {
772 dump(.{ @as(u32, 1234), @as(f64, 12.34), true, "hi" });772 dump(.{ @as(u32, 1234), @as(f64, 12.34), true, "hi" });
773 }773 }
774 fn dump(args: var) void {774 fn dump(args: anytype) void {
775 expect(args.@"0" == 1234);775 expect(args.@"0" == 1234);
776 expect(args.@"1" == 12.34);776 expect(args.@"1" == 12.34);
777 expect(args.@"2");777 expect(args.@"2");
...@@ -792,8 +792,8 @@ test "anonymous struct literal assigned to variable" {...@@ -792,8 +792,8 @@ test "anonymous struct literal assigned to variable" {
792792
793test "struct with var field" {793test "struct with var field" {
794 const Point = struct {794 const Point = struct {
795 x: var,795 x: anytype,
796 y: var,796 y: anytype,
797 };797 };
798 const pt = Point{798 const pt = Point{
799 .x = 1,799 .x = 1,
test/stage1/behavior/tuple.zig+2-2
...@@ -42,7 +42,7 @@ test "tuple multiplication" {...@@ -42,7 +42,7 @@ test "tuple multiplication" {
42 comptime S.doTheTest();42 comptime S.doTheTest();
4343
44 const T = struct {44 const T = struct {
45 fn consume_tuple(tuple: var, len: usize) void {45 fn consume_tuple(tuple: anytype, len: usize) void {
46 expect(tuple.len == len);46 expect(tuple.len == len);
47 }47 }
4848
...@@ -82,7 +82,7 @@ test "tuple multiplication" {...@@ -82,7 +82,7 @@ test "tuple multiplication" {
8282
83test "pass tuple to comptime var parameter" {83test "pass tuple to comptime var parameter" {
84 const S = struct {84 const S = struct {
85 fn Foo(comptime args: var) void {85 fn Foo(comptime args: anytype) void {
86 expect(args[0] == 1);86 expect(args[0] == 1);
87 }87 }
8888
test/stage1/behavior/type_info.zig+1-1
...@@ -385,7 +385,7 @@ test "@typeInfo does not force declarations into existence" {...@@ -385,7 +385,7 @@ test "@typeInfo does not force declarations into existence" {
385}385}
386386
387test "defaut value for a var-typed field" {387test "defaut value for a var-typed field" {
388 const S = struct { x: var };388 const S = struct { x: anytype };
389 expect(@typeInfo(S).Struct.fields[0].default_value == null);389 expect(@typeInfo(S).Struct.fields[0].default_value == null);
390}390}
391391
test/stage1/behavior/union.zig+1-1
...@@ -296,7 +296,7 @@ const TaggedUnionWithAVoid = union(enum) {...@@ -296,7 +296,7 @@ const TaggedUnionWithAVoid = union(enum) {
296 B: i32,296 B: i32,
297};297};
298298
299fn testTaggedUnionInit(x: var) bool {299fn testTaggedUnionInit(x: anytype) bool {
300 const y = TaggedUnionWithAVoid{ .A = x };300 const y = TaggedUnionWithAVoid{ .A = x };
301 return @as(@TagType(TaggedUnionWithAVoid), y) == TaggedUnionWithAVoid.A;301 return @as(@TagType(TaggedUnionWithAVoid), y) == TaggedUnionWithAVoid.A;
302}302}
test/stage1/behavior/var_args.zig+8-8
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const expect = @import("std").testing.expect;1const expect = @import("std").testing.expect;
22
3fn add(args: var) i32 {3fn add(args: anytype) i32 {
4 var sum = @as(i32, 0);4 var sum = @as(i32, 0);
5 {5 {
6 comptime var i: usize = 0;6 comptime var i: usize = 0;
...@@ -17,7 +17,7 @@ test "add arbitrary args" {...@@ -17,7 +17,7 @@ test "add arbitrary args" {
17 expect(add(.{}) == 0);17 expect(add(.{}) == 0);
18}18}
1919
20fn readFirstVarArg(args: var) void {20fn readFirstVarArg(args: anytype) void {
21 const value = args[0];21 const value = args[0];
22}22}
2323
...@@ -31,7 +31,7 @@ test "pass args directly" {...@@ -31,7 +31,7 @@ test "pass args directly" {
31 expect(addSomeStuff(.{}) == 0);31 expect(addSomeStuff(.{}) == 0);
32}32}
3333
34fn addSomeStuff(args: var) i32 {34fn addSomeStuff(args: anytype) i32 {
35 return add(args);35 return add(args);
36}36}
3737
...@@ -47,7 +47,7 @@ test "runtime parameter before var args" {...@@ -47,7 +47,7 @@ test "runtime parameter before var args" {
47 }47 }
48}48}
4949
50fn extraFn(extra: u32, args: var) usize {50fn extraFn(extra: u32, args: anytype) usize {
51 if (args.len >= 1) {51 if (args.len >= 1) {
52 expect(args[0] == false);52 expect(args[0] == false);
53 }53 }
...@@ -57,15 +57,15 @@ fn extraFn(extra: u32, args: var) usize {...@@ -57,15 +57,15 @@ fn extraFn(extra: u32, args: var) usize {
57 return args.len;57 return args.len;
58}58}
5959
60const foos = [_]fn (var) bool{60const foos = [_]fn (anytype) bool{
61 foo1,61 foo1,
62 foo2,62 foo2,
63};63};
6464
65fn foo1(args: var) bool {65fn foo1(args: anytype) bool {
66 return true;66 return true;
67}67}
68fn foo2(args: var) bool {68fn foo2(args: anytype) bool {
69 return false;69 return false;
70}70}
7171
...@@ -78,6 +78,6 @@ test "pass zero length array to var args param" {...@@ -78,6 +78,6 @@ test "pass zero length array to var args param" {
78 doNothingWithFirstArg(.{""});78 doNothingWithFirstArg(.{""});
79}79}
8080
81fn doNothingWithFirstArg(args: var) void {81fn doNothingWithFirstArg(args: anytype) void {
82 const a = args[0];82 const a = args[0];
83}83}
test/stage1/behavior/vector.zig+4-4
...@@ -171,7 +171,7 @@ test "load vector elements via comptime index" {...@@ -171,7 +171,7 @@ test "load vector elements via comptime index" {
171 expect(v[1] == 2);171 expect(v[1] == 2);
172 expect(loadv(&v[2]) == 3);172 expect(loadv(&v[2]) == 3);
173 }173 }
174 fn loadv(ptr: var) i32 {174 fn loadv(ptr: anytype) i32 {
175 return ptr.*;175 return ptr.*;
176 }176 }
177 };177 };
...@@ -194,7 +194,7 @@ test "store vector elements via comptime index" {...@@ -194,7 +194,7 @@ test "store vector elements via comptime index" {
194 storev(&v[0], 100);194 storev(&v[0], 100);
195 expect(v[0] == 100);195 expect(v[0] == 100);
196 }196 }
197 fn storev(ptr: var, x: i32) void {197 fn storev(ptr: anytype, x: i32) void {
198 ptr.* = x;198 ptr.* = x;
199 }199 }
200 };200 };
...@@ -392,7 +392,7 @@ test "vector shift operators" {...@@ -392,7 +392,7 @@ test "vector shift operators" {
392 if (builtin.os.tag == .wasi) return error.SkipZigTest;392 if (builtin.os.tag == .wasi) return error.SkipZigTest;
393393
394 const S = struct {394 const S = struct {
395 fn doTheTestShift(x: var, y: var) void {395 fn doTheTestShift(x: anytype, y: anytype) void {
396 const N = @typeInfo(@TypeOf(x)).Array.len;396 const N = @typeInfo(@TypeOf(x)).Array.len;
397 const TX = @typeInfo(@TypeOf(x)).Array.child;397 const TX = @typeInfo(@TypeOf(x)).Array.child;
398 const TY = @typeInfo(@TypeOf(y)).Array.child;398 const TY = @typeInfo(@TypeOf(y)).Array.child;
...@@ -409,7 +409,7 @@ test "vector shift operators" {...@@ -409,7 +409,7 @@ test "vector shift operators" {
409 expectEqual(x[i] << y[i], v);409 expectEqual(x[i] << y[i], v);
410 }410 }
411 }411 }
412 fn doTheTestShiftExact(x: var, y: var, dir: enum { Left, Right }) void {412 fn doTheTestShiftExact(x: anytype, y: anytype, dir: enum { Left, Right }) void {
413 const N = @typeInfo(@TypeOf(x)).Array.len;413 const N = @typeInfo(@TypeOf(x)).Array.len;
414 const TX = @typeInfo(@TypeOf(x)).Array.child;414 const TX = @typeInfo(@TypeOf(x)).Array.child;
415 const TY = @typeInfo(@TypeOf(y)).Array.child;415 const TY = @typeInfo(@TypeOf(y)).Array.child;
test/translate_c.zig+10-10
...@@ -21,7 +21,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -21,7 +21,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
21 cases.add("correct semicolon after infixop",21 cases.add("correct semicolon after infixop",
22 \\#define __ferror_unlocked_body(_fp) (((_fp)->_flags & _IO_ERR_SEEN) != 0)22 \\#define __ferror_unlocked_body(_fp) (((_fp)->_flags & _IO_ERR_SEEN) != 0)
23 , &[_][]const u8{23 , &[_][]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) {
25 \\ return ((_fp.*._flags) & _IO_ERR_SEEN) != 0;25 \\ return ((_fp.*._flags) & _IO_ERR_SEEN) != 0;
26 \\}26 \\}
27 });27 });
...@@ -30,7 +30,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -30,7 +30,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
30 \\#define FOO(x) ((x >= 0) + (x >= 0))30 \\#define FOO(x) ((x >= 0) + (x >= 0))
31 \\#define BAR 1 && 2 > 431 \\#define BAR 1 && 2 > 4
32 , &[_][]const u8{32 , &[_][]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)) {
34 \\ return @boolToInt(x >= 0) + @boolToInt(x >= 0);34 \\ return @boolToInt(x >= 0) + @boolToInt(x >= 0);
35 \\}35 \\}
36 ,36 ,
...@@ -81,7 +81,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -81,7 +81,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
81 \\ break :blk bar;81 \\ break :blk bar;
82 \\};82 \\};
83 ,83 ,
84 \\pub inline fn bar(x: var) @TypeOf(baz(1, 2)) {84 \\pub inline fn bar(x: anytype) @TypeOf(baz(1, 2)) {
85 \\ return blk: {85 \\ return blk: {
86 \\ _ = &x;86 \\ _ = &x;
87 \\ _ = 3;87 \\ _ = 3;
...@@ -1483,11 +1483,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -1483,11 +1483,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
1483 , &[_][]const u8{1483 , &[_][]const u8{
1484 \\pub extern var c: c_int;1484 \\pub extern var c: c_int;
1485 ,1485 ,
1486 \\pub inline fn BASIC(c_1: var) @TypeOf(c_1 * 2) {1486 \\pub inline fn BASIC(c_1: anytype) @TypeOf(c_1 * 2) {
1487 \\ return c_1 * 2;1487 \\ return c_1 * 2;
1488 \\}1488 \\}
1489 ,1489 ,
1490 \\pub inline fn FOO(L: var, b: var) @TypeOf(L + b) {1490 \\pub inline fn FOO(L: anytype, b: anytype) @TypeOf(L + b) {
1491 \\ return L + b;1491 \\ return L + b;
1492 \\}1492 \\}
1493 });1493 });
...@@ -2123,7 +2123,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -2123,7 +2123,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
2123 cases.add("macro call",2123 cases.add("macro call",
2124 \\#define CALL(arg) bar(arg)2124 \\#define CALL(arg) bar(arg)
2125 , &[_][]const u8{2125 , &[_][]const u8{
2126 \\pub inline fn CALL(arg: var) @TypeOf(bar(arg)) {2126 \\pub inline fn CALL(arg: anytype) @TypeOf(bar(arg)) {
2127 \\ return bar(arg);2127 \\ return bar(arg);
2128 \\}2128 \\}
2129 });2129 });
...@@ -2683,7 +2683,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -2683,7 +2683,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
2683 \\#define FOO(bar) baz((void *)(baz))2683 \\#define FOO(bar) baz((void *)(baz))
2684 \\#define BAR (void*) a2684 \\#define BAR (void*) a
2685 , &[_][]const u8{2685 , &[_][]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)))) {
2687 \\ return baz((@import("std").meta.cast(?*c_void, baz)));2687 \\ return baz((@import("std").meta.cast(?*c_void, baz)));
2688 \\}2688 \\}
2689 ,2689 ,
...@@ -2713,11 +2713,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -2713,11 +2713,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
2713 \\#define MIN(a, b) ((b) < (a) ? (b) : (a))2713 \\#define MIN(a, b) ((b) < (a) ? (b) : (a))
2714 \\#define MAX(a, b) ((b) > (a) ? (b) : (a))2714 \\#define MAX(a, b) ((b) > (a) ? (b) : (a))
2715 , &[_][]const u8{2715 , &[_][]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) {
2717 \\ return if (b < a) b else a;2717 \\ return if (b < a) b else a;
2718 \\}2718 \\}
2719 ,2719 ,
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) {
2721 \\ return if (b > a) b else a;2721 \\ return if (b > a) b else a;
2722 \\}2722 \\}
2723 });2723 });
...@@ -2905,7 +2905,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {...@@ -2905,7 +2905,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
2905 \\#define DefaultScreen(dpy) (((_XPrivDisplay)(dpy))->default_screen)2905 \\#define DefaultScreen(dpy) (((_XPrivDisplay)(dpy))->default_screen)
2906 \\2906 \\
2907 , &[_][]const u8{2907 , &[_][]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) {
2909 \\ return (@import("std").meta.cast(_XPrivDisplay, dpy)).*.default_screen;2909 \\ return (@import("std").meta.cast(_XPrivDisplay, dpy)).*.default_screen;
2910 \\}2910 \\}
2911 });2911 });