authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-07-11 14:09:04+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-07-11 20:41:19+03:00
loge85fe13e44b1e2957b9d90e19c171fdfa8cb5505
tree17880994dab9c0033cc139b677711f45a87ca637
parent8110639c7964fcb23c2b715f97ab6caa27506b93
signaturelock-open Commit is signed but in an unrecognized format.

run zig fmt on std lib and self hosted


151 files changed, 534 insertions(+), 527 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 {
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+35-35
...@@ -76,9 +76,9 @@ fn peekIsAlign(comptime fmt: []const u8) bool {...@@ -76,9 +76,9 @@ fn peekIsAlign(comptime fmt: []const u8) bool {
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+7-7
...@@ -93,7 +93,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,...@@ -93,7 +93,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
93 }93 }
9494
95 /// Deserializes data into the type pointed to by `ptr`95 /// Deserializes data into the type pointed to by `ptr`
96 pub fn deserializeInto(self: *Self, ptr: var) !void {96 pub fn deserializeInto(self: *Self, ptr: anytype) !void {
97 const T = @TypeOf(ptr);97 const T = @TypeOf(ptr);
98 comptime assert(trait.is(.Pointer)(T));98 comptime assert(trait.is(.Pointer)(T));
9999
...@@ -190,7 +190,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,...@@ -190,7 +190,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
190pub fn deserializer(190pub fn deserializer(
191 comptime endian: builtin.Endian,191 comptime endian: builtin.Endian,
192 comptime packing: Packing,192 comptime packing: Packing,
193 in_stream: var,193 in_stream: anytype,
194) Deserializer(endian, packing, @TypeOf(in_stream)) {194) Deserializer(endian, packing, @TypeOf(in_stream)) {
195 return Deserializer(endian, packing, @TypeOf(in_stream)).init(in_stream);195 return Deserializer(endian, packing, @TypeOf(in_stream)).init(in_stream);
196}196}
...@@ -229,7 +229,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co...@@ -229,7 +229,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
229 if (packing == .Bit) return self.out_stream.flushBits();229 if (packing == .Bit) return self.out_stream.flushBits();
230 }230 }
231231
232 fn serializeInt(self: *Self, value: var) Error!void {232 fn serializeInt(self: *Self, value: anytype) Error!void {
233 const T = @TypeOf(value);233 const T = @TypeOf(value);
234 comptime assert(trait.is(.Int)(T) or trait.is(.Float)(T));234 comptime assert(trait.is(.Int)(T) or trait.is(.Float)(T));
235235
...@@ -261,7 +261,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co...@@ -261,7 +261,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
261 }261 }
262262
263 /// Serializes the passed value into the stream263 /// Serializes the passed value into the stream
264 pub fn serialize(self: *Self, value: var) Error!void {264 pub fn serialize(self: *Self, value: anytype) Error!void {
265 const T = comptime @TypeOf(value);265 const T = comptime @TypeOf(value);
266266
267 if (comptime trait.isIndexable(T)) {267 if (comptime trait.isIndexable(T)) {
...@@ -346,7 +346,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co...@@ -346,7 +346,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
346pub fn serializer(346pub fn serializer(
347 comptime endian: builtin.Endian,347 comptime endian: builtin.Endian,
348 comptime packing: Packing,348 comptime packing: Packing,
349 out_stream: var,349 out_stream: anytype,
350) Serializer(endian, packing, @TypeOf(out_stream)) {350) Serializer(endian, packing, @TypeOf(out_stream)) {
351 return Serializer(endian, packing, @TypeOf(out_stream)).init(out_stream);351 return Serializer(endian, packing, @TypeOf(out_stream)).init(out_stream);
352}352}
...@@ -462,7 +462,7 @@ test "Serializer/Deserializer Int: Inf/NaN" {...@@ -462,7 +462,7 @@ test "Serializer/Deserializer Int: Inf/NaN" {
462 try testIntSerializerDeserializerInfNaN(.Little, .Bit);462 try testIntSerializerDeserializerInfNaN(.Little, .Bit);
463}463}
464464
465fn testAlternateSerializer(self: var, _serializer: var) !void {465fn testAlternateSerializer(self: anytype, _serializer: anytype) !void {
466 try _serializer.serialize(self.f_f16);466 try _serializer.serialize(self.f_f16);
467}467}
468468
...@@ -503,7 +503,7 @@ fn testSerializerDeserializer(comptime endian: builtin.Endian, comptime packing:...@@ -503,7 +503,7 @@ fn testSerializerDeserializer(comptime endian: builtin.Endian, comptime packing:
503 f_f16: f16,503 f_f16: f16,
504 f_unused_u32: u32,504 f_unused_u32: u32,
505505
506 pub fn deserialize(self: *@This(), _deserializer: var) !void {506 pub fn deserialize(self: *@This(), _deserializer: anytype) !void {
507 try _deserializer.deserializeInto(&self.f_f16);507 try _deserializer.deserializeInto(&self.f_f16);
508 self.f_unused_u32 = 47;508 self.f_unused_u32 = 47;
509 }509 }
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+9-9
...@@ -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())});
...@@ -1189,7 +1182,7 @@ pub const Target = struct {...@@ -1189,7 +1182,7 @@ pub const Target = struct {
1189 pub fn standardDynamicLinkerPath(self: Target) DynamicLinker {1182 pub fn standardDynamicLinkerPath(self: Target) DynamicLinker {
1190 var result: DynamicLinker = .{};1183 var result: DynamicLinker = .{};
1191 const S = struct {1184 const S = struct {
1192 fn print(r: *DynamicLinker, comptime fmt: []const u8, args: var) DynamicLinker {1185 fn print(r: *DynamicLinker, comptime fmt: []const u8, args: anytype) DynamicLinker {
1193 r.max_byte = @intCast(u8, (std.fmt.bufPrint(&r.buffer, fmt, args) catch unreachable).len - 1);1186 r.max_byte = @intCast(u8, (std.fmt.bufPrint(&r.buffer, fmt, args) catch unreachable).len - 1);
1194 return r.*;1187 return r.*;
1195 }1188 }
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+8-8
...@@ -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 };
lib/std/zig/parse.zig+1-1
...@@ -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);
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);
src-self-hosted/Module.zig+5-5
...@@ -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+9-9
...@@ -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);
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,
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;