| author | |
| committer | |
| log | fe08a4d0654b4d73b78f65cf1a31a037002e2243 |
| tree | b762e87c5191c1d3c1231c5baf3eee73351e3452 |
| parent | 2dcb70a6befc2cc0a8f46a7e64cde534d37f6f3e |
| parent | be1507a7afe4c8869abdbab67a32ede6afe3d938 |
| signature |
Rename 'var' type to 'anytype'166 files changed, 792 insertions(+), 746 deletions(-)
build.zig+4-4| ... | ... | @@ -153,7 +153,7 @@ pub fn build(b: *Builder) !void { |
| 153 | 153 | test_step.dependOn(docs_step); |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | fn dependOnLib(b: *Builder, lib_exe_obj: var, dep: LibraryDep) void { | |
| 156 | fn dependOnLib(b: *Builder, lib_exe_obj: anytype, dep: LibraryDep) void { | |
| 157 | 157 | for (dep.libdirs.items) |lib_dir| { |
| 158 | 158 | lib_exe_obj.addLibPath(lib_dir); |
| 159 | 159 | } |
| ... | ... | @@ -193,7 +193,7 @@ fn fileExists(filename: []const u8) !bool { |
| 193 | 193 | return true; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | fn addCppLib(b: *Builder, lib_exe_obj: var, cmake_binary_dir: []const u8, lib_name: []const u8) void { | |
| 196 | fn addCppLib(b: *Builder, lib_exe_obj: anytype, cmake_binary_dir: []const u8, lib_name: []const u8) void { | |
| 197 | 197 | lib_exe_obj.addObjectFile(fs.path.join(b.allocator, &[_][]const u8{ |
| 198 | 198 | cmake_binary_dir, |
| 199 | 199 | "zig_cpp", |
| ... | ... | @@ -275,7 +275,7 @@ fn findLLVM(b: *Builder, llvm_config_exe: []const u8) !LibraryDep { |
| 275 | 275 | return result; |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | fn configureStage2(b: *Builder, exe: var, ctx: Context) !void { | |
| 278 | fn configureStage2(b: *Builder, exe: anytype, ctx: Context) !void { | |
| 279 | 279 | exe.addIncludeDir("src"); |
| 280 | 280 | exe.addIncludeDir(ctx.cmake_binary_dir); |
| 281 | 281 | addCppLib(b, exe, ctx.cmake_binary_dir, "zig_cpp"); |
| ... | ... | @@ -340,7 +340,7 @@ fn configureStage2(b: *Builder, exe: var, ctx: Context) !void { |
| 340 | 340 | fn addCxxKnownPath( |
| 341 | 341 | b: *Builder, |
| 342 | 342 | ctx: Context, |
| 343 | exe: var, | |
| 343 | exe: anytype, | |
| 344 | 344 | objname: []const u8, |
| 345 | 345 | errtxt: ?[]const u8, |
| 346 | 346 | ) !void { |
doc/docgen.zig+6-5| ... | ... | @@ -212,7 +212,7 @@ const Tokenizer = struct { |
| 212 | 212 | } |
| 213 | 213 | }; |
| 214 | 214 | |
| 215 | fn parseError(tokenizer: *Tokenizer, token: Token, comptime fmt: []const u8, args: var) anyerror { | |
| 215 | fn parseError(tokenizer: *Tokenizer, token: Token, comptime fmt: []const u8, args: anytype) anyerror { | |
| 216 | 216 | const loc = tokenizer.getTokenLocation(token); |
| 217 | 217 | const args_prefix = .{ tokenizer.source_file_name, loc.line + 1, loc.column + 1 }; |
| 218 | 218 | warn("{}:{}:{}: error: " ++ fmt ++ "\n", args_prefix ++ args); |
| ... | ... | @@ -634,7 +634,7 @@ fn escapeHtml(allocator: *mem.Allocator, input: []const u8) ![]u8 { |
| 634 | 634 | return buf.toOwnedSlice(); |
| 635 | 635 | } |
| 636 | 636 | |
| 637 | fn writeEscaped(out: var, input: []const u8) !void { | |
| 637 | fn writeEscaped(out: anytype, input: []const u8) !void { | |
| 638 | 638 | for (input) |c| { |
| 639 | 639 | try switch (c) { |
| 640 | 640 | '&' => out.writeAll("&"), |
| ... | ... | @@ -765,7 +765,7 @@ fn isType(name: []const u8) bool { |
| 765 | 765 | return false; |
| 766 | 766 | } |
| 767 | 767 | |
| 768 | fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Token, raw_src: []const u8) !void { | |
| 768 | fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: anytype, source_token: Token, raw_src: []const u8) !void { | |
| 769 | 769 | const src = mem.trim(u8, raw_src, " \n"); |
| 770 | 770 | try out.writeAll("<code class=\"zig\">"); |
| 771 | 771 | var tokenizer = std.zig.Tokenizer.init(src); |
| ... | ... | @@ -825,6 +825,7 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok |
| 825 | 825 | .Keyword_volatile, |
| 826 | 826 | .Keyword_allowzero, |
| 827 | 827 | .Keyword_while, |
| 828 | .Keyword_anytype, | |
| 828 | 829 | => { |
| 829 | 830 | try out.writeAll("<span class=\"tok-kw\">"); |
| 830 | 831 | try writeEscaped(out, src[token.loc.start..token.loc.end]); |
| ... | ... | @@ -977,12 +978,12 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok |
| 977 | 978 | try out.writeAll("</code>"); |
| 978 | 979 | } |
| 979 | 980 | |
| 980 | fn tokenizeAndPrint(docgen_tokenizer: *Tokenizer, out: var, source_token: Token) !void { | |
| 981 | fn tokenizeAndPrint(docgen_tokenizer: *Tokenizer, out: anytype, source_token: Token) !void { | |
| 981 | 982 | const raw_src = docgen_tokenizer.buffer[source_token.start..source_token.end]; |
| 982 | 983 | return tokenizeAndPrintRaw(docgen_tokenizer, out, source_token, raw_src); |
| 983 | 984 | } |
| 984 | 985 | |
| 985 | fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var, zig_exe: []const u8) !void { | |
| 986 | fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: anytype, zig_exe: []const u8) !void { | |
| 986 | 987 | var code_progress_index: usize = 0; |
| 987 | 988 | |
| 988 | 989 | var env_map = try process.getEnvMap(allocator); |
doc/langref.html.in+44-43| ... | ... | @@ -1785,7 +1785,7 @@ test "fully anonymous list literal" { |
| 1785 | 1785 | dump(.{ @as(u32, 1234), @as(f64, 12.34), true, "hi"}); |
| 1786 | 1786 | } |
| 1787 | 1787 | |
| 1788 | fn dump(args: var) void { | |
| 1788 | fn dump(args: anytype) void { | |
| 1789 | 1789 | assert(args.@"0" == 1234); |
| 1790 | 1790 | assert(args.@"1" == 12.34); |
| 1791 | 1791 | assert(args.@"2"); |
| ... | ... | @@ -2717,7 +2717,7 @@ test "fully anonymous struct" { |
| 2717 | 2717 | }); |
| 2718 | 2718 | } |
| 2719 | 2719 | |
| 2720 | fn dump(args: var) void { | |
| 2720 | fn dump(args: anytype) void { | |
| 2721 | 2721 | assert(args.int == 1234); |
| 2722 | 2722 | assert(args.float == 12.34); |
| 2723 | 2723 | assert(args.b); |
| ... | ... | @@ -4181,14 +4181,14 @@ test "pass struct to function" { |
| 4181 | 4181 | {#header_close#} |
| 4182 | 4182 | {#header_open|Function Parameter Type Inference#} |
| 4183 | 4183 | <p> |
| 4184 | Function parameters can be declared with {#syntax#}var{#endsyntax#} in place of the type. | |
| 4184 | Function parameters can be declared with {#syntax#}anytype{#endsyntax#} in place of the type. | |
| 4185 | 4185 | In this case the parameter types will be inferred when the function is called. |
| 4186 | 4186 | Use {#link|@TypeOf#} and {#link|@typeInfo#} to get information about the inferred type. |
| 4187 | 4187 | </p> |
| 4188 | 4188 | {#code_begin|test#} |
| 4189 | 4189 | const assert = @import("std").debug.assert; |
| 4190 | 4190 | |
| 4191 | fn addFortyTwo(x: var) @TypeOf(x) { | |
| 4191 | fn addFortyTwo(x: anytype) @TypeOf(x) { | |
| 4192 | 4192 | return x + 42; |
| 4193 | 4193 | } |
| 4194 | 4194 | |
| ... | ... | @@ -5974,7 +5974,7 @@ pub fn main() void { |
| 5974 | 5974 | |
| 5975 | 5975 | {#code_begin|syntax#} |
| 5976 | 5976 | /// Calls print and then flushes the buffer. |
| 5977 | pub fn printf(self: *OutStream, comptime format: []const u8, args: var) anyerror!void { | |
| 5977 | pub fn printf(self: *OutStream, comptime format: []const u8, args: anytype) anyerror!void { | |
| 5978 | 5978 | const State = enum { |
| 5979 | 5979 | Start, |
| 5980 | 5980 | OpenBrace, |
| ... | ... | @@ -6060,7 +6060,7 @@ pub fn printf(self: *OutStream, arg0: i32, arg1: []const u8) !void { |
| 6060 | 6060 | on the type: |
| 6061 | 6061 | </p> |
| 6062 | 6062 | {#code_begin|syntax#} |
| 6063 | pub fn printValue(self: *OutStream, value: var) !void { | |
| 6063 | pub fn printValue(self: *OutStream, value: anytype) !void { | |
| 6064 | 6064 | switch (@typeInfo(@TypeOf(value))) { |
| 6065 | 6065 | .Int => { |
| 6066 | 6066 | return self.printInt(T, value); |
| ... | ... | @@ -6686,7 +6686,7 @@ fn readFile(allocator: *Allocator, filename: []const u8) ![]u8 { |
| 6686 | 6686 | </p> |
| 6687 | 6687 | {#header_close#} |
| 6688 | 6688 | {#header_open|@alignCast#} |
| 6689 | <pre>{#syntax#}@alignCast(comptime alignment: u29, ptr: var) var{#endsyntax#}</pre> | |
| 6689 | <pre>{#syntax#}@alignCast(comptime alignment: u29, ptr: anytype) anytype{#endsyntax#}</pre> | |
| 6690 | 6690 | <p> |
| 6691 | 6691 | {#syntax#}ptr{#endsyntax#} can be {#syntax#}*T{#endsyntax#}, {#syntax#}fn(){#endsyntax#}, {#syntax#}?*T{#endsyntax#}, |
| 6692 | 6692 | {#syntax#}?fn(){#endsyntax#}, or {#syntax#}[]T{#endsyntax#}. It returns the same type as {#syntax#}ptr{#endsyntax#} |
| ... | ... | @@ -6723,7 +6723,7 @@ comptime { |
| 6723 | 6723 | {#header_close#} |
| 6724 | 6724 | |
| 6725 | 6725 | {#header_open|@asyncCall#} |
| 6726 | <pre>{#syntax#}@asyncCall(frame_buffer: []align(@alignOf(@Frame(anyAsyncFunction))) u8, result_ptr, function_ptr, args: var) anyframe->T{#endsyntax#}</pre> | |
| 6726 | <pre>{#syntax#}@asyncCall(frame_buffer: []align(@alignOf(@Frame(anyAsyncFunction))) u8, result_ptr, function_ptr, args: anytype) anyframe->T{#endsyntax#}</pre> | |
| 6727 | 6727 | <p> |
| 6728 | 6728 | {#syntax#}@asyncCall{#endsyntax#} performs an {#syntax#}async{#endsyntax#} call on a function pointer, |
| 6729 | 6729 | which may or may not be an {#link|async function|Async Functions#}. |
| ... | ... | @@ -6811,7 +6811,7 @@ fn func(y: *i32) void { |
| 6811 | 6811 | </p> |
| 6812 | 6812 | {#header_close#} |
| 6813 | 6813 | {#header_open|@bitCast#} |
| 6814 | <pre>{#syntax#}@bitCast(comptime DestType: type, value: var) DestType{#endsyntax#}</pre> | |
| 6814 | <pre>{#syntax#}@bitCast(comptime DestType: type, value: anytype) DestType{#endsyntax#}</pre> | |
| 6815 | 6815 | <p> |
| 6816 | 6816 | Converts a value of one type to another type. |
| 6817 | 6817 | </p> |
| ... | ... | @@ -6932,7 +6932,7 @@ fn func(y: *i32) void { |
| 6932 | 6932 | {#header_close#} |
| 6933 | 6933 | |
| 6934 | 6934 | {#header_open|@call#} |
| 6935 | <pre>{#syntax#}@call(options: std.builtin.CallOptions, function: var, args: var) var{#endsyntax#}</pre> | |
| 6935 | <pre>{#syntax#}@call(options: std.builtin.CallOptions, function: anytype, args: anytype) anytype{#endsyntax#}</pre> | |
| 6936 | 6936 | <p> |
| 6937 | 6937 | Calls a function, in the same way that invoking an expression with parentheses does: |
| 6938 | 6938 | </p> |
| ... | ... | @@ -7279,7 +7279,7 @@ test "main" { |
| 7279 | 7279 | {#header_close#} |
| 7280 | 7280 | |
| 7281 | 7281 | {#header_open|@enumToInt#} |
| 7282 | <pre>{#syntax#}@enumToInt(enum_or_tagged_union: var) var{#endsyntax#}</pre> | |
| 7282 | <pre>{#syntax#}@enumToInt(enum_or_tagged_union: anytype) anytype{#endsyntax#}</pre> | |
| 7283 | 7283 | <p> |
| 7284 | 7284 | Converts an enumeration value into its integer tag type. When a tagged union is passed, |
| 7285 | 7285 | the tag value is used as the enumeration value. |
| ... | ... | @@ -7314,7 +7314,7 @@ test "main" { |
| 7314 | 7314 | {#header_close#} |
| 7315 | 7315 | |
| 7316 | 7316 | {#header_open|@errorToInt#} |
| 7317 | <pre>{#syntax#}@errorToInt(err: var) std.meta.IntType(false, @sizeOf(anyerror) * 8){#endsyntax#}</pre> | |
| 7317 | <pre>{#syntax#}@errorToInt(err: anytype) std.meta.IntType(false, @sizeOf(anyerror) * 8){#endsyntax#}</pre> | |
| 7318 | 7318 | <p> |
| 7319 | 7319 | Supports the following types: |
| 7320 | 7320 | </p> |
| ... | ... | @@ -7334,7 +7334,7 @@ test "main" { |
| 7334 | 7334 | {#header_close#} |
| 7335 | 7335 | |
| 7336 | 7336 | {#header_open|@errSetCast#} |
| 7337 | <pre>{#syntax#}@errSetCast(comptime T: DestType, value: var) DestType{#endsyntax#}</pre> | |
| 7337 | <pre>{#syntax#}@errSetCast(comptime T: DestType, value: anytype) DestType{#endsyntax#}</pre> | |
| 7338 | 7338 | <p> |
| 7339 | 7339 | Converts an error value from one error set to another error set. Attempting to convert an error |
| 7340 | 7340 | which is not in the destination error set results in safety-protected {#link|Undefined Behavior#}. |
| ... | ... | @@ -7342,7 +7342,7 @@ test "main" { |
| 7342 | 7342 | {#header_close#} |
| 7343 | 7343 | |
| 7344 | 7344 | {#header_open|@export#} |
| 7345 | <pre>{#syntax#}@export(target: var, comptime options: std.builtin.ExportOptions) void{#endsyntax#}</pre> | |
| 7345 | <pre>{#syntax#}@export(target: anytype, comptime options: std.builtin.ExportOptions) void{#endsyntax#}</pre> | |
| 7346 | 7346 | <p> |
| 7347 | 7347 | Creates a symbol in the output object file. |
| 7348 | 7348 | </p> |
| ... | ... | @@ -7387,7 +7387,7 @@ export fn @"A function name that is a complete sentence."() void {} |
| 7387 | 7387 | {#header_close#} |
| 7388 | 7388 | |
| 7389 | 7389 | {#header_open|@field#} |
| 7390 | <pre>{#syntax#}@field(lhs: var, comptime field_name: []const u8) (field){#endsyntax#}</pre> | |
| 7390 | <pre>{#syntax#}@field(lhs: anytype, comptime field_name: []const u8) (field){#endsyntax#}</pre> | |
| 7391 | 7391 | <p>Performs field access by a compile-time string. |
| 7392 | 7392 | </p> |
| 7393 | 7393 | {#code_begin|test#} |
| ... | ... | @@ -7421,7 +7421,7 @@ test "field access by string" { |
| 7421 | 7421 | {#header_close#} |
| 7422 | 7422 | |
| 7423 | 7423 | {#header_open|@floatCast#} |
| 7424 | <pre>{#syntax#}@floatCast(comptime DestType: type, value: var) DestType{#endsyntax#}</pre> | |
| 7424 | <pre>{#syntax#}@floatCast(comptime DestType: type, value: anytype) DestType{#endsyntax#}</pre> | |
| 7425 | 7425 | <p> |
| 7426 | 7426 | Convert from one float type to another. This cast is safe, but may cause the |
| 7427 | 7427 | numeric value to lose precision. |
| ... | ... | @@ -7429,7 +7429,7 @@ test "field access by string" { |
| 7429 | 7429 | {#header_close#} |
| 7430 | 7430 | |
| 7431 | 7431 | {#header_open|@floatToInt#} |
| 7432 | <pre>{#syntax#}@floatToInt(comptime DestType: type, float: var) DestType{#endsyntax#}</pre> | |
| 7432 | <pre>{#syntax#}@floatToInt(comptime DestType: type, float: anytype) DestType{#endsyntax#}</pre> | |
| 7433 | 7433 | <p> |
| 7434 | 7434 | Converts the integer part of a floating point number to the destination type. |
| 7435 | 7435 | </p> |
| ... | ... | @@ -7455,7 +7455,7 @@ test "field access by string" { |
| 7455 | 7455 | {#header_close#} |
| 7456 | 7456 | |
| 7457 | 7457 | {#header_open|@Frame#} |
| 7458 | <pre>{#syntax#}@Frame(func: var) type{#endsyntax#}</pre> | |
| 7458 | <pre>{#syntax#}@Frame(func: anytype) type{#endsyntax#}</pre> | |
| 7459 | 7459 | <p> |
| 7460 | 7460 | This function returns the frame type of a function. This works for {#link|Async Functions#} |
| 7461 | 7461 | as well as any function without a specific calling convention. |
| ... | ... | @@ -7581,7 +7581,7 @@ test "@hasDecl" { |
| 7581 | 7581 | {#header_close#} |
| 7582 | 7582 | |
| 7583 | 7583 | {#header_open|@intCast#} |
| 7584 | <pre>{#syntax#}@intCast(comptime DestType: type, int: var) DestType{#endsyntax#}</pre> | |
| 7584 | <pre>{#syntax#}@intCast(comptime DestType: type, int: anytype) DestType{#endsyntax#}</pre> | |
| 7585 | 7585 | <p> |
| 7586 | 7586 | Converts an integer to another integer while keeping the same numerical value. |
| 7587 | 7587 | Attempting to convert a number which is out of range of the destination type results in |
| ... | ... | @@ -7622,7 +7622,7 @@ test "@hasDecl" { |
| 7622 | 7622 | {#header_close#} |
| 7623 | 7623 | |
| 7624 | 7624 | {#header_open|@intToFloat#} |
| 7625 | <pre>{#syntax#}@intToFloat(comptime DestType: type, int: var) DestType{#endsyntax#}</pre> | |
| 7625 | <pre>{#syntax#}@intToFloat(comptime DestType: type, int: anytype) DestType{#endsyntax#}</pre> | |
| 7626 | 7626 | <p> |
| 7627 | 7627 | Converts an integer to the closest floating point representation. To convert the other way, use {#link|@floatToInt#}. This cast is always safe. |
| 7628 | 7628 | </p> |
| ... | ... | @@ -7773,7 +7773,7 @@ test "@wasmMemoryGrow" { |
| 7773 | 7773 | {#header_close#} |
| 7774 | 7774 | |
| 7775 | 7775 | {#header_open|@ptrCast#} |
| 7776 | <pre>{#syntax#}@ptrCast(comptime DestType: type, value: var) DestType{#endsyntax#}</pre> | |
| 7776 | <pre>{#syntax#}@ptrCast(comptime DestType: type, value: anytype) DestType{#endsyntax#}</pre> | |
| 7777 | 7777 | <p> |
| 7778 | 7778 | Converts a pointer of one type to a pointer of another type. |
| 7779 | 7779 | </p> |
| ... | ... | @@ -7784,7 +7784,7 @@ test "@wasmMemoryGrow" { |
| 7784 | 7784 | {#header_close#} |
| 7785 | 7785 | |
| 7786 | 7786 | {#header_open|@ptrToInt#} |
| 7787 | <pre>{#syntax#}@ptrToInt(value: var) usize{#endsyntax#}</pre> | |
| 7787 | <pre>{#syntax#}@ptrToInt(value: anytype) usize{#endsyntax#}</pre> | |
| 7788 | 7788 | <p> |
| 7789 | 7789 | Converts {#syntax#}value{#endsyntax#} to a {#syntax#}usize{#endsyntax#} which is the address of the pointer. {#syntax#}value{#endsyntax#} can be one of these types: |
| 7790 | 7790 | </p> |
| ... | ... | @@ -8042,7 +8042,7 @@ test "@setRuntimeSafety" { |
| 8042 | 8042 | {#header_close#} |
| 8043 | 8043 | |
| 8044 | 8044 | {#header_open|@splat#} |
| 8045 | <pre>{#syntax#}@splat(comptime len: u32, scalar: var) std.meta.Vector(len, @TypeOf(scalar)){#endsyntax#}</pre> | |
| 8045 | <pre>{#syntax#}@splat(comptime len: u32, scalar: anytype) std.meta.Vector(len, @TypeOf(scalar)){#endsyntax#}</pre> | |
| 8046 | 8046 | <p> |
| 8047 | 8047 | Produces a vector of length {#syntax#}len{#endsyntax#} where each element is the value |
| 8048 | 8048 | {#syntax#}scalar{#endsyntax#}: |
| ... | ... | @@ -8088,7 +8088,7 @@ fn doTheTest() void { |
| 8088 | 8088 | {#code_end#} |
| 8089 | 8089 | {#header_close#} |
| 8090 | 8090 | {#header_open|@sqrt#} |
| 8091 | <pre>{#syntax#}@sqrt(value: var) @TypeOf(value){#endsyntax#}</pre> | |
| 8091 | <pre>{#syntax#}@sqrt(value: anytype) @TypeOf(value){#endsyntax#}</pre> | |
| 8092 | 8092 | <p> |
| 8093 | 8093 | Performs the square root of a floating point number. Uses a dedicated hardware instruction |
| 8094 | 8094 | when available. |
| ... | ... | @@ -8099,7 +8099,7 @@ fn doTheTest() void { |
| 8099 | 8099 | </p> |
| 8100 | 8100 | {#header_close#} |
| 8101 | 8101 | {#header_open|@sin#} |
| 8102 | <pre>{#syntax#}@sin(value: var) @TypeOf(value){#endsyntax#}</pre> | |
| 8102 | <pre>{#syntax#}@sin(value: anytype) @TypeOf(value){#endsyntax#}</pre> | |
| 8103 | 8103 | <p> |
| 8104 | 8104 | Sine trigometric function on a floating point number. Uses a dedicated hardware instruction |
| 8105 | 8105 | when available. |
| ... | ... | @@ -8110,7 +8110,7 @@ fn doTheTest() void { |
| 8110 | 8110 | </p> |
| 8111 | 8111 | {#header_close#} |
| 8112 | 8112 | {#header_open|@cos#} |
| 8113 | <pre>{#syntax#}@cos(value: var) @TypeOf(value){#endsyntax#}</pre> | |
| 8113 | <pre>{#syntax#}@cos(value: anytype) @TypeOf(value){#endsyntax#}</pre> | |
| 8114 | 8114 | <p> |
| 8115 | 8115 | Cosine trigometric function on a floating point number. Uses a dedicated hardware instruction |
| 8116 | 8116 | when available. |
| ... | ... | @@ -8121,7 +8121,7 @@ fn doTheTest() void { |
| 8121 | 8121 | </p> |
| 8122 | 8122 | {#header_close#} |
| 8123 | 8123 | {#header_open|@exp#} |
| 8124 | <pre>{#syntax#}@exp(value: var) @TypeOf(value){#endsyntax#}</pre> | |
| 8124 | <pre>{#syntax#}@exp(value: anytype) @TypeOf(value){#endsyntax#}</pre> | |
| 8125 | 8125 | <p> |
| 8126 | 8126 | Base-e exponential function on a floating point number. Uses a dedicated hardware instruction |
| 8127 | 8127 | when available. |
| ... | ... | @@ -8132,7 +8132,7 @@ fn doTheTest() void { |
| 8132 | 8132 | </p> |
| 8133 | 8133 | {#header_close#} |
| 8134 | 8134 | {#header_open|@exp2#} |
| 8135 | <pre>{#syntax#}@exp2(value: var) @TypeOf(value){#endsyntax#}</pre> | |
| 8135 | <pre>{#syntax#}@exp2(value: anytype) @TypeOf(value){#endsyntax#}</pre> | |
| 8136 | 8136 | <p> |
| 8137 | 8137 | Base-2 exponential function on a floating point number. Uses a dedicated hardware instruction |
| 8138 | 8138 | when available. |
| ... | ... | @@ -8143,7 +8143,7 @@ fn doTheTest() void { |
| 8143 | 8143 | </p> |
| 8144 | 8144 | {#header_close#} |
| 8145 | 8145 | {#header_open|@log#} |
| 8146 | <pre>{#syntax#}@log(value: var) @TypeOf(value){#endsyntax#}</pre> | |
| 8146 | <pre>{#syntax#}@log(value: anytype) @TypeOf(value){#endsyntax#}</pre> | |
| 8147 | 8147 | <p> |
| 8148 | 8148 | Returns the natural logarithm of a floating point number. Uses a dedicated hardware instruction |
| 8149 | 8149 | when available. |
| ... | ... | @@ -8154,7 +8154,7 @@ fn doTheTest() void { |
| 8154 | 8154 | </p> |
| 8155 | 8155 | {#header_close#} |
| 8156 | 8156 | {#header_open|@log2#} |
| 8157 | <pre>{#syntax#}@log2(value: var) @TypeOf(value){#endsyntax#}</pre> | |
| 8157 | <pre>{#syntax#}@log2(value: anytype) @TypeOf(value){#endsyntax#}</pre> | |
| 8158 | 8158 | <p> |
| 8159 | 8159 | Returns the logarithm to the base 2 of a floating point number. Uses a dedicated hardware instruction |
| 8160 | 8160 | when available. |
| ... | ... | @@ -8165,7 +8165,7 @@ fn doTheTest() void { |
| 8165 | 8165 | </p> |
| 8166 | 8166 | {#header_close#} |
| 8167 | 8167 | {#header_open|@log10#} |
| 8168 | <pre>{#syntax#}@log10(value: var) @TypeOf(value){#endsyntax#}</pre> | |
| 8168 | <pre>{#syntax#}@log10(value: anytype) @TypeOf(value){#endsyntax#}</pre> | |
| 8169 | 8169 | <p> |
| 8170 | 8170 | Returns the logarithm to the base 10 of a floating point number. Uses a dedicated hardware instruction |
| 8171 | 8171 | when available. |
| ... | ... | @@ -8176,7 +8176,7 @@ fn doTheTest() void { |
| 8176 | 8176 | </p> |
| 8177 | 8177 | {#header_close#} |
| 8178 | 8178 | {#header_open|@fabs#} |
| 8179 | <pre>{#syntax#}@fabs(value: var) @TypeOf(value){#endsyntax#}</pre> | |
| 8179 | <pre>{#syntax#}@fabs(value: anytype) @TypeOf(value){#endsyntax#}</pre> | |
| 8180 | 8180 | <p> |
| 8181 | 8181 | Returns the absolute value of a floating point number. Uses a dedicated hardware instruction |
| 8182 | 8182 | when available. |
| ... | ... | @@ -8187,7 +8187,7 @@ fn doTheTest() void { |
| 8187 | 8187 | </p> |
| 8188 | 8188 | {#header_close#} |
| 8189 | 8189 | {#header_open|@floor#} |
| 8190 | <pre>{#syntax#}@floor(value: var) @TypeOf(value){#endsyntax#}</pre> | |
| 8190 | <pre>{#syntax#}@floor(value: anytype) @TypeOf(value){#endsyntax#}</pre> | |
| 8191 | 8191 | <p> |
| 8192 | 8192 | Returns the largest integral value not greater than the given floating point number. |
| 8193 | 8193 | Uses a dedicated hardware instruction when available. |
| ... | ... | @@ -8198,7 +8198,7 @@ fn doTheTest() void { |
| 8198 | 8198 | </p> |
| 8199 | 8199 | {#header_close#} |
| 8200 | 8200 | {#header_open|@ceil#} |
| 8201 | <pre>{#syntax#}@ceil(value: var) @TypeOf(value){#endsyntax#}</pre> | |
| 8201 | <pre>{#syntax#}@ceil(value: anytype) @TypeOf(value){#endsyntax#}</pre> | |
| 8202 | 8202 | <p> |
| 8203 | 8203 | Returns the largest integral value not less than the given floating point number. |
| 8204 | 8204 | Uses a dedicated hardware instruction when available. |
| ... | ... | @@ -8209,7 +8209,7 @@ fn doTheTest() void { |
| 8209 | 8209 | </p> |
| 8210 | 8210 | {#header_close#} |
| 8211 | 8211 | {#header_open|@trunc#} |
| 8212 | <pre>{#syntax#}@trunc(value: var) @TypeOf(value){#endsyntax#}</pre> | |
| 8212 | <pre>{#syntax#}@trunc(value: anytype) @TypeOf(value){#endsyntax#}</pre> | |
| 8213 | 8213 | <p> |
| 8214 | 8214 | Rounds the given floating point number to an integer, towards zero. |
| 8215 | 8215 | Uses a dedicated hardware instruction when available. |
| ... | ... | @@ -8220,7 +8220,7 @@ fn doTheTest() void { |
| 8220 | 8220 | </p> |
| 8221 | 8221 | {#header_close#} |
| 8222 | 8222 | {#header_open|@round#} |
| 8223 | <pre>{#syntax#}@round(value: var) @TypeOf(value){#endsyntax#}</pre> | |
| 8223 | <pre>{#syntax#}@round(value: anytype) @TypeOf(value){#endsyntax#}</pre> | |
| 8224 | 8224 | <p> |
| 8225 | 8225 | Rounds the given floating point number to an integer, away from zero. Uses a dedicated hardware instruction |
| 8226 | 8226 | when available. |
| ... | ... | @@ -8241,7 +8241,7 @@ fn doTheTest() void { |
| 8241 | 8241 | {#header_close#} |
| 8242 | 8242 | |
| 8243 | 8243 | {#header_open|@tagName#} |
| 8244 | <pre>{#syntax#}@tagName(value: var) []const u8{#endsyntax#}</pre> | |
| 8244 | <pre>{#syntax#}@tagName(value: anytype) []const u8{#endsyntax#}</pre> | |
| 8245 | 8245 | <p> |
| 8246 | 8246 | Converts an enum value or union value to a slice of bytes representing the name.</p><p>If the enum is non-exhaustive and the tag value does not map to a name, it invokes safety-checked {#link|Undefined Behavior#}. |
| 8247 | 8247 | </p> |
| ... | ... | @@ -8292,7 +8292,7 @@ fn List(comptime T: type) type { |
| 8292 | 8292 | {#header_close#} |
| 8293 | 8293 | |
| 8294 | 8294 | {#header_open|@truncate#} |
| 8295 | <pre>{#syntax#}@truncate(comptime T: type, integer: var) T{#endsyntax#}</pre> | |
| 8295 | <pre>{#syntax#}@truncate(comptime T: type, integer: anytype) T{#endsyntax#}</pre> | |
| 8296 | 8296 | <p> |
| 8297 | 8297 | This function truncates bits from an integer type, resulting in a smaller |
| 8298 | 8298 | or same-sized integer type. |
| ... | ... | @@ -10214,7 +10214,7 @@ TopLevelDecl |
| 10214 | 10214 | / (KEYWORD_export / KEYWORD_extern STRINGLITERALSINGLE?)? KEYWORD_threadlocal? VarDecl |
| 10215 | 10215 | / KEYWORD_usingnamespace Expr SEMICOLON |
| 10216 | 10216 | |
| 10217 | FnProto &lt;- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_var / TypeExpr) | |
| 10217 | FnProto &lt;- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_anytype / TypeExpr) | |
| 10218 | 10218 | |
| 10219 | 10219 | VarDecl &lt;- (KEYWORD_const / KEYWORD_var) IDENTIFIER (COLON TypeExpr)? ByteAlign? LinkSection? (EQUAL Expr)? SEMICOLON |
| 10220 | 10220 | |
| ... | ... | @@ -10386,7 +10386,7 @@ LinkSection &lt;- KEYWORD_linksection LPAREN Expr RPAREN |
| 10386 | 10386 | ParamDecl &lt;- (KEYWORD_noalias / KEYWORD_comptime)? (IDENTIFIER COLON)? ParamType |
| 10387 | 10387 | |
| 10388 | 10388 | ParamType |
| 10389 | &lt;- KEYWORD_var | |
| 10389 | &lt;- KEYWORD_anytype | |
| 10390 | 10390 | / DOT3 |
| 10391 | 10391 | / TypeExpr |
| 10392 | 10392 | |
| ... | ... | @@ -10624,6 +10624,7 @@ KEYWORD_align &lt;- 'align' end_of_word |
| 10624 | 10624 | KEYWORD_allowzero &lt;- 'allowzero' end_of_word |
| 10625 | 10625 | KEYWORD_and &lt;- 'and' end_of_word |
| 10626 | 10626 | KEYWORD_anyframe &lt;- 'anyframe' end_of_word |
| 10627 | KEYWORD_anytype &lt;- 'anytype' end_of_word | |
| 10627 | 10628 | KEYWORD_asm &lt;- 'asm' end_of_word |
| 10628 | 10629 | KEYWORD_async &lt;- 'async' end_of_word |
| 10629 | 10630 | KEYWORD_await &lt;- 'await' end_of_word |
| ... | ... | @@ -10669,14 +10670,14 @@ KEYWORD_var &lt;- 'var' end_of_word |
| 10669 | 10670 | KEYWORD_volatile &lt;- 'volatile' end_of_word |
| 10670 | 10671 | KEYWORD_while &lt;- 'while' end_of_word |
| 10671 | 10672 | |
| 10672 | keyword &lt;- KEYWORD_align / KEYWORD_and / KEYWORD_allowzero / KEYWORD_asm | |
| 10673 | / KEYWORD_async / KEYWORD_await / KEYWORD_break | |
| 10673 | keyword &lt;- KEYWORD_align / KEYWORD_and / KEYWORD_anyframe / KEYWORD_anytype | |
| 10674 | / KEYWORD_allowzero / KEYWORD_asm / KEYWORD_async / KEYWORD_await / KEYWORD_break | |
| 10674 | 10675 | / KEYWORD_catch / KEYWORD_comptime / KEYWORD_const / KEYWORD_continue |
| 10675 | 10676 | / KEYWORD_defer / KEYWORD_else / KEYWORD_enum / KEYWORD_errdefer |
| 10676 | 10677 | / KEYWORD_error / KEYWORD_export / KEYWORD_extern / KEYWORD_false |
| 10677 | 10678 | / KEYWORD_fn / KEYWORD_for / KEYWORD_if / KEYWORD_inline |
| 10678 | 10679 | / KEYWORD_noalias / KEYWORD_null / KEYWORD_or |
| 10679 | / KEYWORD_orelse / KEYWORD_packed / KEYWORD_anyframe / KEYWORD_pub | |
| 10680 | / KEYWORD_orelse / KEYWORD_packed / KEYWORD_pub | |
| 10680 | 10681 | / KEYWORD_resume / KEYWORD_return / KEYWORD_linksection |
| 10681 | 10682 | / KEYWORD_struct / KEYWORD_suspend |
| 10682 | 10683 | / KEYWORD_switch / KEYWORD_test / KEYWORD_threadlocal / KEYWORD_true / KEYWORD_try |
lib/std/array_list.zig+1-1| ... | ... | @@ -53,7 +53,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { |
| 53 | 53 | /// Deprecated: use `items` field directly. |
| 54 | 54 | /// Return contents as a slice. Only valid while the list |
| 55 | 55 | /// doesn't change size. |
| 56 | pub fn span(self: var) @TypeOf(self.items) { | |
| 56 | pub fn span(self: anytype) @TypeOf(self.items) { | |
| 57 | 57 | return self.items; |
| 58 | 58 | } |
| 59 | 59 |
lib/std/array_list_sentineled.zig+2-2| ... | ... | @@ -69,7 +69,7 @@ pub fn ArrayListSentineled(comptime T: type, comptime sentinel: T) type { |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 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 | 73 | const size = std.math.cast(usize, std.fmt.count(format, args)) catch |err| switch (err) { |
| 74 | 74 | error.Overflow => return error.OutOfMemory, |
| 75 | 75 | }; |
| ... | ... | @@ -82,7 +82,7 @@ pub fn ArrayListSentineled(comptime T: type, comptime sentinel: T) type { |
| 82 | 82 | self.list.deinit(); |
| 83 | 83 | } |
| 84 | 84 | |
| 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 | 86 | return self.list.items[0..self.len() :sentinel]; |
| 87 | 87 | } |
| 88 | 88 |
lib/std/atomic/queue.zig+2-2| ... | ... | @@ -123,10 +123,10 @@ pub fn Queue(comptime T: type) type { |
| 123 | 123 | /// Dumps the contents of the queue to `stream`. |
| 124 | 124 | /// Up to 4 elements from the head are dumped and the tail of the queue is |
| 125 | 125 | /// dumped as well. |
| 126 | pub fn dumpToStream(self: *Self, stream: var) !void { | |
| 126 | pub fn dumpToStream(self: *Self, stream: anytype) !void { | |
| 127 | 127 | const S = struct { |
| 128 | 128 | fn dumpRecursive( |
| 129 | s: var, | |
| 129 | s: anytype, | |
| 130 | 130 | optional_node: ?*Node, |
| 131 | 131 | indent: usize, |
| 132 | 132 | comptime depth: comptime_int, |
lib/std/build.zig+2-2| ... | ... | @@ -312,7 +312,7 @@ pub const Builder = struct { |
| 312 | 312 | return write_file_step; |
| 313 | 313 | } |
| 314 | 314 | |
| 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 | 316 | const data = self.fmt(format, args); |
| 317 | 317 | const log_step = self.allocator.create(LogStep) catch unreachable; |
| 318 | 318 | log_step.* = LogStep.init(self, data); |
| ... | ... | @@ -883,7 +883,7 @@ pub const Builder = struct { |
| 883 | 883 | return fs.path.resolve(self.allocator, &[_][]const u8{ self.build_root, rel_path }) catch unreachable; |
| 884 | 884 | } |
| 885 | 885 | |
| 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 | 887 | return fmt_lib.allocPrint(self.allocator, format, args) catch unreachable; |
| 888 | 888 | } |
| 889 | 889 |
lib/std/build/emit_raw.zig+1-1| ... | ... | @@ -126,7 +126,7 @@ const BinaryElfOutput = struct { |
| 126 | 126 | return segment.p_offset <= section.elfOffset and (segment.p_offset + segment.p_filesz) >= (section.elfOffset + section.fileSize); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | fn sectionValidForOutput(shdr: var) bool { | |
| 129 | fn sectionValidForOutput(shdr: anytype) bool { | |
| 130 | 130 | return shdr.sh_size > 0 and shdr.sh_type != elf.SHT_NOBITS and |
| 131 | 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 | 198 | /// The type of the sentinel is the element type of the pointer, which is |
| 199 | 199 | /// the value of the `child` field in this struct. However there is no way |
| 200 | 200 | /// to refer to that type here, so we use `var`. |
| 201 | sentinel: var, | |
| 201 | sentinel: anytype, | |
| 202 | 202 | |
| 203 | 203 | /// This data structure is used by the Zig language code generation and |
| 204 | 204 | /// therefore must be kept in sync with the compiler implementation. |
| ... | ... | @@ -220,7 +220,7 @@ pub const TypeInfo = union(enum) { |
| 220 | 220 | /// The type of the sentinel is the element type of the array, which is |
| 221 | 221 | /// the value of the `child` field in this struct. However there is no way |
| 222 | 222 | /// to refer to that type here, so we use `var`. |
| 223 | sentinel: var, | |
| 223 | sentinel: anytype, | |
| 224 | 224 | }; |
| 225 | 225 | |
| 226 | 226 | /// This data structure is used by the Zig language code generation and |
| ... | ... | @@ -237,7 +237,7 @@ pub const TypeInfo = union(enum) { |
| 237 | 237 | name: []const u8, |
| 238 | 238 | offset: ?comptime_int, |
| 239 | 239 | field_type: type, |
| 240 | default_value: var, | |
| 240 | default_value: anytype, | |
| 241 | 241 | }; |
| 242 | 242 | |
| 243 | 243 | /// This data structure is used by the Zig language code generation and |
| ... | ... | @@ -328,7 +328,7 @@ pub const TypeInfo = union(enum) { |
| 328 | 328 | /// This data structure is used by the Zig language code generation and |
| 329 | 329 | /// therefore must be kept in sync with the compiler implementation. |
| 330 | 330 | pub const Frame = struct { |
| 331 | function: var, | |
| 331 | function: anytype, | |
| 332 | 332 | }; |
| 333 | 333 | |
| 334 | 334 | /// This data structure is used by the Zig language code generation and |
| ... | ... | @@ -452,7 +452,7 @@ pub const Version = struct { |
| 452 | 452 | self: Version, |
| 453 | 453 | comptime fmt: []const u8, |
| 454 | 454 | options: std.fmt.FormatOptions, |
| 455 | out_stream: var, | |
| 455 | out_stream: anytype, | |
| 456 | 456 | ) !void { |
| 457 | 457 | if (fmt.len == 0) { |
| 458 | 458 | if (self.patch == 0) { |
lib/std/c.zig+1-1| ... | ... | @@ -27,7 +27,7 @@ pub usingnamespace switch (std.Target.current.os.tag) { |
| 27 | 27 | else => struct {}, |
| 28 | 28 | }; |
| 29 | 29 | |
| 30 | pub fn getErrno(rc: var) u16 { | |
| 30 | pub fn getErrno(rc: anytype) u16 { | |
| 31 | 31 | if (rc == -1) { |
| 32 | 32 | return @intCast(u16, _errno().*); |
| 33 | 33 | } else { |
lib/std/c/ast.zig+7-7| ... | ... | @@ -64,7 +64,7 @@ pub const Error = union(enum) { |
| 64 | 64 | NothingDeclared: SimpleError("declaration doesn't declare anything"), |
| 65 | 65 | QualifierIgnored: SingleTokenError("qualifier '{}' ignored"), |
| 66 | 66 | |
| 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 | 68 | switch (self.*) { |
| 69 | 69 | .InvalidToken => |*x| return x.render(tree, stream), |
| 70 | 70 | .ExpectedToken => |*x| return x.render(tree, stream), |
| ... | ... | @@ -114,7 +114,7 @@ pub const Error = union(enum) { |
| 114 | 114 | token: TokenIndex, |
| 115 | 115 | expected_id: @TagType(Token.Id), |
| 116 | 116 | |
| 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 | 118 | const found_token = tree.tokens.at(self.token); |
| 119 | 119 | if (found_token.id == .Invalid) { |
| 120 | 120 | return stream.print("expected '{}', found invalid bytes", .{self.expected_id.symbol()}); |
| ... | ... | @@ -129,7 +129,7 @@ pub const Error = union(enum) { |
| 129 | 129 | token: TokenIndex, |
| 130 | 130 | type_spec: *Node.TypeSpec, |
| 131 | 131 | |
| 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 | 133 | try stream.write("invalid type specifier '"); |
| 134 | 134 | try type_spec.spec.print(tree, stream); |
| 135 | 135 | const token_name = tree.tokens.at(self.token).id.symbol(); |
| ... | ... | @@ -141,7 +141,7 @@ pub const Error = union(enum) { |
| 141 | 141 | kw: TokenIndex, |
| 142 | 142 | name: TokenIndex, |
| 143 | 143 | |
| 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 | 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 | 150 | return struct { |
| 151 | 151 | token: TokenIndex, |
| 152 | 152 | |
| 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 | 154 | const actual_token = tree.tokens.at(self.token); |
| 155 | 155 | return stream.print(msg, .{actual_token.id.symbol()}); |
| 156 | 156 | } |
| ... | ... | @@ -163,7 +163,7 @@ pub const Error = union(enum) { |
| 163 | 163 | |
| 164 | 164 | token: TokenIndex, |
| 165 | 165 | |
| 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 | 167 | return stream.write(msg); |
| 168 | 168 | } |
| 169 | 169 | }; |
| ... | ... | @@ -317,7 +317,7 @@ pub const Node = struct { |
| 317 | 317 | sym_type: *Type, |
| 318 | 318 | }, |
| 319 | 319 | |
| 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 | 321 | switch (self.spec) { |
| 322 | 322 | .None => unreachable, |
| 323 | 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 | 70 | |
| 71 | 71 | /// Convert the input value into bytes and record it as a dependency of the |
| 72 | 72 | /// process being cached |
| 73 | pub fn add(self: *CacheHash, val: var) void { | |
| 73 | pub fn add(self: *CacheHash, val: anytype) void { | |
| 74 | 74 | assert(self.manifest_file == null); |
| 75 | 75 | |
| 76 | 76 | const valPtr = switch (@typeInfo(@TypeOf(val))) { |
lib/std/comptime_string_map.zig+3-3| ... | ... | @@ -8,7 +8,7 @@ const mem = std.mem; |
| 8 | 8 | /// `kvs` expects a list literal containing list literals or an array/slice of structs |
| 9 | 9 | /// where `.@"0"` is the `[]const u8` key and `.@"1"` is the associated value of type `V`. |
| 10 | 10 | /// TODO: https://github.com/ziglang/zig/issues/4335 |
| 11 | pub fn ComptimeStringMap(comptime V: type, comptime kvs: var) type { | |
| 11 | pub fn ComptimeStringMap(comptime V: type, comptime kvs: anytype) type { | |
| 12 | 12 | const precomputed = comptime blk: { |
| 13 | 13 | @setEvalBranchQuota(2000); |
| 14 | 14 | const KV = struct { |
| ... | ... | @@ -126,7 +126,7 @@ test "ComptimeStringMap slice of structs" { |
| 126 | 126 | testMap(map); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | fn testMap(comptime map: var) void { | |
| 129 | fn testMap(comptime map: anytype) void { | |
| 130 | 130 | std.testing.expectEqual(TestEnum.A, map.get("have").?); |
| 131 | 131 | std.testing.expectEqual(TestEnum.B, map.get("nothing").?); |
| 132 | 132 | std.testing.expect(null == map.get("missing")); |
| ... | ... | @@ -165,7 +165,7 @@ test "ComptimeStringMap void value type, list literal of list literals" { |
| 165 | 165 | testSet(map); |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | fn testSet(comptime map: var) void { | |
| 168 | fn testSet(comptime map: anytype) void { | |
| 169 | 169 | std.testing.expectEqual({}, map.get("have").?); |
| 170 | 170 | std.testing.expectEqual({}, map.get("nothing").?); |
| 171 | 171 | std.testing.expect(null == map.get("missing")); |
lib/std/crypto/benchmark.zig+6-6| ... | ... | @@ -29,7 +29,7 @@ const hashes = [_]Crypto{ |
| 29 | 29 | Crypto{ .ty = crypto.Blake3, .name = "blake3" }, |
| 30 | 30 | }; |
| 31 | 31 | |
| 32 | pub fn benchmarkHash(comptime Hash: var, comptime bytes: comptime_int) !u64 { | |
| 32 | pub fn benchmarkHash(comptime Hash: anytype, comptime bytes: comptime_int) !u64 { | |
| 33 | 33 | var h = Hash.init(); |
| 34 | 34 | |
| 35 | 35 | var block: [Hash.digest_length]u8 = undefined; |
| ... | ... | @@ -56,7 +56,7 @@ const macs = [_]Crypto{ |
| 56 | 56 | Crypto{ .ty = crypto.HmacSha256, .name = "hmac-sha256" }, |
| 57 | 57 | }; |
| 58 | 58 | |
| 59 | pub fn benchmarkMac(comptime Mac: var, comptime bytes: comptime_int) !u64 { | |
| 59 | pub fn benchmarkMac(comptime Mac: anytype, comptime bytes: comptime_int) !u64 { | |
| 60 | 60 | std.debug.assert(32 >= Mac.mac_length and 32 >= Mac.minimum_key_length); |
| 61 | 61 | |
| 62 | 62 | var in: [1 * MiB]u8 = undefined; |
| ... | ... | @@ -81,7 +81,7 @@ pub fn benchmarkMac(comptime Mac: var, comptime bytes: comptime_int) !u64 { |
| 81 | 81 | |
| 82 | 82 | const exchanges = [_]Crypto{Crypto{ .ty = crypto.X25519, .name = "x25519" }}; |
| 83 | 83 | |
| 84 | pub fn benchmarkKeyExchange(comptime DhKeyExchange: var, comptime exchange_count: comptime_int) !u64 { | |
| 84 | pub fn benchmarkKeyExchange(comptime DhKeyExchange: anytype, comptime exchange_count: comptime_int) !u64 { | |
| 85 | 85 | std.debug.assert(DhKeyExchange.minimum_key_length >= DhKeyExchange.secret_length); |
| 86 | 86 | |
| 87 | 87 | var in: [DhKeyExchange.minimum_key_length]u8 = undefined; |
| ... | ... | @@ -166,21 +166,21 @@ pub fn main() !void { |
| 166 | 166 | inline for (hashes) |H| { |
| 167 | 167 | if (filter == null or std.mem.indexOf(u8, H.name, filter.?) != null) { |
| 168 | 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 | } |
| 172 | 172 | |
| 173 | 173 | inline for (macs) |M| { |
| 174 | 174 | if (filter == null or std.mem.indexOf(u8, M.name, filter.?) != null) { |
| 175 | 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 | } |
| 179 | 179 | |
| 180 | 180 | inline for (exchanges) |E| { |
| 181 | 181 | if (filter == null or std.mem.indexOf(u8, E.name, filter.?) != null) { |
| 182 | 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 | 4 | const fmt = std.fmt; |
| 5 | 5 | |
| 6 | 6 | // Hash using the specified hasher `H` asserting `expected == H(input)`. |
| 7 | pub fn assertEqualHash(comptime Hasher: var, comptime expected: []const u8, input: []const u8) void { | |
| 7 | pub fn assertEqualHash(comptime Hasher: anytype, comptime expected: []const u8, input: []const u8) void { | |
| 8 | 8 | var h: [expected.len / 2]u8 = undefined; |
| 9 | 9 | Hasher.hash(input, h[0..]); |
| 10 | 10 |
lib/std/debug.zig+12-12| ... | ... | @@ -58,7 +58,7 @@ pub const warn = print; |
| 58 | 58 | |
| 59 | 59 | /// Print to stderr, unbuffered, and silently returning on failure. Intended |
| 60 | 60 | /// for use in "printf debugging." Use `std.log` functions for proper logging. |
| 61 | pub fn print(comptime fmt: []const u8, args: var) void { | |
| 61 | pub fn print(comptime fmt: []const u8, args: anytype) void { | |
| 62 | 62 | const held = stderr_mutex.acquire(); |
| 63 | 63 | defer held.release(); |
| 64 | 64 | const stderr = io.getStdErr().writer(); |
| ... | ... | @@ -223,7 +223,7 @@ pub fn assert(ok: bool) void { |
| 223 | 223 | if (!ok) unreachable; // assertion failure |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | pub fn panic(comptime format: []const u8, args: var) noreturn { | |
| 226 | pub fn panic(comptime format: []const u8, args: anytype) noreturn { | |
| 227 | 227 | @setCold(true); |
| 228 | 228 | // TODO: remove conditional once wasi / LLVM defines __builtin_return_address |
| 229 | 229 | const first_trace_addr = if (builtin.os.tag == .wasi) null else @returnAddress(); |
| ... | ... | @@ -241,7 +241,7 @@ var panic_mutex = std.Mutex.init(); |
| 241 | 241 | /// This is used to catch and handle panics triggered by the panic handler. |
| 242 | 242 | threadlocal var panic_stage: usize = 0; |
| 243 | 243 | |
| 244 | pub fn panicExtra(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, comptime format: []const u8, args: var) noreturn { | |
| 244 | pub fn panicExtra(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, comptime format: []const u8, args: anytype) noreturn { | |
| 245 | 245 | @setCold(true); |
| 246 | 246 | |
| 247 | 247 | if (enable_segfault_handler) { |
| ... | ... | @@ -306,7 +306,7 @@ const RESET = "\x1b[0m"; |
| 306 | 306 | |
| 307 | 307 | pub fn writeStackTrace( |
| 308 | 308 | stack_trace: builtin.StackTrace, |
| 309 | out_stream: var, | |
| 309 | out_stream: anytype, | |
| 310 | 310 | allocator: *mem.Allocator, |
| 311 | 311 | debug_info: *DebugInfo, |
| 312 | 312 | tty_config: TTY.Config, |
| ... | ... | @@ -384,7 +384,7 @@ pub const StackIterator = struct { |
| 384 | 384 | }; |
| 385 | 385 | |
| 386 | 386 | pub fn writeCurrentStackTrace( |
| 387 | out_stream: var, | |
| 387 | out_stream: anytype, | |
| 388 | 388 | debug_info: *DebugInfo, |
| 389 | 389 | tty_config: TTY.Config, |
| 390 | 390 | start_addr: ?usize, |
| ... | ... | @@ -399,7 +399,7 @@ pub fn writeCurrentStackTrace( |
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | pub fn writeCurrentStackTraceWindows( |
| 402 | out_stream: var, | |
| 402 | out_stream: anytype, | |
| 403 | 403 | debug_info: *DebugInfo, |
| 404 | 404 | tty_config: TTY.Config, |
| 405 | 405 | start_addr: ?usize, |
| ... | ... | @@ -435,7 +435,7 @@ pub const TTY = struct { |
| 435 | 435 | // TODO give this a payload of file handle |
| 436 | 436 | windows_api, |
| 437 | 437 | |
| 438 | fn setColor(conf: Config, out_stream: var, color: Color) void { | |
| 438 | fn setColor(conf: Config, out_stream: anytype, color: Color) void { | |
| 439 | 439 | nosuspend switch (conf) { |
| 440 | 440 | .no_color => return, |
| 441 | 441 | .escape_codes => switch (color) { |
| ... | ... | @@ -555,7 +555,7 @@ fn machoSearchSymbols(symbols: []const MachoSymbol, address: usize) ?*const Mach |
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | /// TODO resources https://github.com/ziglang/zig/issues/4353 |
| 558 | pub fn printSourceAtAddress(debug_info: *DebugInfo, out_stream: var, address: usize, tty_config: TTY.Config) !void { | |
| 558 | pub fn printSourceAtAddress(debug_info: *DebugInfo, out_stream: anytype, address: usize, tty_config: TTY.Config) !void { | |
| 559 | 559 | const module = debug_info.getModuleForAddress(address) catch |err| switch (err) { |
| 560 | 560 | error.MissingDebugInfo, error.InvalidDebugInfo => { |
| 561 | 561 | return printLineInfo( |
| ... | ... | @@ -586,13 +586,13 @@ pub fn printSourceAtAddress(debug_info: *DebugInfo, out_stream: var, address: us |
| 586 | 586 | } |
| 587 | 587 | |
| 588 | 588 | fn printLineInfo( |
| 589 | out_stream: var, | |
| 589 | out_stream: anytype, | |
| 590 | 590 | line_info: ?LineInfo, |
| 591 | 591 | address: usize, |
| 592 | 592 | symbol_name: []const u8, |
| 593 | 593 | compile_unit_name: []const u8, |
| 594 | 594 | tty_config: TTY.Config, |
| 595 | comptime printLineFromFile: var, | |
| 595 | comptime printLineFromFile: anytype, | |
| 596 | 596 | ) !void { |
| 597 | 597 | nosuspend { |
| 598 | 598 | tty_config.setColor(out_stream, .White); |
| ... | ... | @@ -820,7 +820,7 @@ fn readCoffDebugInfo(allocator: *mem.Allocator, coff_file: File) !ModuleDebugInf |
| 820 | 820 | } |
| 821 | 821 | } |
| 822 | 822 | |
| 823 | fn readSparseBitVector(stream: var, allocator: *mem.Allocator) ![]usize { | |
| 823 | fn readSparseBitVector(stream: anytype, allocator: *mem.Allocator) ![]usize { | |
| 824 | 824 | const num_words = try stream.readIntLittle(u32); |
| 825 | 825 | var word_i: usize = 0; |
| 826 | 826 | var list = ArrayList(usize).init(allocator); |
| ... | ... | @@ -1004,7 +1004,7 @@ fn readMachODebugInfo(allocator: *mem.Allocator, macho_file: File) !ModuleDebugI |
| 1004 | 1004 | }; |
| 1005 | 1005 | } |
| 1006 | 1006 | |
| 1007 | fn printLineFromFileAnyOs(out_stream: var, line_info: LineInfo) !void { | |
| 1007 | fn printLineFromFileAnyOs(out_stream: anytype, line_info: LineInfo) !void { | |
| 1008 | 1008 | // Need this to always block even in async I/O mode, because this could potentially |
| 1009 | 1009 | // be called from e.g. the event loop code crashing. |
| 1010 | 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 | 3 | |
| 4 | 4 | /// Read a single unsigned LEB128 value from the given reader as type T, |
| 5 | 5 | /// or error.Overflow if the value cannot fit. |
| 6 | pub fn readULEB128(comptime T: type, reader: var) !T { | |
| 6 | pub fn readULEB128(comptime T: type, reader: anytype) !T { | |
| 7 | 7 | const U = if (T.bit_count < 8) u8 else T; |
| 8 | 8 | const ShiftT = std.math.Log2Int(U); |
| 9 | 9 | |
| ... | ... | @@ -33,7 +33,7 @@ pub fn readULEB128(comptime T: type, reader: var) !T { |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /// Write a single unsigned integer as unsigned LEB128 to the given writer. |
| 36 | pub fn writeULEB128(writer: var, uint_value: var) !void { | |
| 36 | pub fn writeULEB128(writer: anytype, uint_value: anytype) !void { | |
| 37 | 37 | const T = @TypeOf(uint_value); |
| 38 | 38 | const U = if (T.bit_count < 8) u8 else T; |
| 39 | 39 | var value = @intCast(U, uint_value); |
| ... | ... | @@ -61,7 +61,7 @@ pub fn readULEB128Mem(comptime T: type, ptr: *[]const u8) !T { |
| 61 | 61 | |
| 62 | 62 | /// Write a single unsigned LEB128 integer to the given memory as unsigned LEB128, |
| 63 | 63 | /// returning the number of bytes written. |
| 64 | pub fn writeULEB128Mem(ptr: []u8, uint_value: var) !usize { | |
| 64 | pub fn writeULEB128Mem(ptr: []u8, uint_value: anytype) !usize { | |
| 65 | 65 | const T = @TypeOf(uint_value); |
| 66 | 66 | const max_group = (T.bit_count + 6) / 7; |
| 67 | 67 | var buf = std.io.fixedBufferStream(ptr); |
| ... | ... | @@ -71,7 +71,7 @@ pub fn writeULEB128Mem(ptr: []u8, uint_value: var) !usize { |
| 71 | 71 | |
| 72 | 72 | /// Read a single signed LEB128 value from the given reader as type T, |
| 73 | 73 | /// or error.Overflow if the value cannot fit. |
| 74 | pub fn readILEB128(comptime T: type, reader: var) !T { | |
| 74 | pub fn readILEB128(comptime T: type, reader: anytype) !T { | |
| 75 | 75 | const S = if (T.bit_count < 8) i8 else T; |
| 76 | 76 | const U = std.meta.Int(false, S.bit_count); |
| 77 | 77 | const ShiftU = std.math.Log2Int(U); |
| ... | ... | @@ -120,7 +120,7 @@ pub fn readILEB128(comptime T: type, reader: var) !T { |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | /// Write a single signed integer as signed LEB128 to the given writer. |
| 123 | pub fn writeILEB128(writer: var, int_value: var) !void { | |
| 123 | pub fn writeILEB128(writer: anytype, int_value: anytype) !void { | |
| 124 | 124 | const T = @TypeOf(int_value); |
| 125 | 125 | const S = if (T.bit_count < 8) i8 else T; |
| 126 | 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 | 152 | |
| 153 | 153 | /// Write a single signed LEB128 integer to the given memory as unsigned LEB128, |
| 154 | 154 | /// returning the number of bytes written. |
| 155 | pub fn writeILEB128Mem(ptr: []u8, int_value: var) !usize { | |
| 155 | pub fn writeILEB128Mem(ptr: []u8, int_value: anytype) !usize { | |
| 156 | 156 | const T = @TypeOf(int_value); |
| 157 | 157 | var buf = std.io.fixedBufferStream(ptr); |
| 158 | 158 | try writeILEB128(buf.writer(), int_value); |
| ... | ... | @@ -295,7 +295,7 @@ test "deserialize unsigned LEB128" { |
| 295 | 295 | try test_read_uleb128_seq(u64, 4, "\x81\x01\x3f\x80\x7f\x80\x80\x80\x00"); |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | fn test_write_leb128(value: var) !void { | |
| 298 | fn test_write_leb128(value: anytype) !void { | |
| 299 | 299 | const T = @TypeOf(value); |
| 300 | 300 | |
| 301 | 301 | const writeStream = if (T.is_signed) writeILEB128 else writeULEB128; |
lib/std/dwarf.zig+9-9| ... | ... | @@ -236,7 +236,7 @@ const LineNumberProgram = struct { |
| 236 | 236 | } |
| 237 | 237 | }; |
| 238 | 238 | |
| 239 | fn readUnitLength(in_stream: var, endian: builtin.Endian, is_64: *bool) !u64 { | |
| 239 | fn readUnitLength(in_stream: anytype, endian: builtin.Endian, is_64: *bool) !u64 { | |
| 240 | 240 | const first_32_bits = try in_stream.readInt(u32, endian); |
| 241 | 241 | is_64.* = (first_32_bits == 0xffffffff); |
| 242 | 242 | if (is_64.*) { |
| ... | ... | @@ -249,7 +249,7 @@ fn readUnitLength(in_stream: var, endian: builtin.Endian, is_64: *bool) !u64 { |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | // TODO the nosuspends here are workarounds |
| 252 | fn readAllocBytes(allocator: *mem.Allocator, in_stream: var, size: usize) ![]u8 { | |
| 252 | fn readAllocBytes(allocator: *mem.Allocator, in_stream: anytype, size: usize) ![]u8 { | |
| 253 | 253 | const buf = try allocator.alloc(u8, size); |
| 254 | 254 | errdefer allocator.free(buf); |
| 255 | 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 | 257 | } |
| 258 | 258 | |
| 259 | 259 | // TODO the nosuspends here are workarounds |
| 260 | fn readAddress(in_stream: var, endian: builtin.Endian, is_64: bool) !u64 { | |
| 260 | fn readAddress(in_stream: anytype, endian: builtin.Endian, is_64: bool) !u64 { | |
| 261 | 261 | return nosuspend if (is_64) |
| 262 | 262 | try in_stream.readInt(u64, endian) |
| 263 | 263 | else |
| 264 | 264 | @as(u64, try in_stream.readInt(u32, endian)); |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | fn parseFormValueBlockLen(allocator: *mem.Allocator, in_stream: var, size: usize) !FormValue { | |
| 267 | fn parseFormValueBlockLen(allocator: *mem.Allocator, in_stream: anytype, size: usize) !FormValue { | |
| 268 | 268 | const buf = try readAllocBytes(allocator, in_stream, size); |
| 269 | 269 | return FormValue{ .Block = buf }; |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | // TODO the nosuspends here are workarounds |
| 273 | fn parseFormValueBlock(allocator: *mem.Allocator, in_stream: var, endian: builtin.Endian, size: usize) !FormValue { | |
| 273 | fn parseFormValueBlock(allocator: *mem.Allocator, in_stream: anytype, endian: builtin.Endian, size: usize) !FormValue { | |
| 274 | 274 | const block_len = try nosuspend in_stream.readVarInt(usize, endian, size); |
| 275 | 275 | return parseFormValueBlockLen(allocator, in_stream, block_len); |
| 276 | 276 | } |
| 277 | 277 | |
| 278 | fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: var, signed: bool, endian: builtin.Endian, comptime size: i32) !FormValue { | |
| 278 | fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: anytype, signed: bool, endian: builtin.Endian, comptime size: i32) !FormValue { | |
| 279 | 279 | // TODO: Please forgive me, I've worked around zig not properly spilling some intermediate values here. |
| 280 | 280 | // `nosuspend` should be removed from all the function calls once it is fixed. |
| 281 | 281 | return FormValue{ |
| ... | ... | @@ -302,7 +302,7 @@ fn parseFormValueConstant(allocator: *mem.Allocator, in_stream: var, signed: boo |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | // TODO the nosuspends here are workarounds |
| 305 | fn parseFormValueRef(allocator: *mem.Allocator, in_stream: var, endian: builtin.Endian, size: i32) !FormValue { | |
| 305 | fn parseFormValueRef(allocator: *mem.Allocator, in_stream: anytype, endian: builtin.Endian, size: i32) !FormValue { | |
| 306 | 306 | return FormValue{ |
| 307 | 307 | .Ref = switch (size) { |
| 308 | 308 | 1 => try nosuspend in_stream.readInt(u8, endian), |
| ... | ... | @@ -316,7 +316,7 @@ fn parseFormValueRef(allocator: *mem.Allocator, in_stream: var, endian: builtin. |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | // TODO the nosuspends here are workarounds |
| 319 | fn parseFormValue(allocator: *mem.Allocator, in_stream: var, form_id: u64, endian: builtin.Endian, is_64: bool) anyerror!FormValue { | |
| 319 | fn parseFormValue(allocator: *mem.Allocator, in_stream: anytype, form_id: u64, endian: builtin.Endian, is_64: bool) anyerror!FormValue { | |
| 320 | 320 | return switch (form_id) { |
| 321 | 321 | FORM_addr => FormValue{ .Address = try readAddress(in_stream, endian, @sizeOf(usize) == 8) }, |
| 322 | 322 | FORM_block1 => parseFormValueBlock(allocator, in_stream, endian, 1), |
| ... | ... | @@ -670,7 +670,7 @@ pub const DwarfInfo = struct { |
| 670 | 670 | } |
| 671 | 671 | } |
| 672 | 672 | |
| 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 | 674 | const abbrev_code = try leb.readULEB128(u64, in_stream); |
| 675 | 675 | if (abbrev_code == 0) return null; |
| 676 | 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 | 517 | return hdrs; |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | pub fn int(is_64: bool, need_bswap: bool, int_32: var, int_64: var) @TypeOf(int_64) { | |
| 520 | pub fn int(is_64: bool, need_bswap: bool, int_32: anytype, int_64: anytype) @TypeOf(int_64) { | |
| 521 | 521 | if (is_64) { |
| 522 | 522 | if (need_bswap) { |
| 523 | 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 | 529 | } |
| 530 | 530 | } |
| 531 | 531 | |
| 532 | pub fn int32(need_bswap: bool, int_32: var, comptime Int64: var) Int64 { | |
| 532 | pub fn int32(need_bswap: bool, int_32: anytype, comptime Int64: anytype) Int64 { | |
| 533 | 533 | if (need_bswap) { |
| 534 | 534 | return @byteSwap(@TypeOf(int_32), int_32); |
| 535 | 535 | } else { |
lib/std/event/group.zig+1-1| ... | ... | @@ -65,7 +65,7 @@ pub fn Group(comptime ReturnType: type) type { |
| 65 | 65 | /// allocated by the group and freed by `wait`. |
| 66 | 66 | /// `func` must be async and have return type `ReturnType`. |
| 67 | 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 | 69 | var frame = try self.allocator.create(@TypeOf(@call(.{ .modifier = .async_kw }, func, args))); |
| 70 | 70 | errdefer self.allocator.destroy(frame); |
| 71 | 71 | const node = try self.allocator.create(AllocStack.Node); |
lib/std/fmt.zig+36-36| ... | ... | @@ -69,16 +69,16 @@ fn peekIsAlign(comptime fmt: []const u8) bool { |
| 69 | 69 | /// |
| 70 | 70 | /// If a formatted user type contains a function of the type |
| 71 | 71 | /// ``` |
| 72 | /// pub fn format(value: ?, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: var) !void | |
| 72 | /// pub fn format(value: ?, comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void | |
| 73 | 73 | /// ``` |
| 74 | 74 | /// with `?` being the type formatted, this function will be called instead of the default implementation. |
| 75 | 75 | /// This allows user types to be formatted in a logical manner instead of dumping all fields of the type. |
| 76 | 76 | /// |
| 77 | 77 | /// A user type may be a `struct`, `vector`, `union` or `enum` type. |
| 78 | 78 | pub fn format( |
| 79 | writer: var, | |
| 79 | writer: anytype, | |
| 80 | 80 | comptime fmt: []const u8, |
| 81 | args: var, | |
| 81 | args: anytype, | |
| 82 | 82 | ) !void { |
| 83 | 83 | const ArgSetType = u32; |
| 84 | 84 | if (@typeInfo(@TypeOf(args)) != .Struct) { |
| ... | ... | @@ -311,10 +311,10 @@ pub fn format( |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | pub fn formatType( |
| 314 | value: var, | |
| 314 | value: anytype, | |
| 315 | 315 | comptime fmt: []const u8, |
| 316 | 316 | options: FormatOptions, |
| 317 | writer: var, | |
| 317 | writer: anytype, | |
| 318 | 318 | max_depth: usize, |
| 319 | 319 | ) @TypeOf(writer).Error!void { |
| 320 | 320 | if (comptime std.mem.eql(u8, fmt, "*")) { |
| ... | ... | @@ -490,10 +490,10 @@ pub fn formatType( |
| 490 | 490 | } |
| 491 | 491 | |
| 492 | 492 | fn formatValue( |
| 493 | value: var, | |
| 493 | value: anytype, | |
| 494 | 494 | comptime fmt: []const u8, |
| 495 | 495 | options: FormatOptions, |
| 496 | writer: var, | |
| 496 | writer: anytype, | |
| 497 | 497 | ) !void { |
| 498 | 498 | if (comptime std.mem.eql(u8, fmt, "B")) { |
| 499 | 499 | return formatBytes(value, options, 1000, writer); |
| ... | ... | @@ -511,10 +511,10 @@ fn formatValue( |
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | pub fn formatIntValue( |
| 514 | value: var, | |
| 514 | value: anytype, | |
| 515 | 515 | comptime fmt: []const u8, |
| 516 | 516 | options: FormatOptions, |
| 517 | writer: var, | |
| 517 | writer: anytype, | |
| 518 | 518 | ) !void { |
| 519 | 519 | comptime var radix = 10; |
| 520 | 520 | comptime var uppercase = false; |
| ... | ... | @@ -551,10 +551,10 @@ pub fn formatIntValue( |
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | fn formatFloatValue( |
| 554 | value: var, | |
| 554 | value: anytype, | |
| 555 | 555 | comptime fmt: []const u8, |
| 556 | 556 | options: FormatOptions, |
| 557 | writer: var, | |
| 557 | writer: anytype, | |
| 558 | 558 | ) !void { |
| 559 | 559 | if (fmt.len == 0 or comptime std.mem.eql(u8, fmt, "e")) { |
| 560 | 560 | return formatFloatScientific(value, options, writer); |
| ... | ... | @@ -569,7 +569,7 @@ pub fn formatText( |
| 569 | 569 | bytes: []const u8, |
| 570 | 570 | comptime fmt: []const u8, |
| 571 | 571 | options: FormatOptions, |
| 572 | writer: var, | |
| 572 | writer: anytype, | |
| 573 | 573 | ) !void { |
| 574 | 574 | if (comptime std.mem.eql(u8, fmt, "s") or (fmt.len == 0)) { |
| 575 | 575 | return formatBuf(bytes, options, writer); |
| ... | ... | @@ -586,7 +586,7 @@ pub fn formatText( |
| 586 | 586 | pub fn formatAsciiChar( |
| 587 | 587 | c: u8, |
| 588 | 588 | options: FormatOptions, |
| 589 | writer: var, | |
| 589 | writer: anytype, | |
| 590 | 590 | ) !void { |
| 591 | 591 | return writer.writeAll(@as(*const [1]u8, &c)); |
| 592 | 592 | } |
| ... | ... | @@ -594,7 +594,7 @@ pub fn formatAsciiChar( |
| 594 | 594 | pub fn formatBuf( |
| 595 | 595 | buf: []const u8, |
| 596 | 596 | options: FormatOptions, |
| 597 | writer: var, | |
| 597 | writer: anytype, | |
| 598 | 598 | ) !void { |
| 599 | 599 | const width = options.width orelse buf.len; |
| 600 | 600 | var padding = if (width > buf.len) (width - buf.len) else 0; |
| ... | ... | @@ -626,9 +626,9 @@ pub fn formatBuf( |
| 626 | 626 | // It should be the case that every full precision, printed value can be re-parsed back to the |
| 627 | 627 | // same type unambiguously. |
| 628 | 628 | pub fn formatFloatScientific( |
| 629 | value: var, | |
| 629 | value: anytype, | |
| 630 | 630 | options: FormatOptions, |
| 631 | writer: var, | |
| 631 | writer: anytype, | |
| 632 | 632 | ) !void { |
| 633 | 633 | var x = @floatCast(f64, value); |
| 634 | 634 | |
| ... | ... | @@ -719,9 +719,9 @@ pub fn formatFloatScientific( |
| 719 | 719 | // Print a float of the format x.yyyyy where the number of y is specified by the precision argument. |
| 720 | 720 | // By default floats are printed at full precision (no rounding). |
| 721 | 721 | pub fn formatFloatDecimal( |
| 722 | value: var, | |
| 722 | value: anytype, | |
| 723 | 723 | options: FormatOptions, |
| 724 | writer: var, | |
| 724 | writer: anytype, | |
| 725 | 725 | ) !void { |
| 726 | 726 | var x = @as(f64, value); |
| 727 | 727 | |
| ... | ... | @@ -860,10 +860,10 @@ pub fn formatFloatDecimal( |
| 860 | 860 | } |
| 861 | 861 | |
| 862 | 862 | pub fn formatBytes( |
| 863 | value: var, | |
| 863 | value: anytype, | |
| 864 | 864 | options: FormatOptions, |
| 865 | 865 | comptime radix: usize, |
| 866 | writer: var, | |
| 866 | writer: anytype, | |
| 867 | 867 | ) !void { |
| 868 | 868 | if (value == 0) { |
| 869 | 869 | return writer.writeAll("0B"); |
| ... | ... | @@ -901,11 +901,11 @@ pub fn formatBytes( |
| 901 | 901 | } |
| 902 | 902 | |
| 903 | 903 | pub fn formatInt( |
| 904 | value: var, | |
| 904 | value: anytype, | |
| 905 | 905 | base: u8, |
| 906 | 906 | uppercase: bool, |
| 907 | 907 | options: FormatOptions, |
| 908 | writer: var, | |
| 908 | writer: anytype, | |
| 909 | 909 | ) !void { |
| 910 | 910 | const int_value = if (@TypeOf(value) == comptime_int) blk: { |
| 911 | 911 | const Int = math.IntFittingRange(value, value); |
| ... | ... | @@ -921,11 +921,11 @@ pub fn formatInt( |
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | fn formatIntSigned( |
| 924 | value: var, | |
| 924 | value: anytype, | |
| 925 | 925 | base: u8, |
| 926 | 926 | uppercase: bool, |
| 927 | 927 | options: FormatOptions, |
| 928 | writer: var, | |
| 928 | writer: anytype, | |
| 929 | 929 | ) !void { |
| 930 | 930 | const new_options = FormatOptions{ |
| 931 | 931 | .width = if (options.width) |w| (if (w == 0) 0 else w - 1) else null, |
| ... | ... | @@ -948,11 +948,11 @@ fn formatIntSigned( |
| 948 | 948 | } |
| 949 | 949 | |
| 950 | 950 | fn formatIntUnsigned( |
| 951 | value: var, | |
| 951 | value: anytype, | |
| 952 | 952 | base: u8, |
| 953 | 953 | uppercase: bool, |
| 954 | 954 | options: FormatOptions, |
| 955 | writer: var, | |
| 955 | writer: anytype, | |
| 956 | 956 | ) !void { |
| 957 | 957 | assert(base >= 2); |
| 958 | 958 | var buf: [math.max(@TypeOf(value).bit_count, 1)]u8 = undefined; |
| ... | ... | @@ -990,7 +990,7 @@ fn formatIntUnsigned( |
| 990 | 990 | } |
| 991 | 991 | } |
| 992 | 992 | |
| 993 | pub fn formatIntBuf(out_buf: []u8, value: var, base: u8, uppercase: bool, options: FormatOptions) usize { | |
| 993 | pub fn formatIntBuf(out_buf: []u8, value: anytype, base: u8, uppercase: bool, options: FormatOptions) usize { | |
| 994 | 994 | var fbs = std.io.fixedBufferStream(out_buf); |
| 995 | 995 | formatInt(value, base, uppercase, options, fbs.writer()) catch unreachable; |
| 996 | 996 | return fbs.pos; |
| ... | ... | @@ -1050,7 +1050,7 @@ fn parseWithSign( |
| 1050 | 1050 | .Pos => math.add, |
| 1051 | 1051 | .Neg => math.sub, |
| 1052 | 1052 | }; |
| 1053 | ||
| 1053 | ||
| 1054 | 1054 | var x: T = 0; |
| 1055 | 1055 | |
| 1056 | 1056 | for (buf) |c| { |
| ... | ... | @@ -1132,14 +1132,14 @@ pub const BufPrintError = error{ |
| 1132 | 1132 | /// As much as possible was written to the buffer, but it was too small to fit all the printed bytes. |
| 1133 | 1133 | NoSpaceLeft, |
| 1134 | 1134 | }; |
| 1135 | pub fn bufPrint(buf: []u8, comptime fmt: []const u8, args: var) BufPrintError![]u8 { | |
| 1135 | pub fn bufPrint(buf: []u8, comptime fmt: []const u8, args: anytype) BufPrintError![]u8 { | |
| 1136 | 1136 | var fbs = std.io.fixedBufferStream(buf); |
| 1137 | 1137 | try format(fbs.writer(), fmt, args); |
| 1138 | 1138 | return fbs.getWritten(); |
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | 1141 | // Count the characters needed for format. Useful for preallocating memory |
| 1142 | pub fn count(comptime fmt: []const u8, args: var) u64 { | |
| 1142 | pub fn count(comptime fmt: []const u8, args: anytype) u64 { | |
| 1143 | 1143 | var counting_writer = std.io.countingWriter(std.io.null_writer); |
| 1144 | 1144 | format(counting_writer.writer(), fmt, args) catch |err| switch (err) {}; |
| 1145 | 1145 | return counting_writer.bytes_written; |
| ... | ... | @@ -1147,7 +1147,7 @@ pub fn count(comptime fmt: []const u8, args: var) u64 { |
| 1147 | 1147 | |
| 1148 | 1148 | pub const AllocPrintError = error{OutOfMemory}; |
| 1149 | 1149 | |
| 1150 | pub fn allocPrint(allocator: *mem.Allocator, comptime fmt: []const u8, args: var) AllocPrintError![]u8 { | |
| 1150 | pub fn allocPrint(allocator: *mem.Allocator, comptime fmt: []const u8, args: anytype) AllocPrintError![]u8 { | |
| 1151 | 1151 | const size = math.cast(usize, count(fmt, args)) catch |err| switch (err) { |
| 1152 | 1152 | // Output too long. Can't possibly allocate enough memory to display it. |
| 1153 | 1153 | error.Overflow => return error.OutOfMemory, |
| ... | ... | @@ -1158,7 +1158,7 @@ pub fn allocPrint(allocator: *mem.Allocator, comptime fmt: []const u8, args: var |
| 1158 | 1158 | }; |
| 1159 | 1159 | } |
| 1160 | 1160 | |
| 1161 | pub fn allocPrint0(allocator: *mem.Allocator, comptime fmt: []const u8, args: var) AllocPrintError![:0]u8 { | |
| 1161 | pub fn allocPrint0(allocator: *mem.Allocator, comptime fmt: []const u8, args: anytype) AllocPrintError![:0]u8 { | |
| 1162 | 1162 | const result = try allocPrint(allocator, fmt ++ "\x00", args); |
| 1163 | 1163 | return result[0 .. result.len - 1 :0]; |
| 1164 | 1164 | } |
| ... | ... | @@ -1184,7 +1184,7 @@ test "bufPrintInt" { |
| 1184 | 1184 | std.testing.expectEqualSlices(u8, "-42", bufPrintIntToSlice(buf, @as(i32, -42), 10, false, FormatOptions{ .width = 3 })); |
| 1185 | 1185 | } |
| 1186 | 1186 | |
| 1187 | fn bufPrintIntToSlice(buf: []u8, value: var, base: u8, uppercase: bool, options: FormatOptions) []u8 { | |
| 1187 | fn bufPrintIntToSlice(buf: []u8, value: anytype, base: u8, uppercase: bool, options: FormatOptions) []u8 { | |
| 1188 | 1188 | return buf[0..formatIntBuf(buf, value, base, uppercase, options)]; |
| 1189 | 1189 | } |
| 1190 | 1190 | |
| ... | ... | @@ -1452,7 +1452,7 @@ test "custom" { |
| 1452 | 1452 | self: SelfType, |
| 1453 | 1453 | comptime fmt: []const u8, |
| 1454 | 1454 | options: FormatOptions, |
| 1455 | writer: var, | |
| 1455 | writer: anytype, | |
| 1456 | 1456 | ) !void { |
| 1457 | 1457 | if (fmt.len == 0 or comptime std.mem.eql(u8, fmt, "p")) { |
| 1458 | 1458 | return std.fmt.format(writer, "({d:.3},{d:.3})", .{ self.x, self.y }); |
| ... | ... | @@ -1573,7 +1573,7 @@ test "bytes.hex" { |
| 1573 | 1573 | try testFmt("lowercase: 000ebabe\n", "lowercase: {x}\n", .{bytes_with_zeros}); |
| 1574 | 1574 | } |
| 1575 | 1575 | |
| 1576 | fn testFmt(expected: []const u8, comptime template: []const u8, args: var) !void { | |
| 1576 | fn testFmt(expected: []const u8, comptime template: []const u8, args: anytype) !void { | |
| 1577 | 1577 | var buf: [100]u8 = undefined; |
| 1578 | 1578 | const result = try bufPrint(buf[0..], template, args); |
| 1579 | 1579 | if (mem.eql(u8, result, expected)) return; |
| ... | ... | @@ -1669,7 +1669,7 @@ test "formatType max_depth" { |
| 1669 | 1669 | self: SelfType, |
| 1670 | 1670 | comptime fmt: []const u8, |
| 1671 | 1671 | options: FormatOptions, |
| 1672 | writer: var, | |
| 1672 | writer: anytype, | |
| 1673 | 1673 | ) !void { |
| 1674 | 1674 | if (fmt.len == 0) { |
| 1675 | 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 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | |
| 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 | 33 | try out_stream.print("PreopenType{{ ", .{}); |
| 34 | 34 | switch (self) { |
| 35 | 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 | 21 | }; |
| 22 | 22 | |
| 23 | 23 | /// Helper function to hash a pointer and mutate the strategy if needed. |
| 24 | pub fn hashPointer(hasher: var, key: var, comptime strat: HashStrategy) void { | |
| 24 | pub fn hashPointer(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { | |
| 25 | 25 | const info = @typeInfo(@TypeOf(key)); |
| 26 | 26 | |
| 27 | 27 | switch (info.Pointer.size) { |
| ... | ... | @@ -53,7 +53,7 @@ pub fn hashPointer(hasher: var, key: var, comptime strat: HashStrategy) void { |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /// Helper function to hash a set of contiguous objects, from an array or slice. |
| 56 | pub fn hashArray(hasher: var, key: var, comptime strat: HashStrategy) void { | |
| 56 | pub fn hashArray(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { | |
| 57 | 57 | switch (strat) { |
| 58 | 58 | .Shallow => { |
| 59 | 59 | // 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 | 73 | |
| 74 | 74 | /// Provides generic hashing for any eligible type. |
| 75 | 75 | /// Strategy is provided to determine if pointers should be followed or not. |
| 76 | pub fn hash(hasher: var, key: var, comptime strat: HashStrategy) void { | |
| 76 | pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { | |
| 77 | 77 | const Key = @TypeOf(key); |
| 78 | 78 | switch (@typeInfo(Key)) { |
| 79 | 79 | .NoReturn, |
| ... | ... | @@ -161,7 +161,7 @@ pub fn hash(hasher: var, key: var, comptime strat: HashStrategy) void { |
| 161 | 161 | /// Provides generic hashing for any eligible type. |
| 162 | 162 | /// Only hashes `key` itself, pointers are not followed. |
| 163 | 163 | /// Slices are rejected to avoid ambiguity on the user's intention. |
| 164 | pub fn autoHash(hasher: var, key: var) void { | |
| 164 | pub fn autoHash(hasher: anytype, key: anytype) void { | |
| 165 | 165 | const Key = @TypeOf(key); |
| 166 | 166 | if (comptime meta.trait.isSlice(Key)) { |
| 167 | 167 | 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 | 181 | const testing = std.testing; |
| 182 | 182 | const Wyhash = std.hash.Wyhash; |
| 183 | 183 | |
| 184 | fn testHash(key: var) u64 { | |
| 184 | fn testHash(key: anytype) u64 { | |
| 185 | 185 | // Any hash could be used here, for testing autoHash. |
| 186 | 186 | var hasher = Wyhash.init(0); |
| 187 | 187 | hash(&hasher, key, .Shallow); |
| 188 | 188 | return hasher.final(); |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | fn testHashShallow(key: var) u64 { | |
| 191 | fn testHashShallow(key: anytype) u64 { | |
| 192 | 192 | // Any hash could be used here, for testing autoHash. |
| 193 | 193 | var hasher = Wyhash.init(0); |
| 194 | 194 | hash(&hasher, key, .Shallow); |
| 195 | 195 | return hasher.final(); |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | fn testHashDeep(key: var) u64 { | |
| 198 | fn testHashDeep(key: anytype) u64 { | |
| 199 | 199 | // Any hash could be used here, for testing autoHash. |
| 200 | 200 | var hasher = Wyhash.init(0); |
| 201 | 201 | hash(&hasher, key, .Deep); |
| 202 | 202 | return hasher.final(); |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | fn testHashDeepRecursive(key: var) u64 { | |
| 205 | fn testHashDeepRecursive(key: anytype) u64 { | |
| 206 | 206 | // Any hash could be used here, for testing autoHash. |
| 207 | 207 | var hasher = Wyhash.init(0); |
| 208 | 208 | hash(&hasher, key, .DeepRecursive); |
lib/std/hash/benchmark.zig+2-2| ... | ... | @@ -88,7 +88,7 @@ const Result = struct { |
| 88 | 88 | |
| 89 | 89 | const block_size: usize = 8 * 8192; |
| 90 | 90 | |
| 91 | pub fn benchmarkHash(comptime H: var, bytes: usize) !Result { | |
| 91 | pub fn benchmarkHash(comptime H: anytype, bytes: usize) !Result { | |
| 92 | 92 | var h = blk: { |
| 93 | 93 | if (H.init_u8s) |init| { |
| 94 | 94 | break :blk H.ty.init(init); |
| ... | ... | @@ -119,7 +119,7 @@ pub fn benchmarkHash(comptime H: var, bytes: usize) !Result { |
| 119 | 119 | }; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | pub fn benchmarkHashSmallKeys(comptime H: var, key_size: usize, bytes: usize) !Result { | |
| 122 | pub fn benchmarkHashSmallKeys(comptime H: anytype, key_size: usize, bytes: usize) !Result { | |
| 123 | 123 | const key_count = bytes / key_size; |
| 124 | 124 | var block: [block_size]u8 = undefined; |
| 125 | 125 | prng.random.bytes(block[0..]); |
lib/std/hash/cityhash.zig+1-1| ... | ... | @@ -354,7 +354,7 @@ pub const CityHash64 = struct { |
| 354 | 354 | } |
| 355 | 355 | }; |
| 356 | 356 | |
| 357 | fn SMHasherTest(comptime hash_fn: var, comptime hashbits: u32) u32 { | |
| 357 | fn SMHasherTest(comptime hash_fn: anytype, comptime hashbits: u32) u32 { | |
| 358 | 358 | const hashbytes = hashbits / 8; |
| 359 | 359 | var key: [256]u8 = undefined; |
| 360 | 360 | var hashes: [hashbytes * 256]u8 = undefined; |
lib/std/hash/murmur.zig+1-1| ... | ... | @@ -279,7 +279,7 @@ pub const Murmur3_32 = struct { |
| 279 | 279 | } |
| 280 | 280 | }; |
| 281 | 281 | |
| 282 | fn SMHasherTest(comptime hash_fn: var, comptime hashbits: u32) u32 { | |
| 282 | fn SMHasherTest(comptime hash_fn: anytype, comptime hashbits: u32) u32 { | |
| 283 | 283 | const hashbytes = hashbits / 8; |
| 284 | 284 | var key: [256]u8 = undefined; |
| 285 | 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 | |
| 16 | 16 | const Allocator = mem.Allocator; |
| 17 | 17 | |
| 18 | usingnamespace if (comptime @hasDecl(c, "malloc_size")) struct { | |
| 19 | pub const supports_malloc_size = true; | |
| 20 | pub const malloc_size = c.malloc_size; | |
| 21 | } else if (comptime @hasDecl(c, "malloc_usable_size")) struct { | |
| 22 | pub const supports_malloc_size = true; | |
| 23 | pub const malloc_size = c.malloc_usable_size; | |
| 24 | } else struct { | |
| 25 | pub const supports_malloc_size = false; | |
| 26 | }; | |
| 18 | usingnamespace if (comptime @hasDecl(c, "malloc_size")) | |
| 19 | struct { | |
| 20 | pub const supports_malloc_size = true; | |
| 21 | pub const malloc_size = c.malloc_size; | |
| 22 | } | |
| 23 | else if (comptime @hasDecl(c, "malloc_usable_size")) | |
| 24 | struct { | |
| 25 | pub const supports_malloc_size = true; | |
| 26 | pub const malloc_size = c.malloc_usable_size; | |
| 27 | } | |
| 28 | else | |
| 29 | struct { | |
| 30 | pub const supports_malloc_size = false; | |
| 31 | }; | |
| 27 | 32 | |
| 28 | 33 | pub const c_allocator = &c_allocator_state; |
| 29 | 34 | var c_allocator_state = Allocator{ |
| ... | ... | @@ -151,8 +156,7 @@ const PageAllocator = struct { |
| 151 | 156 | } |
| 152 | 157 | |
| 153 | 158 | const maxDropLen = alignment - std.math.min(alignment, mem.page_size); |
| 154 | const allocLen = if (maxDropLen <= alignedLen - n) alignedLen | |
| 155 | else mem.alignForward(alignedLen + maxDropLen, mem.page_size); | |
| 159 | const allocLen = if (maxDropLen <= alignedLen - n) alignedLen else mem.alignForward(alignedLen + maxDropLen, mem.page_size); | |
| 156 | 160 | const slice = os.mmap( |
| 157 | 161 | null, |
| 158 | 162 | allocLen, |
| ... | ... | @@ -331,8 +335,7 @@ const WasmPageAllocator = struct { |
| 331 | 335 | fn alloc(allocator: *Allocator, len: usize, alignment: u29, len_align: u29) error{OutOfMemory}![]u8 { |
| 332 | 336 | const page_count = nPages(len); |
| 333 | 337 | const page_idx = try allocPages(page_count, alignment); |
| 334 | return @intToPtr([*]u8, page_idx * mem.page_size) | |
| 335 | [0..alignPageAllocLen(page_count * mem.page_size, len, len_align)]; | |
| 338 | return @intToPtr([*]u8, page_idx * mem.page_size)[0..alignPageAllocLen(page_count * mem.page_size, len, len_align)]; | |
| 336 | 339 | } |
| 337 | 340 | fn allocPages(page_count: usize, alignment: u29) !usize { |
| 338 | 341 | { |
| ... | ... | @@ -452,7 +455,7 @@ pub const HeapAllocator = switch (builtin.os.tag) { |
| 452 | 455 | fn resize(allocator: *Allocator, buf: []u8, new_size: usize, len_align: u29) error{OutOfMemory}!usize { |
| 453 | 456 | const self = @fieldParentPtr(HeapAllocator, "allocator", allocator); |
| 454 | 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 | 459 | return 0; |
| 457 | 460 | } |
| 458 | 461 |
lib/std/heap/logging_allocator.zig+2-2| ... | ... | @@ -40,7 +40,7 @@ pub fn LoggingAllocator(comptime OutStreamType: type) type { |
| 40 | 40 | if (new_len == 0) { |
| 41 | 41 | self.out_stream.print("free : {}\n", .{buf.len}) catch {}; |
| 42 | 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 | 44 | } else { |
| 45 | 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 | 60 | |
| 61 | 61 | pub fn loggingAllocator( |
| 62 | 62 | parent_allocator: *Allocator, |
| 63 | out_stream: var, | |
| 63 | out_stream: anytype, | |
| 64 | 64 | ) LoggingAllocator(@TypeOf(out_stream)) { |
| 65 | 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 | 348 | self: Self, |
| 349 | 349 | comptime fmt: []const u8, |
| 350 | 350 | options: std.fmt.FormatOptions, |
| 351 | out_stream: var, | |
| 351 | out_stream: anytype, | |
| 352 | 352 | ) !void { |
| 353 | 353 | for (self.toSlice()) |entry| { |
| 354 | 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 | 170 | |
| 171 | 171 | pub fn bitReader( |
| 172 | 172 | comptime endian: builtin.Endian, |
| 173 | underlying_stream: var, | |
| 173 | underlying_stream: anytype, | |
| 174 | 174 | ) BitReader(endian, @TypeOf(underlying_stream)) { |
| 175 | 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 | 34 | /// Write the specified number of bits to the stream from the least significant bits of |
| 35 | 35 | /// the specified unsigned int value. Bits will only be written to the stream when there |
| 36 | 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 | 38 | if (bits == 0) return; |
| 39 | 39 | |
| 40 | 40 | const U = @TypeOf(value); |
| ... | ... | @@ -145,7 +145,7 @@ pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type { |
| 145 | 145 | |
| 146 | 146 | pub fn bitWriter( |
| 147 | 147 | comptime endian: builtin.Endian, |
| 148 | underlying_stream: var, | |
| 148 | underlying_stream: anytype, | |
| 149 | 149 | ) BitWriter(endian, @TypeOf(underlying_stream)) { |
| 150 | 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 | 48 | }; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | pub fn bufferedReader(underlying_stream: var) BufferedReader(4096, @TypeOf(underlying_stream)) { | |
| 51 | pub fn bufferedReader(underlying_stream: anytype) BufferedReader(4096, @TypeOf(underlying_stream)) { | |
| 52 | 52 | return .{ .unbuffered_reader = underlying_stream }; |
| 53 | 53 | } |
| 54 | 54 |
lib/std/io/buffered_writer.zig+1-1| ... | ... | @@ -43,6 +43,6 @@ pub fn BufferedWriter(comptime buffer_size: usize, comptime WriterType: type) ty |
| 43 | 43 | }; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | pub fn bufferedWriter(underlying_stream: var) BufferedWriter(4096, @TypeOf(underlying_stream)) { | |
| 46 | pub fn bufferedWriter(underlying_stream: anytype) BufferedWriter(4096, @TypeOf(underlying_stream)) { | |
| 47 | 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 | 32 | }; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | pub fn countingWriter(child_stream: var) CountingWriter(@TypeOf(child_stream)) { | |
| 35 | pub fn countingWriter(child_stream: anytype) CountingWriter(@TypeOf(child_stream)) { | |
| 36 | 36 | return .{ .bytes_written = 0, .child_stream = child_stream }; |
| 37 | 37 | } |
| 38 | 38 |
lib/std/io/fixed_buffer_stream.zig+1-1| ... | ... | @@ -127,7 +127,7 @@ pub fn FixedBufferStream(comptime Buffer: type) type { |
| 127 | 127 | }; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | pub fn fixedBufferStream(buffer: var) FixedBufferStream(NonSentinelSpan(@TypeOf(buffer))) { | |
| 130 | pub fn fixedBufferStream(buffer: anytype) FixedBufferStream(NonSentinelSpan(@TypeOf(buffer))) { | |
| 131 | 131 | return .{ .buffer = mem.span(buffer), .pos = 0 }; |
| 132 | 132 | } |
| 133 | 133 |
lib/std/io/multi_writer.zig+1-1| ... | ... | @@ -43,7 +43,7 @@ pub fn MultiWriter(comptime Writers: type) type { |
| 43 | 43 | }; |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | pub fn multiWriter(streams: var) MultiWriter(@TypeOf(streams)) { | |
| 46 | pub fn multiWriter(streams: anytype) MultiWriter(@TypeOf(streams)) { | |
| 47 | 47 | return .{ .streams = streams }; |
| 48 | 48 | } |
| 49 | 49 |
lib/std/io/peek_stream.zig+1-1| ... | ... | @@ -80,7 +80,7 @@ pub fn PeekStream( |
| 80 | 80 | |
| 81 | 81 | pub fn peekStream( |
| 82 | 82 | comptime lookahead: comptime_int, |
| 83 | underlying_stream: var, | |
| 83 | underlying_stream: anytype, | |
| 84 | 84 | ) PeekStream(.{ .Static = lookahead }, @TypeOf(underlying_stream)) { |
| 85 | 85 | return PeekStream(.{ .Static = lookahead }, @TypeOf(underlying_stream)).init(underlying_stream); |
| 86 | 86 | } |
lib/std/io/serialization.zig+33-29| ... | ... | @@ -16,14 +16,16 @@ pub const Packing = enum { |
| 16 | 16 | }; |
| 17 | 17 | |
| 18 | 18 | /// Creates a deserializer that deserializes types from any stream. |
| 19 | /// If `is_packed` is true, the data stream is treated as bit-packed, | |
| 20 | /// otherwise data is expected to be packed to the smallest byte. | |
| 21 | /// Types may implement a custom deserialization routine with a | |
| 22 | /// function named `deserialize` in the form of: | |
| 23 | /// pub fn deserialize(self: *Self, deserializer: var) !void | |
| 24 | /// which will be called when the deserializer is used to deserialize | |
| 25 | /// that type. It will pass a pointer to the type instance to deserialize | |
| 26 | /// into and a pointer to the deserializer struct. | |
| 19 | /// If `is_packed` is true, the data stream is treated as bit-packed, | |
| 20 | /// otherwise data is expected to be packed to the smallest byte. | |
| 21 | /// Types may implement a custom deserialization routine with a | |
| 22 | /// function named `deserialize` in the form of: | |
| 23 | /// ``` | |
| 24 | /// pub fn deserialize(self: *Self, deserializer: anytype) !void | |
| 25 | /// ``` | |
| 26 | /// which will be called when the deserializer is used to deserialize | |
| 27 | /// that type. It will pass a pointer to the type instance to deserialize | |
| 28 | /// into and a pointer to the deserializer struct. | |
| 27 | 29 | pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing, comptime ReaderType: type) type { |
| 28 | 30 | return struct { |
| 29 | 31 | in_stream: if (packing == .Bit) io.BitReader(endian, ReaderType) else ReaderType, |
| ... | ... | @@ -93,7 +95,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing, |
| 93 | 95 | } |
| 94 | 96 | |
| 95 | 97 | /// Deserializes data into the type pointed to by `ptr` |
| 96 | pub fn deserializeInto(self: *Self, ptr: var) !void { | |
| 98 | pub fn deserializeInto(self: *Self, ptr: anytype) !void { | |
| 97 | 99 | const T = @TypeOf(ptr); |
| 98 | 100 | comptime assert(trait.is(.Pointer)(T)); |
| 99 | 101 | |
| ... | ... | @@ -108,7 +110,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing, |
| 108 | 110 | const C = comptime meta.Child(T); |
| 109 | 111 | const child_type_id = @typeInfo(C); |
| 110 | 112 | |
| 111 | //custom deserializer: fn(self: *Self, deserializer: var) !void | |
| 113 | //custom deserializer: fn(self: *Self, deserializer: anytype) !void | |
| 112 | 114 | if (comptime trait.hasFn("deserialize")(C)) return C.deserialize(ptr, self); |
| 113 | 115 | |
| 114 | 116 | if (comptime trait.isPacked(C) and packing != .Bit) { |
| ... | ... | @@ -190,24 +192,26 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing, |
| 190 | 192 | pub fn deserializer( |
| 191 | 193 | comptime endian: builtin.Endian, |
| 192 | 194 | comptime packing: Packing, |
| 193 | in_stream: var, | |
| 195 | in_stream: anytype, | |
| 194 | 196 | ) Deserializer(endian, packing, @TypeOf(in_stream)) { |
| 195 | 197 | return Deserializer(endian, packing, @TypeOf(in_stream)).init(in_stream); |
| 196 | 198 | } |
| 197 | 199 | |
| 198 | 200 | /// Creates a serializer that serializes types to any stream. |
| 199 | /// If `is_packed` is true, the data will be bit-packed into the stream. | |
| 200 | /// Note that the you must call `serializer.flush()` when you are done | |
| 201 | /// writing bit-packed data in order ensure any unwritten bits are committed. | |
| 202 | /// If `is_packed` is false, data is packed to the smallest byte. In the case | |
| 203 | /// of packed structs, the struct will written bit-packed and with the specified | |
| 204 | /// endianess, after which data will resume being written at the next byte boundary. | |
| 205 | /// Types may implement a custom serialization routine with a | |
| 206 | /// function named `serialize` in the form of: | |
| 207 | /// pub fn serialize(self: Self, serializer: var) !void | |
| 208 | /// which will be called when the serializer is used to serialize that type. It will | |
| 209 | /// pass a const pointer to the type instance to be serialized and a pointer | |
| 210 | /// to the serializer struct. | |
| 201 | /// If `is_packed` is true, the data will be bit-packed into the stream. | |
| 202 | /// Note that the you must call `serializer.flush()` when you are done | |
| 203 | /// writing bit-packed data in order ensure any unwritten bits are committed. | |
| 204 | /// If `is_packed` is false, data is packed to the smallest byte. In the case | |
| 205 | /// of packed structs, the struct will written bit-packed and with the specified | |
| 206 | /// endianess, after which data will resume being written at the next byte boundary. | |
| 207 | /// Types may implement a custom serialization routine with a | |
| 208 | /// function named `serialize` in the form of: | |
| 209 | /// ``` | |
| 210 | /// pub fn serialize(self: Self, serializer: anytype) !void | |
| 211 | /// ``` | |
| 212 | /// which will be called when the serializer is used to serialize that type. It will | |
| 213 | /// pass a const pointer to the type instance to be serialized and a pointer | |
| 214 | /// to the serializer struct. | |
| 211 | 215 | pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, comptime OutStreamType: type) type { |
| 212 | 216 | return struct { |
| 213 | 217 | out_stream: if (packing == .Bit) io.BitOutStream(endian, OutStreamType) else OutStreamType, |
| ... | ... | @@ -229,7 +233,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co |
| 229 | 233 | if (packing == .Bit) return self.out_stream.flushBits(); |
| 230 | 234 | } |
| 231 | 235 | |
| 232 | fn serializeInt(self: *Self, value: var) Error!void { | |
| 236 | fn serializeInt(self: *Self, value: anytype) Error!void { | |
| 233 | 237 | const T = @TypeOf(value); |
| 234 | 238 | comptime assert(trait.is(.Int)(T) or trait.is(.Float)(T)); |
| 235 | 239 | |
| ... | ... | @@ -261,7 +265,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co |
| 261 | 265 | } |
| 262 | 266 | |
| 263 | 267 | /// Serializes the passed value into the stream |
| 264 | pub fn serialize(self: *Self, value: var) Error!void { | |
| 268 | pub fn serialize(self: *Self, value: anytype) Error!void { | |
| 265 | 269 | const T = comptime @TypeOf(value); |
| 266 | 270 | |
| 267 | 271 | if (comptime trait.isIndexable(T)) { |
| ... | ... | @@ -270,7 +274,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co |
| 270 | 274 | return; |
| 271 | 275 | } |
| 272 | 276 | |
| 273 | //custom serializer: fn(self: Self, serializer: var) !void | |
| 277 | //custom serializer: fn(self: Self, serializer: anytype) !void | |
| 274 | 278 | if (comptime trait.hasFn("serialize")(T)) return T.serialize(value, self); |
| 275 | 279 | |
| 276 | 280 | if (comptime trait.isPacked(T) and packing != .Bit) { |
| ... | ... | @@ -346,7 +350,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co |
| 346 | 350 | pub fn serializer( |
| 347 | 351 | comptime endian: builtin.Endian, |
| 348 | 352 | comptime packing: Packing, |
| 349 | out_stream: var, | |
| 353 | out_stream: anytype, | |
| 350 | 354 | ) Serializer(endian, packing, @TypeOf(out_stream)) { |
| 351 | 355 | return Serializer(endian, packing, @TypeOf(out_stream)).init(out_stream); |
| 352 | 356 | } |
| ... | ... | @@ -462,7 +466,7 @@ test "Serializer/Deserializer Int: Inf/NaN" { |
| 462 | 466 | try testIntSerializerDeserializerInfNaN(.Little, .Bit); |
| 463 | 467 | } |
| 464 | 468 | |
| 465 | fn testAlternateSerializer(self: var, _serializer: var) !void { | |
| 469 | fn testAlternateSerializer(self: anytype, _serializer: anytype) !void { | |
| 466 | 470 | try _serializer.serialize(self.f_f16); |
| 467 | 471 | } |
| 468 | 472 | |
| ... | ... | @@ -503,7 +507,7 @@ fn testSerializerDeserializer(comptime endian: builtin.Endian, comptime packing: |
| 503 | 507 | f_f16: f16, |
| 504 | 508 | f_unused_u32: u32, |
| 505 | 509 | |
| 506 | pub fn deserialize(self: *@This(), _deserializer: var) !void { | |
| 510 | pub fn deserialize(self: *@This(), _deserializer: anytype) !void { | |
| 507 | 511 | try _deserializer.deserializeInto(&self.f_f16); |
| 508 | 512 | self.f_unused_u32 = 47; |
| 509 | 513 | } |
lib/std/io/writer.zig+1-1| ... | ... | @@ -24,7 +24,7 @@ pub fn Writer( |
| 24 | 24 | } |
| 25 | 25 | } |
| 26 | 26 | |
| 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 | 28 | return std.fmt.format(self, format, args); |
| 29 | 29 | } |
| 30 | 30 |
lib/std/json.zig+8-8| ... | ... | @@ -239,7 +239,7 @@ pub const StreamingParser = struct { |
| 239 | 239 | NullLiteral3, |
| 240 | 240 | |
| 241 | 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 | 243 | debug.assert(x == 0 or x == 1); |
| 244 | 244 | const T = @TagType(State); |
| 245 | 245 | return @intToEnum(State, @intCast(T, x)); |
| ... | ... | @@ -1236,7 +1236,7 @@ pub const Value = union(enum) { |
| 1236 | 1236 | pub fn jsonStringify( |
| 1237 | 1237 | value: @This(), |
| 1238 | 1238 | options: StringifyOptions, |
| 1239 | out_stream: var, | |
| 1239 | out_stream: anytype, | |
| 1240 | 1240 | ) @TypeOf(out_stream).Error!void { |
| 1241 | 1241 | switch (value) { |
| 1242 | 1242 | .Null => try stringify(null, options, out_stream), |
| ... | ... | @@ -2338,7 +2338,7 @@ pub const StringifyOptions = struct { |
| 2338 | 2338 | |
| 2339 | 2339 | pub fn outputIndent( |
| 2340 | 2340 | whitespace: @This(), |
| 2341 | out_stream: var, | |
| 2341 | out_stream: anytype, | |
| 2342 | 2342 | ) @TypeOf(out_stream).Error!void { |
| 2343 | 2343 | var char: u8 = undefined; |
| 2344 | 2344 | var n_chars: usize = undefined; |
| ... | ... | @@ -2380,7 +2380,7 @@ pub const StringifyOptions = struct { |
| 2380 | 2380 | |
| 2381 | 2381 | fn outputUnicodeEscape( |
| 2382 | 2382 | codepoint: u21, |
| 2383 | out_stream: var, | |
| 2383 | out_stream: anytype, | |
| 2384 | 2384 | ) !void { |
| 2385 | 2385 | if (codepoint <= 0xFFFF) { |
| 2386 | 2386 | // If the character is in the Basic Multilingual Plane (U+0000 through U+FFFF), |
| ... | ... | @@ -2402,9 +2402,9 @@ fn outputUnicodeEscape( |
| 2402 | 2402 | } |
| 2403 | 2403 | |
| 2404 | 2404 | pub fn stringify( |
| 2405 | value: var, | |
| 2405 | value: anytype, | |
| 2406 | 2406 | options: StringifyOptions, |
| 2407 | out_stream: var, | |
| 2407 | out_stream: anytype, | |
| 2408 | 2408 | ) @TypeOf(out_stream).Error!void { |
| 2409 | 2409 | const T = @TypeOf(value); |
| 2410 | 2410 | switch (@typeInfo(T)) { |
| ... | ... | @@ -2584,7 +2584,7 @@ pub fn stringify( |
| 2584 | 2584 | unreachable; |
| 2585 | 2585 | } |
| 2586 | 2586 | |
| 2587 | fn teststringify(expected: []const u8, value: var, options: StringifyOptions) !void { | |
| 2587 | fn teststringify(expected: []const u8, value: anytype, options: StringifyOptions) !void { | |
| 2588 | 2588 | const ValidationOutStream = struct { |
| 2589 | 2589 | const Self = @This(); |
| 2590 | 2590 | pub const OutStream = std.io.OutStream(*Self, Error, write); |
| ... | ... | @@ -2758,7 +2758,7 @@ test "stringify struct with custom stringifier" { |
| 2758 | 2758 | pub fn jsonStringify( |
| 2759 | 2759 | value: Self, |
| 2760 | 2760 | options: StringifyOptions, |
| 2761 | out_stream: var, | |
| 2761 | out_stream: anytype, | |
| 2762 | 2762 | ) !void { |
| 2763 | 2763 | try out_stream.writeAll("[\"something special\","); |
| 2764 | 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 | 152 | self: *Self, |
| 153 | 153 | /// An integer, float, or `std.math.BigInt`. Emitted as a bare number if it fits losslessly |
| 154 | 154 | /// in a IEEE 754 double float, otherwise emitted as a string to the full precision. |
| 155 | value: var, | |
| 155 | value: anytype, | |
| 156 | 156 | ) !void { |
| 157 | 157 | assert(self.state[self.state_index] == State.Value); |
| 158 | 158 | switch (@typeInfo(@TypeOf(value))) { |
| ... | ... | @@ -215,7 +215,7 @@ pub fn WriteStream(comptime OutStream: type, comptime max_depth: usize) type { |
| 215 | 215 | self.state_index -= 1; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | fn stringify(self: *Self, value: var) !void { | |
| 218 | fn stringify(self: *Self, value: anytype) !void { | |
| 219 | 219 | try std.json.stringify(value, std.json.StringifyOptions{ |
| 220 | 220 | .whitespace = self.whitespace, |
| 221 | 221 | }, self.stream); |
| ... | ... | @@ -224,7 +224,7 @@ pub fn WriteStream(comptime OutStream: type, comptime max_depth: usize) type { |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | pub fn writeStream( |
| 227 | out_stream: var, | |
| 227 | out_stream: anytype, | |
| 228 | 228 | comptime max_depth: usize, |
| 229 | 229 | ) WriteStream(@TypeOf(out_stream), max_depth) { |
| 230 | 230 | return WriteStream(@TypeOf(out_stream), max_depth).init(out_stream); |
lib/std/log.zig+10-10| ... | ... | @@ -22,7 +22,7 @@ const root = @import("root"); |
| 22 | 22 | //! comptime level: std.log.Level, |
| 23 | 23 | //! comptime scope: @TypeOf(.EnumLiteral), |
| 24 | 24 | //! comptime format: []const u8, |
| 25 | //! args: var, | |
| 25 | //! args: anytype, | |
| 26 | 26 | //! ) void { |
| 27 | 27 | //! // Ignore all non-critical logging from sources other than |
| 28 | 28 | //! // .my_project and .nice_library |
| ... | ... | @@ -101,7 +101,7 @@ fn log( |
| 101 | 101 | comptime message_level: Level, |
| 102 | 102 | comptime scope: @Type(.EnumLiteral), |
| 103 | 103 | comptime format: []const u8, |
| 104 | args: var, | |
| 104 | args: anytype, | |
| 105 | 105 | ) void { |
| 106 | 106 | if (@enumToInt(message_level) <= @enumToInt(level)) { |
| 107 | 107 | if (@hasDecl(root, "log")) { |
| ... | ... | @@ -120,7 +120,7 @@ fn log( |
| 120 | 120 | pub fn emerg( |
| 121 | 121 | comptime scope: @Type(.EnumLiteral), |
| 122 | 122 | comptime format: []const u8, |
| 123 | args: var, | |
| 123 | args: anytype, | |
| 124 | 124 | ) void { |
| 125 | 125 | @setCold(true); |
| 126 | 126 | log(.emerg, scope, format, args); |
| ... | ... | @@ -131,7 +131,7 @@ pub fn emerg( |
| 131 | 131 | pub fn alert( |
| 132 | 132 | comptime scope: @Type(.EnumLiteral), |
| 133 | 133 | comptime format: []const u8, |
| 134 | args: var, | |
| 134 | args: anytype, | |
| 135 | 135 | ) void { |
| 136 | 136 | @setCold(true); |
| 137 | 137 | log(.alert, scope, format, args); |
| ... | ... | @@ -143,7 +143,7 @@ pub fn alert( |
| 143 | 143 | pub fn crit( |
| 144 | 144 | comptime scope: @Type(.EnumLiteral), |
| 145 | 145 | comptime format: []const u8, |
| 146 | args: var, | |
| 146 | args: anytype, | |
| 147 | 147 | ) void { |
| 148 | 148 | @setCold(true); |
| 149 | 149 | log(.crit, scope, format, args); |
| ... | ... | @@ -154,7 +154,7 @@ pub fn crit( |
| 154 | 154 | pub fn err( |
| 155 | 155 | comptime scope: @Type(.EnumLiteral), |
| 156 | 156 | comptime format: []const u8, |
| 157 | args: var, | |
| 157 | args: anytype, | |
| 158 | 158 | ) void { |
| 159 | 159 | @setCold(true); |
| 160 | 160 | log(.err, scope, format, args); |
| ... | ... | @@ -166,7 +166,7 @@ pub fn err( |
| 166 | 166 | pub fn warn( |
| 167 | 167 | comptime scope: @Type(.EnumLiteral), |
| 168 | 168 | comptime format: []const u8, |
| 169 | args: var, | |
| 169 | args: anytype, | |
| 170 | 170 | ) void { |
| 171 | 171 | log(.warn, scope, format, args); |
| 172 | 172 | } |
| ... | ... | @@ -176,7 +176,7 @@ pub fn warn( |
| 176 | 176 | pub fn notice( |
| 177 | 177 | comptime scope: @Type(.EnumLiteral), |
| 178 | 178 | comptime format: []const u8, |
| 179 | args: var, | |
| 179 | args: anytype, | |
| 180 | 180 | ) void { |
| 181 | 181 | log(.notice, scope, format, args); |
| 182 | 182 | } |
| ... | ... | @@ -186,7 +186,7 @@ pub fn notice( |
| 186 | 186 | pub fn info( |
| 187 | 187 | comptime scope: @Type(.EnumLiteral), |
| 188 | 188 | comptime format: []const u8, |
| 189 | args: var, | |
| 189 | args: anytype, | |
| 190 | 190 | ) void { |
| 191 | 191 | log(.info, scope, format, args); |
| 192 | 192 | } |
| ... | ... | @@ -196,7 +196,7 @@ pub fn info( |
| 196 | 196 | pub fn debug( |
| 197 | 197 | comptime scope: @Type(.EnumLiteral), |
| 198 | 198 | comptime format: []const u8, |
| 199 | args: var, | |
| 199 | args: anytype, | |
| 200 | 200 | ) void { |
| 201 | 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 | 104 | } |
| 105 | 105 | |
| 106 | 106 | // TODO: Hide the following in an internal module. |
| 107 | pub fn forceEval(value: var) void { | |
| 107 | pub fn forceEval(value: anytype) void { | |
| 108 | 108 | const T = @TypeOf(value); |
| 109 | 109 | switch (T) { |
| 110 | 110 | f16 => { |
| ... | ... | @@ -259,7 +259,7 @@ pub fn Min(comptime A: type, comptime B: type) type { |
| 259 | 259 | |
| 260 | 260 | /// Returns the smaller number. When one of the parameter's type's full range fits in the other, |
| 261 | 261 | /// the return type is the smaller type. |
| 262 | pub fn min(x: var, y: var) Min(@TypeOf(x), @TypeOf(y)) { | |
| 262 | pub fn min(x: anytype, y: anytype) Min(@TypeOf(x), @TypeOf(y)) { | |
| 263 | 263 | const Result = Min(@TypeOf(x), @TypeOf(y)); |
| 264 | 264 | if (x < y) { |
| 265 | 265 | // TODO Zig should allow this as an implicit cast because x is immutable and in this |
| ... | ... | @@ -310,7 +310,7 @@ test "math.min" { |
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | pub fn max(x: var, y: var) @TypeOf(x, y) { | |
| 313 | pub fn max(x: anytype, y: anytype) @TypeOf(x, y) { | |
| 314 | 314 | return if (x > y) x else y; |
| 315 | 315 | } |
| 316 | 316 | |
| ... | ... | @@ -318,7 +318,7 @@ test "math.max" { |
| 318 | 318 | testing.expect(max(@as(i32, -1), @as(i32, 2)) == 2); |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | pub fn clamp(val: var, lower: var, upper: var) @TypeOf(val, lower, upper) { | |
| 321 | pub fn clamp(val: anytype, lower: anytype, upper: anytype) @TypeOf(val, lower, upper) { | |
| 322 | 322 | assert(lower <= upper); |
| 323 | 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 | 354 | return if (@subWithOverflow(T, a, b, &answer)) error.Overflow else answer; |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | pub fn negate(x: var) !@TypeOf(x) { | |
| 357 | pub fn negate(x: anytype) !@TypeOf(x) { | |
| 358 | 358 | return sub(@TypeOf(x), 0, x); |
| 359 | 359 | } |
| 360 | 360 | |
| ... | ... | @@ -365,7 +365,7 @@ pub fn shlExact(comptime T: type, a: T, shift_amt: Log2Int(T)) !T { |
| 365 | 365 | |
| 366 | 366 | /// Shifts left. Overflowed bits are truncated. |
| 367 | 367 | /// A negative shift amount results in a right shift. |
| 368 | pub fn shl(comptime T: type, a: T, shift_amt: var) T { | |
| 368 | pub fn shl(comptime T: type, a: T, shift_amt: anytype) T { | |
| 369 | 369 | const abs_shift_amt = absCast(shift_amt); |
| 370 | 370 | const casted_shift_amt = if (abs_shift_amt >= T.bit_count) return 0 else @intCast(Log2Int(T), abs_shift_amt); |
| 371 | 371 | |
| ... | ... | @@ -391,7 +391,7 @@ test "math.shl" { |
| 391 | 391 | |
| 392 | 392 | /// Shifts right. Overflowed bits are truncated. |
| 393 | 393 | /// A negative shift amount results in a left shift. |
| 394 | pub fn shr(comptime T: type, a: T, shift_amt: var) T { | |
| 394 | pub fn shr(comptime T: type, a: T, shift_amt: anytype) T { | |
| 395 | 395 | const abs_shift_amt = absCast(shift_amt); |
| 396 | 396 | const casted_shift_amt = if (abs_shift_amt >= T.bit_count) return 0 else @intCast(Log2Int(T), abs_shift_amt); |
| 397 | 397 | |
| ... | ... | @@ -419,7 +419,7 @@ test "math.shr" { |
| 419 | 419 | |
| 420 | 420 | /// Rotates right. Only unsigned values can be rotated. |
| 421 | 421 | /// Negative shift values results in shift modulo the bit count. |
| 422 | pub fn rotr(comptime T: type, x: T, r: var) T { | |
| 422 | pub fn rotr(comptime T: type, x: T, r: anytype) T { | |
| 423 | 423 | if (T.is_signed) { |
| 424 | 424 | @compileError("cannot rotate signed integer"); |
| 425 | 425 | } else { |
| ... | ... | @@ -438,7 +438,7 @@ test "math.rotr" { |
| 438 | 438 | |
| 439 | 439 | /// Rotates left. Only unsigned values can be rotated. |
| 440 | 440 | /// Negative shift values results in shift modulo the bit count. |
| 441 | pub fn rotl(comptime T: type, x: T, r: var) T { | |
| 441 | pub fn rotl(comptime T: type, x: T, r: anytype) T { | |
| 442 | 442 | if (T.is_signed) { |
| 443 | 443 | @compileError("cannot rotate signed integer"); |
| 444 | 444 | } else { |
| ... | ... | @@ -541,7 +541,7 @@ fn testOverflow() void { |
| 541 | 541 | testing.expect((shlExact(i32, 0b11, 4) catch unreachable) == 0b110000); |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | pub fn absInt(x: var) !@TypeOf(x) { | |
| 544 | pub fn absInt(x: anytype) !@TypeOf(x) { | |
| 545 | 545 | const T = @TypeOf(x); |
| 546 | 546 | comptime assert(@typeInfo(T) == .Int); // must pass an integer to absInt |
| 547 | 547 | comptime assert(T.is_signed); // must pass a signed integer to absInt |
| ... | ... | @@ -689,7 +689,7 @@ fn testRem() void { |
| 689 | 689 | |
| 690 | 690 | /// Returns the absolute value of the integer parameter. |
| 691 | 691 | /// Result is an unsigned integer. |
| 692 | pub fn absCast(x: var) switch (@typeInfo(@TypeOf(x))) { | |
| 692 | pub fn absCast(x: anytype) switch (@typeInfo(@TypeOf(x))) { | |
| 693 | 693 | .ComptimeInt => comptime_int, |
| 694 | 694 | .Int => |intInfo| std.meta.Int(false, intInfo.bits), |
| 695 | 695 | else => @compileError("absCast only accepts integers"), |
| ... | ... | @@ -724,7 +724,7 @@ test "math.absCast" { |
| 724 | 724 | |
| 725 | 725 | /// Returns the negation of the integer parameter. |
| 726 | 726 | /// Result is a signed integer. |
| 727 | pub fn negateCast(x: var) !std.meta.Int(true, @TypeOf(x).bit_count) { | |
| 727 | pub fn negateCast(x: anytype) !std.meta.Int(true, @TypeOf(x).bit_count) { | |
| 728 | 728 | if (@TypeOf(x).is_signed) return negate(x); |
| 729 | 729 | |
| 730 | 730 | const int = std.meta.Int(true, @TypeOf(x).bit_count); |
| ... | ... | @@ -747,7 +747,7 @@ test "math.negateCast" { |
| 747 | 747 | |
| 748 | 748 | /// Cast an integer to a different integer type. If the value doesn't fit, |
| 749 | 749 | /// return an error. |
| 750 | pub fn cast(comptime T: type, x: var) (error{Overflow}!T) { | |
| 750 | pub fn cast(comptime T: type, x: anytype) (error{Overflow}!T) { | |
| 751 | 751 | comptime assert(@typeInfo(T) == .Int); // must pass an integer |
| 752 | 752 | comptime assert(@typeInfo(@TypeOf(x)) == .Int); // must pass an integer |
| 753 | 753 | if (maxInt(@TypeOf(x)) > maxInt(T) and x > maxInt(T)) { |
| ... | ... | @@ -772,7 +772,7 @@ test "math.cast" { |
| 772 | 772 | pub const AlignCastError = error{UnalignedMemory}; |
| 773 | 773 | |
| 774 | 774 | /// Align cast a pointer but return an error if it's the wrong alignment |
| 775 | pub fn alignCast(comptime alignment: u29, ptr: var) AlignCastError!@TypeOf(@alignCast(alignment, ptr)) { | |
| 775 | pub fn alignCast(comptime alignment: u29, ptr: anytype) AlignCastError!@TypeOf(@alignCast(alignment, ptr)) { | |
| 776 | 776 | const addr = @ptrToInt(ptr); |
| 777 | 777 | if (addr % alignment != 0) { |
| 778 | 778 | return error.UnalignedMemory; |
| ... | ... | @@ -780,7 +780,7 @@ pub fn alignCast(comptime alignment: u29, ptr: var) AlignCastError!@TypeOf(@alig |
| 780 | 780 | return @alignCast(alignment, ptr); |
| 781 | 781 | } |
| 782 | 782 | |
| 783 | pub fn isPowerOfTwo(v: var) bool { | |
| 783 | pub fn isPowerOfTwo(v: anytype) bool { | |
| 784 | 784 | assert(v != 0); |
| 785 | 785 | return (v & (v - 1)) == 0; |
| 786 | 786 | } |
| ... | ... | @@ -897,7 +897,7 @@ test "std.math.log2_int_ceil" { |
| 897 | 897 | testing.expect(log2_int_ceil(u32, 10) == 4); |
| 898 | 898 | } |
| 899 | 899 | |
| 900 | pub fn lossyCast(comptime T: type, value: var) T { | |
| 900 | pub fn lossyCast(comptime T: type, value: anytype) T { | |
| 901 | 901 | switch (@typeInfo(@TypeOf(value))) { |
| 902 | 902 | .Int => return @intToFloat(T, value), |
| 903 | 903 | .Float => return @floatCast(T, value), |
| ... | ... | @@ -1031,7 +1031,7 @@ pub const Order = enum { |
| 1031 | 1031 | }; |
| 1032 | 1032 | |
| 1033 | 1033 | /// Given two numbers, this function returns the order they are with respect to each other. |
| 1034 | pub fn order(a: var, b: var) Order { | |
| 1034 | pub fn order(a: anytype, b: anytype) Order { | |
| 1035 | 1035 | if (a == b) { |
| 1036 | 1036 | return .eq; |
| 1037 | 1037 | } else if (a < b) { |
| ... | ... | @@ -1062,7 +1062,7 @@ pub const CompareOperator = enum { |
| 1062 | 1062 | /// This function does the same thing as comparison operators, however the |
| 1063 | 1063 | /// operator is a runtime-known enum value. Works on any operands that |
| 1064 | 1064 | /// support comparison operators. |
| 1065 | pub fn compare(a: var, op: CompareOperator, b: var) bool { | |
| 1065 | pub fn compare(a: anytype, op: CompareOperator, b: anytype) bool { | |
| 1066 | 1066 | return switch (op) { |
| 1067 | 1067 | .lt => a < b, |
| 1068 | 1068 | .lte => a <= b, |
lib/std/math/acos.zig+1-1| ... | ... | @@ -12,7 +12,7 @@ const expect = std.testing.expect; |
| 12 | 12 | /// |
| 13 | 13 | /// Special cases: |
| 14 | 14 | /// - acos(x) = nan if x < -1 or x > 1 |
| 15 | pub fn acos(x: var) @TypeOf(x) { | |
| 15 | pub fn acos(x: anytype) @TypeOf(x) { | |
| 16 | 16 | const T = @TypeOf(x); |
| 17 | 17 | return switch (T) { |
| 18 | 18 | f32 => acos32(x), |
lib/std/math/acosh.zig+1-1| ... | ... | @@ -14,7 +14,7 @@ const expect = std.testing.expect; |
| 14 | 14 | /// Special cases: |
| 15 | 15 | /// - acosh(x) = snan if x < 1 |
| 16 | 16 | /// - acosh(nan) = nan |
| 17 | pub fn acosh(x: var) @TypeOf(x) { | |
| 17 | pub fn acosh(x: anytype) @TypeOf(x) { | |
| 18 | 18 | const T = @TypeOf(x); |
| 19 | 19 | return switch (T) { |
| 20 | 20 | f32 => acosh32(x), |
lib/std/math/asin.zig+1-1| ... | ... | @@ -13,7 +13,7 @@ const expect = std.testing.expect; |
| 13 | 13 | /// Special Cases: |
| 14 | 14 | /// - asin(+-0) = +-0 |
| 15 | 15 | /// - asin(x) = nan if x < -1 or x > 1 |
| 16 | pub fn asin(x: var) @TypeOf(x) { | |
| 16 | pub fn asin(x: anytype) @TypeOf(x) { | |
| 17 | 17 | const T = @TypeOf(x); |
| 18 | 18 | return switch (T) { |
| 19 | 19 | f32 => asin32(x), |
lib/std/math/asinh.zig+1-1| ... | ... | @@ -15,7 +15,7 @@ const maxInt = std.math.maxInt; |
| 15 | 15 | /// - asinh(+-0) = +-0 |
| 16 | 16 | /// - asinh(+-inf) = +-inf |
| 17 | 17 | /// - asinh(nan) = nan |
| 18 | pub fn asinh(x: var) @TypeOf(x) { | |
| 18 | pub fn asinh(x: anytype) @TypeOf(x) { | |
| 19 | 19 | const T = @TypeOf(x); |
| 20 | 20 | return switch (T) { |
| 21 | 21 | f32 => asinh32(x), |
lib/std/math/atan.zig+1-1| ... | ... | @@ -13,7 +13,7 @@ const expect = std.testing.expect; |
| 13 | 13 | /// Special Cases: |
| 14 | 14 | /// - atan(+-0) = +-0 |
| 15 | 15 | /// - atan(+-inf) = +-pi/2 |
| 16 | pub fn atan(x: var) @TypeOf(x) { | |
| 16 | pub fn atan(x: anytype) @TypeOf(x) { | |
| 17 | 17 | const T = @TypeOf(x); |
| 18 | 18 | return switch (T) { |
| 19 | 19 | f32 => atan32(x), |
lib/std/math/atanh.zig+1-1| ... | ... | @@ -15,7 +15,7 @@ const maxInt = std.math.maxInt; |
| 15 | 15 | /// - atanh(+-1) = +-inf with signal |
| 16 | 16 | /// - atanh(x) = nan if |x| > 1 with signal |
| 17 | 17 | /// - atanh(nan) = nan |
| 18 | pub fn atanh(x: var) @TypeOf(x) { | |
| 18 | pub fn atanh(x: anytype) @TypeOf(x) { | |
| 19 | 19 | const T = @TypeOf(x); |
| 20 | 20 | return switch (T) { |
| 21 | 21 | f32 => atanh_32(x), |
lib/std/math/big/int.zig+10-10| ... | ... | @@ -12,7 +12,7 @@ const assert = std.debug.assert; |
| 12 | 12 | |
| 13 | 13 | /// Returns the number of limbs needed to store `scalar`, which must be a |
| 14 | 14 | /// primitive integer value. |
| 15 | pub fn calcLimbLen(scalar: var) usize { | |
| 15 | pub fn calcLimbLen(scalar: anytype) usize { | |
| 16 | 16 | const T = @TypeOf(scalar); |
| 17 | 17 | switch (@typeInfo(T)) { |
| 18 | 18 | .Int => |info| { |
| ... | ... | @@ -110,7 +110,7 @@ pub const Mutable = struct { |
| 110 | 110 | /// `value` is a primitive integer type. |
| 111 | 111 | /// Asserts the value fits within the provided `limbs_buffer`. |
| 112 | 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 | 114 | limbs_buffer[0] = 0; |
| 115 | 115 | var self: Mutable = .{ |
| 116 | 116 | .limbs = limbs_buffer, |
| ... | ... | @@ -169,7 +169,7 @@ pub const Mutable = struct { |
| 169 | 169 | /// Asserts the value fits within the limbs buffer. |
| 170 | 170 | /// Note: `calcLimbLen` can be used to figure out how big the limbs buffer |
| 171 | 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 | 173 | const T = @TypeOf(value); |
| 174 | 174 | |
| 175 | 175 | switch (@typeInfo(T)) { |
| ... | ... | @@ -281,7 +281,7 @@ pub const Mutable = struct { |
| 281 | 281 | /// |
| 282 | 282 | /// Asserts the result fits in `r`. An upper bound on the number of limbs needed by |
| 283 | 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 | 285 | var limbs: [calcLimbLen(scalar)]Limb = undefined; |
| 286 | 286 | const operand = init(&limbs, scalar).toConst(); |
| 287 | 287 | return add(r, a, operand); |
| ... | ... | @@ -1058,7 +1058,7 @@ pub const Const = struct { |
| 1058 | 1058 | self: Const, |
| 1059 | 1059 | comptime fmt: []const u8, |
| 1060 | 1060 | options: std.fmt.FormatOptions, |
| 1061 | out_stream: var, | |
| 1061 | out_stream: anytype, | |
| 1062 | 1062 | ) !void { |
| 1063 | 1063 | comptime var radix = 10; |
| 1064 | 1064 | comptime var uppercase = false; |
| ... | ... | @@ -1261,7 +1261,7 @@ pub const Const = struct { |
| 1261 | 1261 | } |
| 1262 | 1262 | |
| 1263 | 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 | 1265 | var limbs: [calcLimbLen(scalar)]Limb = undefined; |
| 1266 | 1266 | const rhs = Mutable.init(&limbs, scalar); |
| 1267 | 1267 | return order(lhs, rhs.toConst()); |
| ... | ... | @@ -1333,7 +1333,7 @@ pub const Managed = struct { |
| 1333 | 1333 | /// Creates a new `Managed` with value `value`. |
| 1334 | 1334 | /// |
| 1335 | 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 | 1337 | var s = try Managed.init(allocator); |
| 1338 | 1338 | try s.set(value); |
| 1339 | 1339 | return s; |
| ... | ... | @@ -1496,7 +1496,7 @@ pub const Managed = struct { |
| 1496 | 1496 | } |
| 1497 | 1497 | |
| 1498 | 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 | 1500 | try self.ensureCapacity(calcLimbLen(value)); |
| 1501 | 1501 | var m = self.toMutable(); |
| 1502 | 1502 | m.set(value); |
| ... | ... | @@ -1549,7 +1549,7 @@ pub const Managed = struct { |
| 1549 | 1549 | self: Managed, |
| 1550 | 1550 | comptime fmt: []const u8, |
| 1551 | 1551 | options: std.fmt.FormatOptions, |
| 1552 | out_stream: var, | |
| 1552 | out_stream: anytype, | |
| 1553 | 1553 | ) !void { |
| 1554 | 1554 | return self.toConst().format(fmt, options, out_stream); |
| 1555 | 1555 | } |
| ... | ... | @@ -1607,7 +1607,7 @@ pub const Managed = struct { |
| 1607 | 1607 | /// scalar is a primitive integer type. |
| 1608 | 1608 | /// |
| 1609 | 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 | 1611 | try r.ensureCapacity(math.max(a.limbs.len, calcLimbLen(scalar)) + 1); |
| 1612 | 1612 | var m = r.toMutable(); |
| 1613 | 1613 | m.addScalar(a, scalar); |
lib/std/math/big/rational.zig+2-2| ... | ... | @@ -43,7 +43,7 @@ pub const Rational = struct { |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 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 | 47 | try self.p.set(a); |
| 48 | 48 | try self.q.set(1); |
| 49 | 49 | } |
| ... | ... | @@ -280,7 +280,7 @@ pub const Rational = struct { |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 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 | 284 | try self.p.set(p); |
| 285 | 285 | try self.q.set(q); |
| 286 | 286 |
lib/std/math/cbrt.zig+1-1| ... | ... | @@ -14,7 +14,7 @@ const expect = std.testing.expect; |
| 14 | 14 | /// - cbrt(+-0) = +-0 |
| 15 | 15 | /// - cbrt(+-inf) = +-inf |
| 16 | 16 | /// - cbrt(nan) = nan |
| 17 | pub fn cbrt(x: var) @TypeOf(x) { | |
| 17 | pub fn cbrt(x: anytype) @TypeOf(x) { | |
| 18 | 18 | const T = @TypeOf(x); |
| 19 | 19 | return switch (T) { |
| 20 | 20 | f32 => cbrt32(x), |
lib/std/math/ceil.zig+1-1| ... | ... | @@ -15,7 +15,7 @@ const expect = std.testing.expect; |
| 15 | 15 | /// - ceil(+-0) = +-0 |
| 16 | 16 | /// - ceil(+-inf) = +-inf |
| 17 | 17 | /// - ceil(nan) = nan |
| 18 | pub fn ceil(x: var) @TypeOf(x) { | |
| 18 | pub fn ceil(x: anytype) @TypeOf(x) { | |
| 19 | 19 | const T = @TypeOf(x); |
| 20 | 20 | return switch (T) { |
| 21 | 21 | f32 => ceil32(x), |
lib/std/math/complex/abs.zig+1-1| ... | ... | @@ -5,7 +5,7 @@ const cmath = math.complex; |
| 5 | 5 | const Complex = cmath.Complex; |
| 6 | 6 | |
| 7 | 7 | /// Returns the absolute value (modulus) of z. |
| 8 | pub fn abs(z: var) @TypeOf(z.re) { | |
| 8 | pub fn abs(z: anytype) @TypeOf(z.re) { | |
| 9 | 9 | const T = @TypeOf(z.re); |
| 10 | 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 | 5 | const Complex = cmath.Complex; |
| 6 | 6 | |
| 7 | 7 | /// Returns the arc-cosine of z. |
| 8 | pub fn acos(z: var) Complex(@TypeOf(z.re)) { | |
| 8 | pub fn acos(z: anytype) Complex(@TypeOf(z.re)) { | |
| 9 | 9 | const T = @TypeOf(z.re); |
| 10 | 10 | const q = cmath.asin(z); |
| 11 | 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 | 5 | const Complex = cmath.Complex; |
| 6 | 6 | |
| 7 | 7 | /// Returns the hyperbolic arc-cosine of z. |
| 8 | pub fn acosh(z: var) Complex(@TypeOf(z.re)) { | |
| 8 | pub fn acosh(z: anytype) Complex(@TypeOf(z.re)) { | |
| 9 | 9 | const T = @TypeOf(z.re); |
| 10 | 10 | const q = cmath.acos(z); |
| 11 | 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 | 5 | const Complex = cmath.Complex; |
| 6 | 6 | |
| 7 | 7 | /// Returns the angular component (in radians) of z. |
| 8 | pub fn arg(z: var) @TypeOf(z.re) { | |
| 8 | pub fn arg(z: anytype) @TypeOf(z.re) { | |
| 9 | 9 | const T = @TypeOf(z.re); |
| 10 | 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 | 5 | const Complex = cmath.Complex; |
| 6 | 6 | |
| 7 | 7 | // Returns the arc-sine of z. |
| 8 | pub fn asin(z: var) Complex(@TypeOf(z.re)) { | |
| 8 | pub fn asin(z: anytype) Complex(@TypeOf(z.re)) { | |
| 9 | 9 | const T = @TypeOf(z.re); |
| 10 | 10 | const x = z.re; |
| 11 | 11 | const y = z.im; |
lib/std/math/complex/asinh.zig+1-1| ... | ... | @@ -5,7 +5,7 @@ const cmath = math.complex; |
| 5 | 5 | const Complex = cmath.Complex; |
| 6 | 6 | |
| 7 | 7 | /// Returns the hyperbolic arc-sine of z. |
| 8 | pub fn asinh(z: var) Complex(@TypeOf(z.re)) { | |
| 8 | pub fn asinh(z: anytype) Complex(@TypeOf(z.re)) { | |
| 9 | 9 | const T = @TypeOf(z.re); |
| 10 | 10 | const q = Complex(T).new(-z.im, z.re); |
| 11 | 11 | const r = cmath.asin(q); |
lib/std/math/complex/atan.zig+1-1| ... | ... | @@ -12,7 +12,7 @@ const cmath = math.complex; |
| 12 | 12 | const Complex = cmath.Complex; |
| 13 | 13 | |
| 14 | 14 | /// Returns the arc-tangent of z. |
| 15 | pub fn atan(z: var) @TypeOf(z) { | |
| 15 | pub fn atan(z: anytype) @TypeOf(z) { | |
| 16 | 16 | const T = @TypeOf(z.re); |
| 17 | 17 | return switch (T) { |
| 18 | 18 | f32 => atan32(z), |
lib/std/math/complex/atanh.zig+1-1| ... | ... | @@ -5,7 +5,7 @@ const cmath = math.complex; |
| 5 | 5 | const Complex = cmath.Complex; |
| 6 | 6 | |
| 7 | 7 | /// Returns the hyperbolic arc-tangent of z. |
| 8 | pub fn atanh(z: var) Complex(@TypeOf(z.re)) { | |
| 8 | pub fn atanh(z: anytype) Complex(@TypeOf(z.re)) { | |
| 9 | 9 | const T = @TypeOf(z.re); |
| 10 | 10 | const q = Complex(T).new(-z.im, z.re); |
| 11 | 11 | const r = cmath.atan(q); |
lib/std/math/complex/conj.zig+1-1| ... | ... | @@ -5,7 +5,7 @@ const cmath = math.complex; |
| 5 | 5 | const Complex = cmath.Complex; |
| 6 | 6 | |
| 7 | 7 | /// Returns the complex conjugate of z. |
| 8 | pub fn conj(z: var) Complex(@TypeOf(z.re)) { | |
| 8 | pub fn conj(z: anytype) Complex(@TypeOf(z.re)) { | |
| 9 | 9 | const T = @TypeOf(z.re); |
| 10 | 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 | 5 | const Complex = cmath.Complex; |
| 6 | 6 | |
| 7 | 7 | /// Returns the cosine of z. |
| 8 | pub fn cos(z: var) Complex(@TypeOf(z.re)) { | |
| 8 | pub fn cos(z: anytype) Complex(@TypeOf(z.re)) { | |
| 9 | 9 | const T = @TypeOf(z.re); |
| 10 | 10 | const p = Complex(T).new(-z.im, z.re); |
| 11 | 11 | return cmath.cosh(p); |
lib/std/math/complex/cosh.zig+1-1| ... | ... | @@ -14,7 +14,7 @@ const Complex = cmath.Complex; |
| 14 | 14 | const ldexp_cexp = @import("ldexp.zig").ldexp_cexp; |
| 15 | 15 | |
| 16 | 16 | /// Returns the hyperbolic arc-cosine of z. |
| 17 | pub fn cosh(z: var) Complex(@TypeOf(z.re)) { | |
| 17 | pub fn cosh(z: anytype) Complex(@TypeOf(z.re)) { | |
| 18 | 18 | const T = @TypeOf(z.re); |
| 19 | 19 | return switch (T) { |
| 20 | 20 | f32 => cosh32(z), |
lib/std/math/complex/exp.zig+1-1| ... | ... | @@ -14,7 +14,7 @@ const Complex = cmath.Complex; |
| 14 | 14 | const ldexp_cexp = @import("ldexp.zig").ldexp_cexp; |
| 15 | 15 | |
| 16 | 16 | /// Returns e raised to the power of z (e^z). |
| 17 | pub fn exp(z: var) @TypeOf(z) { | |
| 17 | pub fn exp(z: anytype) @TypeOf(z) { | |
| 18 | 18 | const T = @TypeOf(z.re); |
| 19 | 19 | |
| 20 | 20 | return switch (T) { |
lib/std/math/complex/ldexp.zig+1-1| ... | ... | @@ -11,7 +11,7 @@ const cmath = math.complex; |
| 11 | 11 | const Complex = cmath.Complex; |
| 12 | 12 | |
| 13 | 13 | /// Returns exp(z) scaled to avoid overflow. |
| 14 | pub fn ldexp_cexp(z: var, expt: i32) @TypeOf(z) { | |
| 14 | pub fn ldexp_cexp(z: anytype, expt: i32) @TypeOf(z) { | |
| 15 | 15 | const T = @TypeOf(z.re); |
| 16 | 16 | |
| 17 | 17 | return switch (T) { |
lib/std/math/complex/log.zig+1-1| ... | ... | @@ -5,7 +5,7 @@ const cmath = math.complex; |
| 5 | 5 | const Complex = cmath.Complex; |
| 6 | 6 | |
| 7 | 7 | /// Returns the natural logarithm of z. |
| 8 | pub fn log(z: var) Complex(@TypeOf(z.re)) { | |
| 8 | pub fn log(z: anytype) Complex(@TypeOf(z.re)) { | |
| 9 | 9 | const T = @TypeOf(z.re); |
| 10 | 10 | const r = cmath.abs(z); |
| 11 | 11 | const phi = cmath.arg(z); |
lib/std/math/complex/proj.zig+1-1| ... | ... | @@ -5,7 +5,7 @@ const cmath = math.complex; |
| 5 | 5 | const Complex = cmath.Complex; |
| 6 | 6 | |
| 7 | 7 | /// Returns the projection of z onto the riemann sphere. |
| 8 | pub fn proj(z: var) Complex(@TypeOf(z.re)) { | |
| 8 | pub fn proj(z: anytype) Complex(@TypeOf(z.re)) { | |
| 9 | 9 | const T = @TypeOf(z.re); |
| 10 | 10 | |
| 11 | 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 | 5 | const Complex = cmath.Complex; |
| 6 | 6 | |
| 7 | 7 | /// Returns the sine of z. |
| 8 | pub fn sin(z: var) Complex(@TypeOf(z.re)) { | |
| 8 | pub fn sin(z: anytype) Complex(@TypeOf(z.re)) { | |
| 9 | 9 | const T = @TypeOf(z.re); |
| 10 | 10 | const p = Complex(T).new(-z.im, z.re); |
| 11 | 11 | const q = cmath.sinh(p); |
lib/std/math/complex/sinh.zig+1-1| ... | ... | @@ -14,7 +14,7 @@ const Complex = cmath.Complex; |
| 14 | 14 | const ldexp_cexp = @import("ldexp.zig").ldexp_cexp; |
| 15 | 15 | |
| 16 | 16 | /// Returns the hyperbolic sine of z. |
| 17 | pub fn sinh(z: var) @TypeOf(z) { | |
| 17 | pub fn sinh(z: anytype) @TypeOf(z) { | |
| 18 | 18 | const T = @TypeOf(z.re); |
| 19 | 19 | return switch (T) { |
| 20 | 20 | f32 => sinh32(z), |
lib/std/math/complex/sqrt.zig+1-1| ... | ... | @@ -12,7 +12,7 @@ const Complex = cmath.Complex; |
| 12 | 12 | |
| 13 | 13 | /// Returns the square root of z. The real and imaginary parts of the result have the same sign |
| 14 | 14 | /// as the imaginary part of z. |
| 15 | pub fn sqrt(z: var) @TypeOf(z) { | |
| 15 | pub fn sqrt(z: anytype) @TypeOf(z) { | |
| 16 | 16 | const T = @TypeOf(z.re); |
| 17 | 17 | |
| 18 | 18 | return switch (T) { |
lib/std/math/complex/tan.zig+1-1| ... | ... | @@ -5,7 +5,7 @@ const cmath = math.complex; |
| 5 | 5 | const Complex = cmath.Complex; |
| 6 | 6 | |
| 7 | 7 | /// Returns the tanget of z. |
| 8 | pub fn tan(z: var) Complex(@TypeOf(z.re)) { | |
| 8 | pub fn tan(z: anytype) Complex(@TypeOf(z.re)) { | |
| 9 | 9 | const T = @TypeOf(z.re); |
| 10 | 10 | const q = Complex(T).new(-z.im, z.re); |
| 11 | 11 | const r = cmath.tanh(q); |
lib/std/math/complex/tanh.zig+1-1| ... | ... | @@ -12,7 +12,7 @@ const cmath = math.complex; |
| 12 | 12 | const Complex = cmath.Complex; |
| 13 | 13 | |
| 14 | 14 | /// Returns the hyperbolic tangent of z. |
| 15 | pub fn tanh(z: var) @TypeOf(z) { | |
| 15 | pub fn tanh(z: anytype) @TypeOf(z) { | |
| 16 | 16 | const T = @TypeOf(z.re); |
| 17 | 17 | return switch (T) { |
| 18 | 18 | f32 => tanh32(z), |
lib/std/math/cos.zig+1-1| ... | ... | @@ -13,7 +13,7 @@ const expect = std.testing.expect; |
| 13 | 13 | /// Special Cases: |
| 14 | 14 | /// - cos(+-inf) = nan |
| 15 | 15 | /// - cos(nan) = nan |
| 16 | pub fn cos(x: var) @TypeOf(x) { | |
| 16 | pub fn cos(x: anytype) @TypeOf(x) { | |
| 17 | 17 | const T = @TypeOf(x); |
| 18 | 18 | return switch (T) { |
| 19 | 19 | f32 => cos_(f32, x), |
lib/std/math/cosh.zig+1-1| ... | ... | @@ -17,7 +17,7 @@ const maxInt = std.math.maxInt; |
| 17 | 17 | /// - cosh(+-0) = 1 |
| 18 | 18 | /// - cosh(+-inf) = +inf |
| 19 | 19 | /// - cosh(nan) = nan |
| 20 | pub fn cosh(x: var) @TypeOf(x) { | |
| 20 | pub fn cosh(x: anytype) @TypeOf(x) { | |
| 21 | 21 | const T = @TypeOf(x); |
| 22 | 22 | return switch (T) { |
| 23 | 23 | f32 => cosh32(x), |
lib/std/math/exp.zig+1-1| ... | ... | @@ -14,7 +14,7 @@ const builtin = @import("builtin"); |
| 14 | 14 | /// Special Cases: |
| 15 | 15 | /// - exp(+inf) = +inf |
| 16 | 16 | /// - exp(nan) = nan |
| 17 | pub fn exp(x: var) @TypeOf(x) { | |
| 17 | pub fn exp(x: anytype) @TypeOf(x) { | |
| 18 | 18 | const T = @TypeOf(x); |
| 19 | 19 | return switch (T) { |
| 20 | 20 | f32 => exp32(x), |
lib/std/math/exp2.zig+1-1| ... | ... | @@ -13,7 +13,7 @@ const expect = std.testing.expect; |
| 13 | 13 | /// Special Cases: |
| 14 | 14 | /// - exp2(+inf) = +inf |
| 15 | 15 | /// - exp2(nan) = nan |
| 16 | pub fn exp2(x: var) @TypeOf(x) { | |
| 16 | pub fn exp2(x: anytype) @TypeOf(x) { | |
| 17 | 17 | const T = @TypeOf(x); |
| 18 | 18 | return switch (T) { |
| 19 | 19 | f32 => exp2_32(x), |
lib/std/math/expm1.zig+1-1| ... | ... | @@ -18,7 +18,7 @@ const expect = std.testing.expect; |
| 18 | 18 | /// - expm1(+inf) = +inf |
| 19 | 19 | /// - expm1(-inf) = -1 |
| 20 | 20 | /// - expm1(nan) = nan |
| 21 | pub fn expm1(x: var) @TypeOf(x) { | |
| 21 | pub fn expm1(x: anytype) @TypeOf(x) { | |
| 22 | 22 | const T = @TypeOf(x); |
| 23 | 23 | return switch (T) { |
| 24 | 24 | f32 => expm1_32(x), |
lib/std/math/expo2.zig+1-1| ... | ... | @@ -7,7 +7,7 @@ |
| 7 | 7 | const math = @import("../math.zig"); |
| 8 | 8 | |
| 9 | 9 | /// Returns exp(x) / 2 for x >= log(maxFloat(T)). |
| 10 | pub fn expo2(x: var) @TypeOf(x) { | |
| 10 | pub fn expo2(x: anytype) @TypeOf(x) { | |
| 11 | 11 | const T = @TypeOf(x); |
| 12 | 12 | return switch (T) { |
| 13 | 13 | f32 => expo2f(x), |
lib/std/math/fabs.zig+1-1| ... | ... | @@ -14,7 +14,7 @@ const maxInt = std.math.maxInt; |
| 14 | 14 | /// Special Cases: |
| 15 | 15 | /// - fabs(+-inf) = +inf |
| 16 | 16 | /// - fabs(nan) = nan |
| 17 | pub fn fabs(x: var) @TypeOf(x) { | |
| 17 | pub fn fabs(x: anytype) @TypeOf(x) { | |
| 18 | 18 | const T = @TypeOf(x); |
| 19 | 19 | return switch (T) { |
| 20 | 20 | f16 => fabs16(x), |
lib/std/math/floor.zig+1-1| ... | ... | @@ -15,7 +15,7 @@ const math = std.math; |
| 15 | 15 | /// - floor(+-0) = +-0 |
| 16 | 16 | /// - floor(+-inf) = +-inf |
| 17 | 17 | /// - floor(nan) = nan |
| 18 | pub fn floor(x: var) @TypeOf(x) { | |
| 18 | pub fn floor(x: anytype) @TypeOf(x) { | |
| 19 | 19 | const T = @TypeOf(x); |
| 20 | 20 | return switch (T) { |
| 21 | 21 | f16 => floor16(x), |
lib/std/math/frexp.zig+1-1| ... | ... | @@ -24,7 +24,7 @@ pub const frexp64_result = frexp_result(f64); |
| 24 | 24 | /// - frexp(+-0) = +-0, 0 |
| 25 | 25 | /// - frexp(+-inf) = +-inf, 0 |
| 26 | 26 | /// - frexp(nan) = nan, undefined |
| 27 | pub fn frexp(x: var) frexp_result(@TypeOf(x)) { | |
| 27 | pub fn frexp(x: anytype) frexp_result(@TypeOf(x)) { | |
| 28 | 28 | const T = @TypeOf(x); |
| 29 | 29 | return switch (T) { |
| 30 | 30 | f32 => frexp32(x), |
lib/std/math/ilogb.zig+1-1| ... | ... | @@ -16,7 +16,7 @@ const minInt = std.math.minInt; |
| 16 | 16 | /// - ilogb(+-inf) = maxInt(i32) |
| 17 | 17 | /// - ilogb(0) = maxInt(i32) |
| 18 | 18 | /// - ilogb(nan) = maxInt(i32) |
| 19 | pub fn ilogb(x: var) i32 { | |
| 19 | pub fn ilogb(x: anytype) i32 { | |
| 20 | 20 | const T = @TypeOf(x); |
| 21 | 21 | return switch (T) { |
| 22 | 22 | f32 => ilogb32(x), |
lib/std/math/isfinite.zig+1-1| ... | ... | @@ -4,7 +4,7 @@ const expect = std.testing.expect; |
| 4 | 4 | const maxInt = std.math.maxInt; |
| 5 | 5 | |
| 6 | 6 | /// Returns whether x is a finite value. |
| 7 | pub fn isFinite(x: var) bool { | |
| 7 | pub fn isFinite(x: anytype) bool { | |
| 8 | 8 | const T = @TypeOf(x); |
| 9 | 9 | switch (T) { |
| 10 | 10 | f16 => { |
lib/std/math/isinf.zig+3-3| ... | ... | @@ -4,7 +4,7 @@ const expect = std.testing.expect; |
| 4 | 4 | const maxInt = std.math.maxInt; |
| 5 | 5 | |
| 6 | 6 | /// Returns whether x is an infinity, ignoring sign. |
| 7 | pub fn isInf(x: var) bool { | |
| 7 | pub fn isInf(x: anytype) bool { | |
| 8 | 8 | const T = @TypeOf(x); |
| 9 | 9 | switch (T) { |
| 10 | 10 | f16 => { |
| ... | ... | @@ -30,7 +30,7 @@ pub fn isInf(x: var) bool { |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /// Returns whether x is an infinity with a positive sign. |
| 33 | pub fn isPositiveInf(x: var) bool { | |
| 33 | pub fn isPositiveInf(x: anytype) bool { | |
| 34 | 34 | const T = @TypeOf(x); |
| 35 | 35 | switch (T) { |
| 36 | 36 | f16 => { |
| ... | ... | @@ -52,7 +52,7 @@ pub fn isPositiveInf(x: var) bool { |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /// Returns whether x is an infinity with a negative sign. |
| 55 | pub fn isNegativeInf(x: var) bool { | |
| 55 | pub fn isNegativeInf(x: anytype) bool { | |
| 56 | 56 | const T = @TypeOf(x); |
| 57 | 57 | switch (T) { |
| 58 | 58 | f16 => { |
lib/std/math/isnan.zig+2-2| ... | ... | @@ -4,12 +4,12 @@ const expect = std.testing.expect; |
| 4 | 4 | const maxInt = std.math.maxInt; |
| 5 | 5 | |
| 6 | 6 | /// Returns whether x is a nan. |
| 7 | pub fn isNan(x: var) bool { | |
| 7 | pub fn isNan(x: anytype) bool { | |
| 8 | 8 | return x != x; |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | /// Returns whether x is a signalling nan. |
| 12 | pub fn isSignalNan(x: var) bool { | |
| 12 | pub fn isSignalNan(x: anytype) bool { | |
| 13 | 13 | // Note: A signalling nan is identical to a standard nan right now but may have a different bit |
| 14 | 14 | // representation in the future when required. |
| 15 | 15 | return isNan(x); |
lib/std/math/isnormal.zig+1-1| ... | ... | @@ -4,7 +4,7 @@ const expect = std.testing.expect; |
| 4 | 4 | const maxInt = std.math.maxInt; |
| 5 | 5 | |
| 6 | 6 | // Returns whether x has a normalized representation (i.e. integer part of mantissa is 1). |
| 7 | pub fn isNormal(x: var) bool { | |
| 7 | pub fn isNormal(x: anytype) bool { | |
| 8 | 8 | const T = @TypeOf(x); |
| 9 | 9 | switch (T) { |
| 10 | 10 | f16 => { |
lib/std/math/ln.zig+1-1| ... | ... | @@ -15,7 +15,7 @@ const expect = std.testing.expect; |
| 15 | 15 | /// - ln(0) = -inf |
| 16 | 16 | /// - ln(x) = nan if x < 0 |
| 17 | 17 | /// - ln(nan) = nan |
| 18 | pub fn ln(x: var) @TypeOf(x) { | |
| 18 | pub fn ln(x: anytype) @TypeOf(x) { | |
| 19 | 19 | const T = @TypeOf(x); |
| 20 | 20 | switch (@typeInfo(T)) { |
| 21 | 21 | .ComptimeFloat => { |
lib/std/math/log10.zig+1-1| ... | ... | @@ -16,7 +16,7 @@ const maxInt = std.math.maxInt; |
| 16 | 16 | /// - log10(0) = -inf |
| 17 | 17 | /// - log10(x) = nan if x < 0 |
| 18 | 18 | /// - log10(nan) = nan |
| 19 | pub fn log10(x: var) @TypeOf(x) { | |
| 19 | pub fn log10(x: anytype) @TypeOf(x) { | |
| 20 | 20 | const T = @TypeOf(x); |
| 21 | 21 | switch (@typeInfo(T)) { |
| 22 | 22 | .ComptimeFloat => { |
lib/std/math/log1p.zig+1-1| ... | ... | @@ -17,7 +17,7 @@ const expect = std.testing.expect; |
| 17 | 17 | /// - log1p(-1) = -inf |
| 18 | 18 | /// - log1p(x) = nan if x < -1 |
| 19 | 19 | /// - log1p(nan) = nan |
| 20 | pub fn log1p(x: var) @TypeOf(x) { | |
| 20 | pub fn log1p(x: anytype) @TypeOf(x) { | |
| 21 | 21 | const T = @TypeOf(x); |
| 22 | 22 | return switch (T) { |
| 23 | 23 | f32 => log1p_32(x), |
lib/std/math/log2.zig+1-1| ... | ... | @@ -16,7 +16,7 @@ const maxInt = std.math.maxInt; |
| 16 | 16 | /// - log2(0) = -inf |
| 17 | 17 | /// - log2(x) = nan if x < 0 |
| 18 | 18 | /// - log2(nan) = nan |
| 19 | pub fn log2(x: var) @TypeOf(x) { | |
| 19 | pub fn log2(x: anytype) @TypeOf(x) { | |
| 20 | 20 | const T = @TypeOf(x); |
| 21 | 21 | switch (@typeInfo(T)) { |
| 22 | 22 | .ComptimeFloat => { |
lib/std/math/modf.zig+1-1| ... | ... | @@ -24,7 +24,7 @@ pub const modf64_result = modf_result(f64); |
| 24 | 24 | /// Special Cases: |
| 25 | 25 | /// - modf(+-inf) = +-inf, nan |
| 26 | 26 | /// - modf(nan) = nan, nan |
| 27 | pub fn modf(x: var) modf_result(@TypeOf(x)) { | |
| 27 | pub fn modf(x: anytype) modf_result(@TypeOf(x)) { | |
| 28 | 28 | const T = @TypeOf(x); |
| 29 | 29 | return switch (T) { |
| 30 | 30 | f32 => modf32(x), |
lib/std/math/round.zig+1-1| ... | ... | @@ -15,7 +15,7 @@ const math = std.math; |
| 15 | 15 | /// - round(+-0) = +-0 |
| 16 | 16 | /// - round(+-inf) = +-inf |
| 17 | 17 | /// - round(nan) = nan |
| 18 | pub fn round(x: var) @TypeOf(x) { | |
| 18 | pub fn round(x: anytype) @TypeOf(x) { | |
| 19 | 19 | const T = @TypeOf(x); |
| 20 | 20 | return switch (T) { |
| 21 | 21 | f32 => round32(x), |
lib/std/math/scalbn.zig+1-1| ... | ... | @@ -9,7 +9,7 @@ const math = std.math; |
| 9 | 9 | const expect = std.testing.expect; |
| 10 | 10 | |
| 11 | 11 | /// Returns x * 2^n. |
| 12 | pub fn scalbn(x: var, n: i32) @TypeOf(x) { | |
| 12 | pub fn scalbn(x: anytype, n: i32) @TypeOf(x) { | |
| 13 | 13 | const T = @TypeOf(x); |
| 14 | 14 | return switch (T) { |
| 15 | 15 | f32 => scalbn32(x, n), |
lib/std/math/signbit.zig+1-1| ... | ... | @@ -3,7 +3,7 @@ const math = std.math; |
| 3 | 3 | const expect = std.testing.expect; |
| 4 | 4 | |
| 5 | 5 | /// Returns whether x is negative or negative 0. |
| 6 | pub fn signbit(x: var) bool { | |
| 6 | pub fn signbit(x: anytype) bool { | |
| 7 | 7 | const T = @TypeOf(x); |
| 8 | 8 | return switch (T) { |
| 9 | 9 | f16 => signbit16(x), |
lib/std/math/sin.zig+1-1| ... | ... | @@ -14,7 +14,7 @@ const expect = std.testing.expect; |
| 14 | 14 | /// - sin(+-0) = +-0 |
| 15 | 15 | /// - sin(+-inf) = nan |
| 16 | 16 | /// - sin(nan) = nan |
| 17 | pub fn sin(x: var) @TypeOf(x) { | |
| 17 | pub fn sin(x: anytype) @TypeOf(x) { | |
| 18 | 18 | const T = @TypeOf(x); |
| 19 | 19 | return switch (T) { |
| 20 | 20 | f32 => sin_(T, x), |
lib/std/math/sinh.zig+1-1| ... | ... | @@ -17,7 +17,7 @@ const maxInt = std.math.maxInt; |
| 17 | 17 | /// - sinh(+-0) = +-0 |
| 18 | 18 | /// - sinh(+-inf) = +-inf |
| 19 | 19 | /// - sinh(nan) = nan |
| 20 | pub fn sinh(x: var) @TypeOf(x) { | |
| 20 | pub fn sinh(x: anytype) @TypeOf(x) { | |
| 21 | 21 | const T = @TypeOf(x); |
| 22 | 22 | return switch (T) { |
| 23 | 23 | f32 => sinh32(x), |
lib/std/math/sqrt.zig+1-1| ... | ... | @@ -13,7 +13,7 @@ const maxInt = std.math.maxInt; |
| 13 | 13 | /// - sqrt(x) = nan if x < 0 |
| 14 | 14 | /// - sqrt(nan) = nan |
| 15 | 15 | /// TODO Decide if all this logic should be implemented directly in the @sqrt bultin function. |
| 16 | pub fn sqrt(x: var) Sqrt(@TypeOf(x)) { | |
| 16 | pub fn sqrt(x: anytype) Sqrt(@TypeOf(x)) { | |
| 17 | 17 | const T = @TypeOf(x); |
| 18 | 18 | switch (@typeInfo(T)) { |
| 19 | 19 | .Float, .ComptimeFloat => return @sqrt(x), |
lib/std/math/tan.zig+1-1| ... | ... | @@ -14,7 +14,7 @@ const expect = std.testing.expect; |
| 14 | 14 | /// - tan(+-0) = +-0 |
| 15 | 15 | /// - tan(+-inf) = nan |
| 16 | 16 | /// - tan(nan) = nan |
| 17 | pub fn tan(x: var) @TypeOf(x) { | |
| 17 | pub fn tan(x: anytype) @TypeOf(x) { | |
| 18 | 18 | const T = @TypeOf(x); |
| 19 | 19 | return switch (T) { |
| 20 | 20 | f32 => tan_(f32, x), |
lib/std/math/tanh.zig+1-1| ... | ... | @@ -17,7 +17,7 @@ const maxInt = std.math.maxInt; |
| 17 | 17 | /// - sinh(+-0) = +-0 |
| 18 | 18 | /// - sinh(+-inf) = +-1 |
| 19 | 19 | /// - sinh(nan) = nan |
| 20 | pub fn tanh(x: var) @TypeOf(x) { | |
| 20 | pub fn tanh(x: anytype) @TypeOf(x) { | |
| 21 | 21 | const T = @TypeOf(x); |
| 22 | 22 | return switch (T) { |
| 23 | 23 | f32 => tanh32(x), |
lib/std/math/trunc.zig+1-1| ... | ... | @@ -15,7 +15,7 @@ const maxInt = std.math.maxInt; |
| 15 | 15 | /// - trunc(+-0) = +-0 |
| 16 | 16 | /// - trunc(+-inf) = +-inf |
| 17 | 17 | /// - trunc(nan) = nan |
| 18 | pub fn trunc(x: var) @TypeOf(x) { | |
| 18 | pub fn trunc(x: anytype) @TypeOf(x) { | |
| 19 | 19 | const T = @TypeOf(x); |
| 20 | 20 | return switch (T) { |
| 21 | 21 | f32 => trunc32(x), |
lib/std/mem.zig+87-86| ... | ... | @@ -122,7 +122,7 @@ pub const Allocator = struct { |
| 122 | 122 | assert(resized_len >= new_byte_count); |
| 123 | 123 | @memset(old_mem.ptr + new_byte_count, undefined, resized_len - new_byte_count); |
| 124 | 124 | return old_mem.ptr[0..resized_len]; |
| 125 | } else |_| { } | |
| 125 | } else |_| {} | |
| 126 | 126 | } |
| 127 | 127 | if (new_byte_count <= old_mem.len and new_alignment <= old_alignment) { |
| 128 | 128 | return error.OutOfMemory; |
| ... | ... | @@ -156,7 +156,7 @@ pub const Allocator = struct { |
| 156 | 156 | |
| 157 | 157 | /// `ptr` should be the return value of `create`, or otherwise |
| 158 | 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 | 160 | const T = @TypeOf(ptr).Child; |
| 161 | 161 | if (@sizeOf(T) == 0) return; |
| 162 | 162 | const non_const_ptr = @intToPtr([*]u8, @ptrToInt(ptr)); |
| ... | ... | @@ -225,7 +225,7 @@ pub const Allocator = struct { |
| 225 | 225 | return self.allocAdvanced(T, alignment, n, .exact); |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | const Exact = enum {exact,at_least}; | |
| 228 | const Exact = enum { exact, at_least }; | |
| 229 | 229 | pub fn allocAdvanced( |
| 230 | 230 | self: *Allocator, |
| 231 | 231 | comptime T: type, |
| ... | ... | @@ -272,7 +272,7 @@ pub const Allocator = struct { |
| 272 | 272 | /// in `std.ArrayList.shrink`. |
| 273 | 273 | /// If you need guaranteed success, call `shrink`. |
| 274 | 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 | 276 | const Slice = @typeInfo(@TypeOf(old_mem)).Pointer; |
| 277 | 277 | break :t Error![]align(Slice.alignment) Slice.child; |
| 278 | 278 | } { |
| ... | ... | @@ -280,7 +280,7 @@ pub const Allocator = struct { |
| 280 | 280 | return self.reallocAdvanced(old_mem, old_alignment, new_n, .exact); |
| 281 | 281 | } |
| 282 | 282 | |
| 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 | 284 | const Slice = @typeInfo(@TypeOf(old_mem)).Pointer; |
| 285 | 285 | break :t Error![]align(Slice.alignment) Slice.child; |
| 286 | 286 | } { |
| ... | ... | @@ -291,7 +291,7 @@ pub const Allocator = struct { |
| 291 | 291 | // Deprecated: use `reallocAdvanced` |
| 292 | 292 | pub fn alignedRealloc( |
| 293 | 293 | self: *Allocator, |
| 294 | old_mem: var, | |
| 294 | old_mem: anytype, | |
| 295 | 295 | comptime new_alignment: u29, |
| 296 | 296 | new_n: usize, |
| 297 | 297 | ) Error![]align(new_alignment) @typeInfo(@TypeOf(old_mem)).Pointer.child { |
| ... | ... | @@ -303,7 +303,7 @@ pub const Allocator = struct { |
| 303 | 303 | /// allocation. |
| 304 | 304 | pub fn reallocAdvanced( |
| 305 | 305 | self: *Allocator, |
| 306 | old_mem: var, | |
| 306 | old_mem: anytype, | |
| 307 | 307 | comptime new_alignment: u29, |
| 308 | 308 | new_n: usize, |
| 309 | 309 | exact: Exact, |
| ... | ... | @@ -321,8 +321,7 @@ pub const Allocator = struct { |
| 321 | 321 | const old_byte_slice = mem.sliceAsBytes(old_mem); |
| 322 | 322 | const byte_count = math.mul(usize, @sizeOf(T), new_n) catch return Error.OutOfMemory; |
| 323 | 323 | // Note: can't set shrunk memory to undefined as memory shouldn't be modified on realloc failure |
| 324 | const new_byte_slice = try self.reallocBytes(old_byte_slice, Slice.alignment, byte_count, new_alignment, | |
| 325 | if (exact == .exact) @as(u29, 0) else @sizeOf(T)); | |
| 324 | const new_byte_slice = try self.reallocBytes(old_byte_slice, Slice.alignment, byte_count, new_alignment, if (exact == .exact) @as(u29, 0) else @sizeOf(T)); | |
| 326 | 325 | return mem.bytesAsSlice(T, @alignCast(new_alignment, new_byte_slice)); |
| 327 | 326 | } |
| 328 | 327 | |
| ... | ... | @@ -331,7 +330,7 @@ pub const Allocator = struct { |
| 331 | 330 | /// Shrink always succeeds, and `new_n` must be <= `old_mem.len`. |
| 332 | 331 | /// Returned slice has same alignment as old_mem. |
| 333 | 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 | 334 | const Slice = @typeInfo(@TypeOf(old_mem)).Pointer; |
| 336 | 335 | break :t []align(Slice.alignment) Slice.child; |
| 337 | 336 | } { |
| ... | ... | @@ -344,7 +343,7 @@ pub const Allocator = struct { |
| 344 | 343 | /// allocation. |
| 345 | 344 | pub fn alignedShrink( |
| 346 | 345 | self: *Allocator, |
| 347 | old_mem: var, | |
| 346 | old_mem: anytype, | |
| 348 | 347 | comptime new_alignment: u29, |
| 349 | 348 | new_n: usize, |
| 350 | 349 | ) []align(new_alignment) @typeInfo(@TypeOf(old_mem)).Pointer.child { |
| ... | ... | @@ -368,7 +367,7 @@ pub const Allocator = struct { |
| 368 | 367 | |
| 369 | 368 | /// Free an array allocated with `alloc`. To free a single item, |
| 370 | 369 | /// see `destroy`. |
| 371 | pub fn free(self: *Allocator, memory: var) void { | |
| 370 | pub fn free(self: *Allocator, memory: anytype) void { | |
| 372 | 371 | const Slice = @typeInfo(@TypeOf(memory)).Pointer; |
| 373 | 372 | const bytes = mem.sliceAsBytes(memory); |
| 374 | 373 | const bytes_len = bytes.len + if (Slice.sentinel != null) @sizeOf(Slice.child) else 0; |
| ... | ... | @@ -396,67 +395,69 @@ pub const Allocator = struct { |
| 396 | 395 | |
| 397 | 396 | /// Detects and asserts if the std.mem.Allocator interface is violated by the caller |
| 398 | 397 | /// or the allocator. |
| 399 | pub fn ValidationAllocator(comptime T: type) type { return struct { | |
| 400 | const Self = @This(); | |
| 401 | allocator: Allocator, | |
| 402 | underlying_allocator: T, | |
| 403 | pub fn init(allocator: T) @This() { | |
| 404 | return .{ | |
| 405 | .allocator = .{ | |
| 406 | .allocFn = alloc, | |
| 407 | .resizeFn = resize, | |
| 408 | }, | |
| 409 | .underlying_allocator = allocator, | |
| 410 | }; | |
| 411 | } | |
| 412 | fn getUnderlyingAllocatorPtr(self: *@This()) *Allocator { | |
| 413 | if (T == *Allocator) return self.underlying_allocator; | |
| 414 | if (*T == *Allocator) return &self.underlying_allocator; | |
| 415 | return &self.underlying_allocator.allocator; | |
| 416 | } | |
| 417 | pub fn alloc(allocator: *Allocator, n: usize, ptr_align: u29, len_align: u29) Allocator.Error![]u8 { | |
| 418 | assert(n > 0); | |
| 419 | assert(mem.isValidAlign(ptr_align)); | |
| 420 | if (len_align != 0) { | |
| 421 | assert(mem.isAlignedAnyAlign(n, len_align)); | |
| 422 | assert(n >= len_align); | |
| 423 | } | |
| 424 | ||
| 425 | const self = @fieldParentPtr(@This(), "allocator", allocator); | |
| 426 | const result = try self.getUnderlyingAllocatorPtr().callAllocFn(n, ptr_align, len_align); | |
| 427 | assert(mem.isAligned(@ptrToInt(result.ptr), ptr_align)); | |
| 428 | if (len_align == 0) { | |
| 429 | assert(result.len == n); | |
| 430 | } else { | |
| 431 | assert(result.len >= n); | |
| 432 | assert(mem.isAlignedAnyAlign(result.len, len_align)); | |
| 398 | pub fn ValidationAllocator(comptime T: type) type { | |
| 399 | return struct { | |
| 400 | const Self = @This(); | |
| 401 | allocator: Allocator, | |
| 402 | underlying_allocator: T, | |
| 403 | pub fn init(allocator: T) @This() { | |
| 404 | return .{ | |
| 405 | .allocator = .{ | |
| 406 | .allocFn = alloc, | |
| 407 | .resizeFn = resize, | |
| 408 | }, | |
| 409 | .underlying_allocator = allocator, | |
| 410 | }; | |
| 433 | 411 | } |
| 434 | return result; | |
| 435 | } | |
| 436 | pub fn resize(allocator: *Allocator, buf: []u8, new_len: usize, len_align: u29) Allocator.Error!usize { | |
| 437 | assert(buf.len > 0); | |
| 438 | if (len_align != 0) { | |
| 439 | assert(mem.isAlignedAnyAlign(new_len, len_align)); | |
| 440 | assert(new_len >= len_align); | |
| 412 | fn getUnderlyingAllocatorPtr(self: *@This()) *Allocator { | |
| 413 | if (T == *Allocator) return self.underlying_allocator; | |
| 414 | if (*T == *Allocator) return &self.underlying_allocator; | |
| 415 | return &self.underlying_allocator.allocator; | |
| 441 | 416 | } |
| 442 | const self = @fieldParentPtr(@This(), "allocator", allocator); | |
| 443 | const result = try self.getUnderlyingAllocatorPtr().callResizeFn(buf, new_len, len_align); | |
| 444 | if (len_align == 0) { | |
| 445 | assert(result == new_len); | |
| 446 | } else { | |
| 447 | assert(result >= new_len); | |
| 448 | assert(mem.isAlignedAnyAlign(result, len_align)); | |
| 417 | pub fn alloc(allocator: *Allocator, n: usize, ptr_align: u29, len_align: u29) Allocator.Error![]u8 { | |
| 418 | assert(n > 0); | |
| 419 | assert(mem.isValidAlign(ptr_align)); | |
| 420 | if (len_align != 0) { | |
| 421 | assert(mem.isAlignedAnyAlign(n, len_align)); | |
| 422 | assert(n >= len_align); | |
| 423 | } | |
| 424 | ||
| 425 | const self = @fieldParentPtr(@This(), "allocator", allocator); | |
| 426 | const result = try self.getUnderlyingAllocatorPtr().callAllocFn(n, ptr_align, len_align); | |
| 427 | assert(mem.isAligned(@ptrToInt(result.ptr), ptr_align)); | |
| 428 | if (len_align == 0) { | |
| 429 | assert(result.len == n); | |
| 430 | } else { | |
| 431 | assert(result.len >= n); | |
| 432 | assert(mem.isAlignedAnyAlign(result.len, len_align)); | |
| 433 | } | |
| 434 | return result; | |
| 449 | 435 | } |
| 450 | return result; | |
| 451 | } | |
| 452 | pub usingnamespace if (T == *Allocator or !@hasDecl(T, "reset")) struct {} else struct { | |
| 453 | pub fn reset(self: *Self) void { | |
| 454 | self.underlying_allocator.reset(); | |
| 436 | pub fn resize(allocator: *Allocator, buf: []u8, new_len: usize, len_align: u29) Allocator.Error!usize { | |
| 437 | assert(buf.len > 0); | |
| 438 | if (len_align != 0) { | |
| 439 | assert(mem.isAlignedAnyAlign(new_len, len_align)); | |
| 440 | assert(new_len >= len_align); | |
| 441 | } | |
| 442 | const self = @fieldParentPtr(@This(), "allocator", allocator); | |
| 443 | const result = try self.getUnderlyingAllocatorPtr().callResizeFn(buf, new_len, len_align); | |
| 444 | if (len_align == 0) { | |
| 445 | assert(result == new_len); | |
| 446 | } else { | |
| 447 | assert(result >= new_len); | |
| 448 | assert(mem.isAlignedAnyAlign(result, len_align)); | |
| 449 | } | |
| 450 | return result; | |
| 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 | } | |
| 458 | 459 | |
| 459 | pub fn validationWrap(allocator: var) ValidationAllocator(@TypeOf(allocator)) { | |
| 460 | pub fn validationWrap(allocator: anytype) ValidationAllocator(@TypeOf(allocator)) { | |
| 460 | 461 | return ValidationAllocator(@TypeOf(allocator)).init(allocator); |
| 461 | 462 | } |
| 462 | 463 | |
| ... | ... | @@ -465,14 +466,14 @@ pub fn validationWrap(allocator: var) ValidationAllocator(@TypeOf(allocator)) { |
| 465 | 466 | /// than the `len` that was requsted. This function should only be used by allocators |
| 466 | 467 | /// that are unaffected by `len_align`. |
| 467 | 468 | pub fn alignAllocLen(full_len: usize, alloc_len: usize, len_align: u29) usize { |
| 468 | assert(alloc_len > 0); | |
| 469 | assert(alloc_len >= len_align); | |
| 470 | assert(full_len >= alloc_len); | |
| 471 | if (len_align == 0) | |
| 472 | return alloc_len; | |
| 473 | const adjusted = alignBackwardAnyAlign(full_len, len_align); | |
| 474 | assert(adjusted >= alloc_len); | |
| 475 | return adjusted; | |
| 469 | assert(alloc_len > 0); | |
| 470 | assert(alloc_len >= len_align); | |
| 471 | assert(full_len >= alloc_len); | |
| 472 | if (len_align == 0) | |
| 473 | return alloc_len; | |
| 474 | const adjusted = alignBackwardAnyAlign(full_len, len_align); | |
| 475 | assert(adjusted >= alloc_len); | |
| 476 | return adjusted; | |
| 476 | 477 | } |
| 477 | 478 | |
| 478 | 479 | var failAllocator = Allocator{ |
| ... | ... | @@ -695,7 +696,7 @@ test "mem.secureZero" { |
| 695 | 696 | /// Initializes all fields of the struct with their default value, or zero values if no default value is present. |
| 696 | 697 | /// If the field is present in the provided initial values, it will have that value instead. |
| 697 | 698 | /// Structs are initialized recursively. |
| 698 | pub fn zeroInit(comptime T: type, init: var) T { | |
| 699 | pub fn zeroInit(comptime T: type, init: anytype) T { | |
| 699 | 700 | comptime const Init = @TypeOf(init); |
| 700 | 701 | |
| 701 | 702 | switch (@typeInfo(T)) { |
| ... | ... | @@ -895,7 +896,7 @@ test "Span" { |
| 895 | 896 | /// |
| 896 | 897 | /// When there is both a sentinel and an array length or slice length, the |
| 897 | 898 | /// length value is used instead of the sentinel. |
| 898 | pub fn span(ptr: var) Span(@TypeOf(ptr)) { | |
| 899 | pub fn span(ptr: anytype) Span(@TypeOf(ptr)) { | |
| 899 | 900 | if (@typeInfo(@TypeOf(ptr)) == .Optional) { |
| 900 | 901 | if (ptr) |non_null| { |
| 901 | 902 | return span(non_null); |
| ... | ... | @@ -923,7 +924,7 @@ test "span" { |
| 923 | 924 | /// Same as `span`, except when there is both a sentinel and an array |
| 924 | 925 | /// length or slice length, scans the memory for the sentinel value |
| 925 | 926 | /// rather than using the length. |
| 926 | pub fn spanZ(ptr: var) Span(@TypeOf(ptr)) { | |
| 927 | pub fn spanZ(ptr: anytype) Span(@TypeOf(ptr)) { | |
| 927 | 928 | if (@typeInfo(@TypeOf(ptr)) == .Optional) { |
| 928 | 929 | if (ptr) |non_null| { |
| 929 | 930 | return spanZ(non_null); |
| ... | ... | @@ -952,7 +953,7 @@ test "spanZ" { |
| 952 | 953 | /// or a slice, and returns the length. |
| 953 | 954 | /// In the case of a sentinel-terminated array, it uses the array length. |
| 954 | 955 | /// For C pointers it assumes it is a pointer-to-many with a 0 sentinel. |
| 955 | pub fn len(value: var) usize { | |
| 956 | pub fn len(value: anytype) usize { | |
| 956 | 957 | return switch (@typeInfo(@TypeOf(value))) { |
| 957 | 958 | .Array => |info| info.len, |
| 958 | 959 | .Vector => |info| info.len, |
| ... | ... | @@ -1000,7 +1001,7 @@ test "len" { |
| 1000 | 1001 | /// In the case of a sentinel-terminated array, it scans the array |
| 1001 | 1002 | /// for a sentinel and uses that for the length, rather than using the array length. |
| 1002 | 1003 | /// For C pointers it assumes it is a pointer-to-many with a 0 sentinel. |
| 1003 | pub fn lenZ(ptr: var) usize { | |
| 1004 | pub fn lenZ(ptr: anytype) usize { | |
| 1004 | 1005 | return switch (@typeInfo(@TypeOf(ptr))) { |
| 1005 | 1006 | .Array => |info| if (info.sentinel) |sentinel| |
| 1006 | 1007 | indexOfSentinel(info.child, sentinel, &ptr) |
| ... | ... | @@ -2031,7 +2032,7 @@ fn AsBytesReturnType(comptime P: type) type { |
| 2031 | 2032 | } |
| 2032 | 2033 | |
| 2033 | 2034 | /// Given a pointer to a single item, returns a slice of the underlying bytes, preserving constness. |
| 2034 | pub fn asBytes(ptr: var) AsBytesReturnType(@TypeOf(ptr)) { | |
| 2035 | pub fn asBytes(ptr: anytype) AsBytesReturnType(@TypeOf(ptr)) { | |
| 2035 | 2036 | const P = @TypeOf(ptr); |
| 2036 | 2037 | return @ptrCast(AsBytesReturnType(P), ptr); |
| 2037 | 2038 | } |
| ... | ... | @@ -2071,7 +2072,7 @@ test "asBytes" { |
| 2071 | 2072 | } |
| 2072 | 2073 | |
| 2073 | 2074 | ///Given any value, returns a copy of its bytes in an array. |
| 2074 | pub fn toBytes(value: var) [@sizeOf(@TypeOf(value))]u8 { | |
| 2075 | pub fn toBytes(value: anytype) [@sizeOf(@TypeOf(value))]u8 { | |
| 2075 | 2076 | return asBytes(&value).*; |
| 2076 | 2077 | } |
| 2077 | 2078 | |
| ... | ... | @@ -2106,7 +2107,7 @@ fn BytesAsValueReturnType(comptime T: type, comptime B: type) type { |
| 2106 | 2107 | |
| 2107 | 2108 | ///Given a pointer to an array of bytes, returns a pointer to a value of the specified type |
| 2108 | 2109 | /// backed by those bytes, preserving constness. |
| 2109 | pub fn bytesAsValue(comptime T: type, bytes: var) BytesAsValueReturnType(T, @TypeOf(bytes)) { | |
| 2110 | pub fn bytesAsValue(comptime T: type, bytes: anytype) BytesAsValueReturnType(T, @TypeOf(bytes)) { | |
| 2110 | 2111 | return @ptrCast(BytesAsValueReturnType(T, @TypeOf(bytes)), bytes); |
| 2111 | 2112 | } |
| 2112 | 2113 | |
| ... | ... | @@ -2149,7 +2150,7 @@ test "bytesAsValue" { |
| 2149 | 2150 | |
| 2150 | 2151 | ///Given a pointer to an array of bytes, returns a value of the specified type backed by a |
| 2151 | 2152 | /// copy of those bytes. |
| 2152 | pub fn bytesToValue(comptime T: type, bytes: var) T { | |
| 2153 | pub fn bytesToValue(comptime T: type, bytes: anytype) T { | |
| 2153 | 2154 | return bytesAsValue(T, bytes).*; |
| 2154 | 2155 | } |
| 2155 | 2156 | test "bytesToValue" { |
| ... | ... | @@ -2177,7 +2178,7 @@ fn BytesAsSliceReturnType(comptime T: type, comptime bytesType: type) type { |
| 2177 | 2178 | return if (trait.isConstPtr(bytesType)) []align(alignment) const T else []align(alignment) T; |
| 2178 | 2179 | } |
| 2179 | 2180 | |
| 2180 | pub fn bytesAsSlice(comptime T: type, bytes: var) BytesAsSliceReturnType(T, @TypeOf(bytes)) { | |
| 2181 | pub fn bytesAsSlice(comptime T: type, bytes: anytype) BytesAsSliceReturnType(T, @TypeOf(bytes)) { | |
| 2181 | 2182 | // let's not give an undefined pointer to @ptrCast |
| 2182 | 2183 | // it may be equal to zero and fail a null check |
| 2183 | 2184 | if (bytes.len == 0) { |
| ... | ... | @@ -2256,7 +2257,7 @@ fn SliceAsBytesReturnType(comptime sliceType: type) type { |
| 2256 | 2257 | return if (trait.isConstPtr(sliceType)) []align(alignment) const u8 else []align(alignment) u8; |
| 2257 | 2258 | } |
| 2258 | 2259 | |
| 2259 | pub fn sliceAsBytes(slice: var) SliceAsBytesReturnType(@TypeOf(slice)) { | |
| 2260 | pub fn sliceAsBytes(slice: anytype) SliceAsBytesReturnType(@TypeOf(slice)) { | |
| 2260 | 2261 | const Slice = @TypeOf(slice); |
| 2261 | 2262 | |
| 2262 | 2263 | // 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 | 9 | |
| 10 | 10 | const TypeInfo = builtin.TypeInfo; |
| 11 | 11 | |
| 12 | pub fn tagName(v: var) []const u8 { | |
| 12 | pub fn tagName(v: anytype) []const u8 { | |
| 13 | 13 | const T = @TypeOf(v); |
| 14 | 14 | switch (@typeInfo(T)) { |
| 15 | 15 | .ErrorSet => return @errorName(v), |
| ... | ... | @@ -430,7 +430,7 @@ test "std.meta.TagType" { |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | ///Returns the active tag of a tagged union |
| 433 | pub fn activeTag(u: var) @TagType(@TypeOf(u)) { | |
| 433 | pub fn activeTag(u: anytype) @TagType(@TypeOf(u)) { | |
| 434 | 434 | const T = @TypeOf(u); |
| 435 | 435 | return @as(@TagType(T), u); |
| 436 | 436 | } |
| ... | ... | @@ -480,7 +480,7 @@ test "std.meta.TagPayloadType" { |
| 480 | 480 | |
| 481 | 481 | /// Compares two of any type for equality. Containers are compared on a field-by-field basis, |
| 482 | 482 | /// where possible. Pointers are not followed. |
| 483 | pub fn eql(a: var, b: @TypeOf(a)) bool { | |
| 483 | pub fn eql(a: anytype, b: @TypeOf(a)) bool { | |
| 484 | 484 | const T = @TypeOf(a); |
| 485 | 485 | |
| 486 | 486 | switch (@typeInfo(T)) { |
| ... | ... | @@ -627,7 +627,7 @@ test "intToEnum with error return" { |
| 627 | 627 | |
| 628 | 628 | pub const IntToEnumError = error{InvalidEnumTag}; |
| 629 | 629 | |
| 630 | pub fn intToEnum(comptime Tag: type, tag_int: var) IntToEnumError!Tag { | |
| 630 | pub fn intToEnum(comptime Tag: type, tag_int: anytype) IntToEnumError!Tag { | |
| 631 | 631 | inline for (@typeInfo(Tag).Enum.fields) |f| { |
| 632 | 632 | const this_tag_value = @field(Tag, f.name); |
| 633 | 633 | if (tag_int == @enumToInt(this_tag_value)) { |
| ... | ... | @@ -696,7 +696,7 @@ pub fn Vector(comptime len: u32, comptime child: type) type { |
| 696 | 696 | |
| 697 | 697 | /// Given a type and value, cast the value to the type as c would. |
| 698 | 698 | /// This is for translate-c and is not intended for general use. |
| 699 | pub fn cast(comptime DestType: type, target: var) DestType { | |
| 699 | pub fn cast(comptime DestType: type, target: anytype) DestType { | |
| 700 | 700 | const TargetType = @TypeOf(target); |
| 701 | 701 | switch (@typeInfo(DestType)) { |
| 702 | 702 | .Pointer => { |
lib/std/meta/trait.zig+4-4| ... | ... | @@ -9,7 +9,7 @@ const meta = @import("../meta.zig"); |
| 9 | 9 | |
| 10 | 10 | pub const TraitFn = fn (type) bool; |
| 11 | 11 | |
| 12 | pub fn multiTrait(comptime traits: var) TraitFn { | |
| 12 | pub fn multiTrait(comptime traits: anytype) TraitFn { | |
| 13 | 13 | const Closure = struct { |
| 14 | 14 | pub fn trait(comptime T: type) bool { |
| 15 | 15 | inline for (traits) |t| |
| ... | ... | @@ -342,7 +342,7 @@ test "std.meta.trait.isContainer" { |
| 342 | 342 | testing.expect(!isContainer(u8)); |
| 343 | 343 | } |
| 344 | 344 | |
| 345 | pub fn hasDecls(comptime T: type, comptime names: var) bool { | |
| 345 | pub fn hasDecls(comptime T: type, comptime names: anytype) bool { | |
| 346 | 346 | inline for (names) |name| { |
| 347 | 347 | if (!@hasDecl(T, name)) |
| 348 | 348 | return false; |
| ... | ... | @@ -368,7 +368,7 @@ test "std.meta.trait.hasDecls" { |
| 368 | 368 | testing.expect(!hasDecls(TestStruct2, tuple)); |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | pub fn hasFields(comptime T: type, comptime names: var) bool { | |
| 371 | pub fn hasFields(comptime T: type, comptime names: anytype) bool { | |
| 372 | 372 | inline for (names) |name| { |
| 373 | 373 | if (!@hasField(T, name)) |
| 374 | 374 | return false; |
| ... | ... | @@ -394,7 +394,7 @@ test "std.meta.trait.hasFields" { |
| 394 | 394 | testing.expect(!hasFields(TestStruct2, .{ "a", "b", "useless" })); |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | pub fn hasFunctions(comptime T: type, comptime names: var) bool { | |
| 397 | pub fn hasFunctions(comptime T: type, comptime names: anytype) bool { | |
| 398 | 398 | inline for (names) |name| { |
| 399 | 399 | if (!hasFn(name)(T)) |
| 400 | 400 | return false; |
lib/std/net.zig+3-3| ... | ... | @@ -427,7 +427,7 @@ pub const Address = extern union { |
| 427 | 427 | self: Address, |
| 428 | 428 | comptime fmt: []const u8, |
| 429 | 429 | options: std.fmt.FormatOptions, |
| 430 | out_stream: var, | |
| 430 | out_stream: anytype, | |
| 431 | 431 | ) !void { |
| 432 | 432 | switch (self.any.family) { |
| 433 | 433 | os.AF_INET => { |
| ... | ... | @@ -1404,8 +1404,8 @@ fn resMSendRc( |
| 1404 | 1404 | |
| 1405 | 1405 | fn dnsParse( |
| 1406 | 1406 | r: []const u8, |
| 1407 | ctx: var, | |
| 1408 | comptime callback: var, | |
| 1407 | ctx: anytype, | |
| 1408 | comptime callback: anytype, | |
| 1409 | 1409 | ) !void { |
| 1410 | 1410 | // This implementation is ported from musl libc. |
| 1411 | 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 | 4068 | } |
| 4069 | 4069 | |
| 4070 | 4070 | pub fn dl_iterate_phdr( |
| 4071 | context: var, | |
| 4071 | context: anytype, | |
| 4072 | 4072 | comptime Error: type, |
| 4073 | 4073 | comptime callback: fn (info: *dl_phdr_info, size: usize, context: @TypeOf(context)) Error!void, |
| 4074 | 4074 | ) Error!void { |
lib/std/os/uefi.zig+1-1| ... | ... | @@ -28,7 +28,7 @@ pub const Guid = extern struct { |
| 28 | 28 | self: @This(), |
| 29 | 29 | comptime f: []const u8, |
| 30 | 30 | options: std.fmt.FormatOptions, |
| 31 | out_stream: var, | |
| 31 | out_stream: anytype, | |
| 32 | 32 | ) Errors!void { |
| 33 | 33 | if (f.len == 0) { |
| 34 | 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 | 224 | self.prev_refresh_timestamp = self.timer.read(); |
| 225 | 225 | } |
| 226 | 226 | |
| 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 | 228 | const file = self.terminal orelse return; |
| 229 | 229 | self.refresh(); |
| 230 | 230 | file.outStream().print(format, args) catch { |
| ... | ... | @@ -234,7 +234,7 @@ pub const Progress = struct { |
| 234 | 234 | self.columns_written = 0; |
| 235 | 235 | } |
| 236 | 236 | |
| 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 | 238 | if (std.fmt.bufPrint(self.output_buffer[end.*..], format, args)) |written| { |
| 239 | 239 | const amt = written.len; |
| 240 | 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 | 122 | self.* = undefined; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | pub fn at(self: var, i: usize) AtType(@TypeOf(self)) { | |
| 125 | pub fn at(self: anytype, i: usize) AtType(@TypeOf(self)) { | |
| 126 | 126 | assert(i < self.len); |
| 127 | 127 | return self.uncheckedAt(i); |
| 128 | 128 | } |
| ... | ... | @@ -241,7 +241,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type |
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | pub fn uncheckedAt(self: var, index: usize) AtType(@TypeOf(self)) { | |
| 244 | pub fn uncheckedAt(self: anytype, index: usize) AtType(@TypeOf(self)) { | |
| 245 | 245 | if (index < prealloc_item_count) { |
| 246 | 246 | return &self.prealloc_segment[index]; |
| 247 | 247 | } |
lib/std/sort.zig+19-19| ... | ... | @@ -9,7 +9,7 @@ pub fn binarySearch( |
| 9 | 9 | comptime T: type, |
| 10 | 10 | key: T, |
| 11 | 11 | items: []const T, |
| 12 | context: var, | |
| 12 | context: anytype, | |
| 13 | 13 | comptime compareFn: fn (context: @TypeOf(context), lhs: T, rhs: T) math.Order, |
| 14 | 14 | ) ?usize { |
| 15 | 15 | var left: usize = 0; |
| ... | ... | @@ -76,7 +76,7 @@ test "binarySearch" { |
| 76 | 76 | pub fn insertionSort( |
| 77 | 77 | comptime T: type, |
| 78 | 78 | items: []T, |
| 79 | context: var, | |
| 79 | context: anytype, | |
| 80 | 80 | comptime lessThan: fn (context: @TypeOf(context), lhs: T, rhs: T) bool, |
| 81 | 81 | ) void { |
| 82 | 82 | var i: usize = 1; |
| ... | ... | @@ -182,7 +182,7 @@ const Pull = struct { |
| 182 | 182 | pub fn sort( |
| 183 | 183 | comptime T: type, |
| 184 | 184 | items: []T, |
| 185 | context: var, | |
| 185 | context: anytype, | |
| 186 | 186 | comptime lessThan: fn (context: @TypeOf(context), lhs: T, rhs: T) bool, |
| 187 | 187 | ) void { |
| 188 | 188 | // Implementation ported from https://github.com/BonzaiThePenguin/WikiSort/blob/master/WikiSort.c |
| ... | ... | @@ -813,7 +813,7 @@ fn mergeInPlace( |
| 813 | 813 | items: []T, |
| 814 | 814 | A_arg: Range, |
| 815 | 815 | B_arg: Range, |
| 816 | context: var, | |
| 816 | context: anytype, | |
| 817 | 817 | comptime lessThan: fn (@TypeOf(context), T, T) bool, |
| 818 | 818 | ) void { |
| 819 | 819 | if (A_arg.length() == 0 or B_arg.length() == 0) return; |
| ... | ... | @@ -862,7 +862,7 @@ fn mergeInternal( |
| 862 | 862 | items: []T, |
| 863 | 863 | A: Range, |
| 864 | 864 | B: Range, |
| 865 | context: var, | |
| 865 | context: anytype, | |
| 866 | 866 | comptime lessThan: fn (@TypeOf(context), T, T) bool, |
| 867 | 867 | buffer: Range, |
| 868 | 868 | ) void { |
| ... | ... | @@ -906,7 +906,7 @@ fn findFirstForward( |
| 906 | 906 | items: []T, |
| 907 | 907 | value: T, |
| 908 | 908 | range: Range, |
| 909 | context: var, | |
| 909 | context: anytype, | |
| 910 | 910 | comptime lessThan: fn (@TypeOf(context), T, T) bool, |
| 911 | 911 | unique: usize, |
| 912 | 912 | ) usize { |
| ... | ... | @@ -928,7 +928,7 @@ fn findFirstBackward( |
| 928 | 928 | items: []T, |
| 929 | 929 | value: T, |
| 930 | 930 | range: Range, |
| 931 | context: var, | |
| 931 | context: anytype, | |
| 932 | 932 | comptime lessThan: fn (@TypeOf(context), T, T) bool, |
| 933 | 933 | unique: usize, |
| 934 | 934 | ) usize { |
| ... | ... | @@ -950,7 +950,7 @@ fn findLastForward( |
| 950 | 950 | items: []T, |
| 951 | 951 | value: T, |
| 952 | 952 | range: Range, |
| 953 | context: var, | |
| 953 | context: anytype, | |
| 954 | 954 | comptime lessThan: fn (@TypeOf(context), T, T) bool, |
| 955 | 955 | unique: usize, |
| 956 | 956 | ) usize { |
| ... | ... | @@ -972,7 +972,7 @@ fn findLastBackward( |
| 972 | 972 | items: []T, |
| 973 | 973 | value: T, |
| 974 | 974 | range: Range, |
| 975 | context: var, | |
| 975 | context: anytype, | |
| 976 | 976 | comptime lessThan: fn (@TypeOf(context), T, T) bool, |
| 977 | 977 | unique: usize, |
| 978 | 978 | ) usize { |
| ... | ... | @@ -994,7 +994,7 @@ fn binaryFirst( |
| 994 | 994 | items: []T, |
| 995 | 995 | value: T, |
| 996 | 996 | range: Range, |
| 997 | context: var, | |
| 997 | context: anytype, | |
| 998 | 998 | comptime lessThan: fn (@TypeOf(context), T, T) bool, |
| 999 | 999 | ) usize { |
| 1000 | 1000 | var curr = range.start; |
| ... | ... | @@ -1017,7 +1017,7 @@ fn binaryLast( |
| 1017 | 1017 | items: []T, |
| 1018 | 1018 | value: T, |
| 1019 | 1019 | range: Range, |
| 1020 | context: var, | |
| 1020 | context: anytype, | |
| 1021 | 1021 | comptime lessThan: fn (@TypeOf(context), T, T) bool, |
| 1022 | 1022 | ) usize { |
| 1023 | 1023 | var curr = range.start; |
| ... | ... | @@ -1040,7 +1040,7 @@ fn mergeInto( |
| 1040 | 1040 | from: []T, |
| 1041 | 1041 | A: Range, |
| 1042 | 1042 | B: Range, |
| 1043 | context: var, | |
| 1043 | context: anytype, | |
| 1044 | 1044 | comptime lessThan: fn (@TypeOf(context), T, T) bool, |
| 1045 | 1045 | into: []T, |
| 1046 | 1046 | ) void { |
| ... | ... | @@ -1078,7 +1078,7 @@ fn mergeExternal( |
| 1078 | 1078 | items: []T, |
| 1079 | 1079 | A: Range, |
| 1080 | 1080 | B: Range, |
| 1081 | context: var, | |
| 1081 | context: anytype, | |
| 1082 | 1082 | comptime lessThan: fn (@TypeOf(context), T, T) bool, |
| 1083 | 1083 | cache: []T, |
| 1084 | 1084 | ) void { |
| ... | ... | @@ -1112,7 +1112,7 @@ fn mergeExternal( |
| 1112 | 1112 | fn swap( |
| 1113 | 1113 | comptime T: type, |
| 1114 | 1114 | items: []T, |
| 1115 | context: var, | |
| 1115 | context: anytype, | |
| 1116 | 1116 | comptime lessThan: fn (@TypeOf(context), lhs: T, rhs: T) bool, |
| 1117 | 1117 | order: *[8]u8, |
| 1118 | 1118 | x: usize, |
| ... | ... | @@ -1358,7 +1358,7 @@ fn fuzzTest(rng: *std.rand.Random) !void { |
| 1358 | 1358 | pub fn argMin( |
| 1359 | 1359 | comptime T: type, |
| 1360 | 1360 | items: []const T, |
| 1361 | context: var, | |
| 1361 | context: anytype, | |
| 1362 | 1362 | comptime lessThan: fn (@TypeOf(context), lhs: T, rhs: T) bool, |
| 1363 | 1363 | ) ?usize { |
| 1364 | 1364 | if (items.len == 0) { |
| ... | ... | @@ -1390,7 +1390,7 @@ test "argMin" { |
| 1390 | 1390 | pub fn min( |
| 1391 | 1391 | comptime T: type, |
| 1392 | 1392 | items: []const T, |
| 1393 | context: var, | |
| 1393 | context: anytype, | |
| 1394 | 1394 | comptime lessThan: fn (context: @TypeOf(context), lhs: T, rhs: T) bool, |
| 1395 | 1395 | ) ?T { |
| 1396 | 1396 | const i = argMin(T, items, context, lessThan) orelse return null; |
| ... | ... | @@ -1410,7 +1410,7 @@ test "min" { |
| 1410 | 1410 | pub fn argMax( |
| 1411 | 1411 | comptime T: type, |
| 1412 | 1412 | items: []const T, |
| 1413 | context: var, | |
| 1413 | context: anytype, | |
| 1414 | 1414 | comptime lessThan: fn (context: @TypeOf(context), lhs: T, rhs: T) bool, |
| 1415 | 1415 | ) ?usize { |
| 1416 | 1416 | if (items.len == 0) { |
| ... | ... | @@ -1442,7 +1442,7 @@ test "argMax" { |
| 1442 | 1442 | pub fn max( |
| 1443 | 1443 | comptime T: type, |
| 1444 | 1444 | items: []const T, |
| 1445 | context: var, | |
| 1445 | context: anytype, | |
| 1446 | 1446 | comptime lessThan: fn (context: @TypeOf(context), lhs: T, rhs: T) bool, |
| 1447 | 1447 | ) ?T { |
| 1448 | 1448 | const i = argMax(T, items, context, lessThan) orelse return null; |
| ... | ... | @@ -1462,7 +1462,7 @@ test "max" { |
| 1462 | 1462 | pub fn isSorted( |
| 1463 | 1463 | comptime T: type, |
| 1464 | 1464 | items: []const T, |
| 1465 | context: var, | |
| 1465 | context: anytype, | |
| 1466 | 1466 | comptime lessThan: fn (context: @TypeOf(context), lhs: T, rhs: T) bool, |
| 1467 | 1467 | ) bool { |
| 1468 | 1468 | var i: usize = 1; |
lib/std/special/build_runner.zig+2-2| ... | ... | @@ -135,7 +135,7 @@ fn runBuild(builder: *Builder) anyerror!void { |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void { | |
| 138 | fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void { | |
| 139 | 139 | // run the build script to collect the options |
| 140 | 140 | if (!already_ran_build) { |
| 141 | 141 | builder.setInstallPrefix(null); |
| ... | ... | @@ -202,7 +202,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void { |
| 202 | 202 | ); |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | fn usageAndErr(builder: *Builder, already_ran_build: bool, out_stream: var) void { | |
| 205 | fn usageAndErr(builder: *Builder, already_ran_build: bool, out_stream: anytype) void { | |
| 206 | 206 | usage(builder, already_ran_build, out_stream) catch {}; |
| 207 | 207 | process.exit(1); |
| 208 | 208 | } |
lib/std/special/test_runner.zig+2-2| ... | ... | @@ -79,9 +79,9 @@ pub fn log( |
| 79 | 79 | comptime message_level: std.log.Level, |
| 80 | 80 | comptime scope: @Type(.EnumLiteral), |
| 81 | 81 | comptime format: []const u8, |
| 82 | args: var, | |
| 82 | args: anytype, | |
| 83 | 83 | ) void { |
| 84 | 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 | 108 | self: WindowsVersion, |
| 109 | 109 | comptime fmt: []const u8, |
| 110 | 110 | options: std.fmt.FormatOptions, |
| 111 | out_stream: var, | |
| 111 | out_stream: anytype, | |
| 112 | 112 | ) !void { |
| 113 | if (fmt.len > 0 and fmt[0] == 's') { | |
| 114 | if ( | |
| 115 | @enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.win10_19h1) | |
| 116 | ) { | |
| 113 | if (fmt.len > 0 and fmt[0] == 's') { | |
| 114 | if (@enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.win10_19h1)) { | |
| 117 | 115 | try std.fmt.format(out_stream, ".{}", .{@tagName(self)}); |
| 118 | 116 | } else { |
| 119 | try std.fmt.format(out_stream, | |
| 120 | "@intToEnum(Target.Os.WindowsVersion, {})", | |
| 121 | .{ @enumToInt(self) } | |
| 122 | ); | |
| 117 | try std.fmt.format(out_stream, "@intToEnum(Target.Os.WindowsVersion, {})", .{@enumToInt(self)}); | |
| 123 | 118 | } |
| 124 | 119 | } else { |
| 125 | if ( | |
| 126 | @enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.win10_19h1) | |
| 127 | ) { | |
| 120 | if (@enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.win10_19h1)) { | |
| 128 | 121 | try std.fmt.format(out_stream, "WindowsVersion.{}", .{@tagName(self)}); |
| 129 | 122 | } else { |
| 130 | 123 | try std.fmt.format(out_stream, "WindowsVersion(", .{@typeName(@This())}); |
| ... | ... | @@ -1198,7 +1191,7 @@ pub const Target = struct { |
| 1198 | 1191 | pub fn standardDynamicLinkerPath(self: Target) DynamicLinker { |
| 1199 | 1192 | var result: DynamicLinker = .{}; |
| 1200 | 1193 | const S = struct { |
| 1201 | fn print(r: *DynamicLinker, comptime fmt: []const u8, args: var) DynamicLinker { | |
| 1194 | fn print(r: *DynamicLinker, comptime fmt: []const u8, args: anytype) DynamicLinker { | |
| 1202 | 1195 | r.max_byte = @intCast(u8, (std.fmt.bufPrint(&r.buffer, fmt, args) catch unreachable).len - 1); |
| 1203 | 1196 | return r.*; |
| 1204 | 1197 | } |
lib/std/testing.zig+2-2| ... | ... | @@ -19,7 +19,7 @@ pub var log_level = std.log.Level.warn; |
| 19 | 19 | |
| 20 | 20 | /// This function is intended to be used only in tests. It prints diagnostics to stderr |
| 21 | 21 | /// and then aborts when actual_error_union is not expected_error. |
| 22 | pub fn expectError(expected_error: anyerror, actual_error_union: var) void { | |
| 22 | pub fn expectError(expected_error: anyerror, actual_error_union: anytype) void { | |
| 23 | 23 | if (actual_error_union) |actual_payload| { |
| 24 | 24 | std.debug.panic("expected error.{}, found {}", .{ @errorName(expected_error), actual_payload }); |
| 25 | 25 | } else |actual_error| { |
| ... | ... | @@ -36,7 +36,7 @@ pub fn expectError(expected_error: anyerror, actual_error_union: var) void { |
| 36 | 36 | /// equal, prints diagnostics to stderr to show exactly how they are not equal, |
| 37 | 37 | /// then aborts. |
| 38 | 38 | /// The types must match exactly. |
| 39 | pub fn expectEqual(expected: var, actual: @TypeOf(expected)) void { | |
| 39 | pub fn expectEqual(expected: anytype, actual: @TypeOf(expected)) void { | |
| 40 | 40 | switch (@typeInfo(@TypeOf(actual))) { |
| 41 | 41 | .NoReturn, |
| 42 | 42 | .BoundFn, |
lib/std/thread.zig+1-1| ... | ... | @@ -143,7 +143,7 @@ pub const Thread = struct { |
| 143 | 143 | /// fn startFn(@TypeOf(context)) T |
| 144 | 144 | /// where T is u8, noreturn, void, or !void |
| 145 | 145 | /// 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 | 147 | if (builtin.single_threaded) @compileError("cannot spawn thread when building in single-threaded mode"); |
| 148 | 148 | // TODO compile-time call graph analysis to determine stack upper bound |
| 149 | 149 | // https://github.com/ziglang/zig/issues/157 |
lib/std/zig/ast.zig+20-20| ... | ... | @@ -29,7 +29,7 @@ pub const Tree = struct { |
| 29 | 29 | self.arena.promote(self.gpa).deinit(); |
| 30 | 30 | } |
| 31 | 31 | |
| 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 | 33 | return parse_error.render(self.token_ids, stream); |
| 34 | 34 | } |
| 35 | 35 | |
| ... | ... | @@ -167,7 +167,7 @@ pub const Error = union(enum) { |
| 167 | 167 | DeclBetweenFields: DeclBetweenFields, |
| 168 | 168 | InvalidAnd: InvalidAnd, |
| 169 | 169 | |
| 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 | 171 | switch (self.*) { |
| 172 | 172 | .InvalidToken => |*x| return x.render(tokens, stream), |
| 173 | 173 | .ExpectedContainerMembers => |*x| return x.render(tokens, stream), |
| ... | ... | @@ -322,7 +322,7 @@ pub const Error = union(enum) { |
| 322 | 322 | pub const ExpectedCall = struct { |
| 323 | 323 | node: *Node, |
| 324 | 324 | |
| 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 | 326 | return stream.print("expected " ++ @tagName(Node.Id.Call) ++ ", found {}", .{ |
| 327 | 327 | @tagName(self.node.id), |
| 328 | 328 | }); |
| ... | ... | @@ -332,7 +332,7 @@ pub const Error = union(enum) { |
| 332 | 332 | pub const ExpectedCallOrFnProto = struct { |
| 333 | 333 | node: *Node, |
| 334 | 334 | |
| 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 | 336 | return stream.print("expected " ++ @tagName(Node.Id.Call) ++ " or " ++ |
| 337 | 337 | @tagName(Node.Id.FnProto) ++ ", found {}", .{@tagName(self.node.id)}); |
| 338 | 338 | } |
| ... | ... | @@ -342,7 +342,7 @@ pub const Error = union(enum) { |
| 342 | 342 | token: TokenIndex, |
| 343 | 343 | expected_id: Token.Id, |
| 344 | 344 | |
| 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 | 346 | const found_token = tokens[self.token]; |
| 347 | 347 | switch (found_token) { |
| 348 | 348 | .Invalid => { |
| ... | ... | @@ -360,7 +360,7 @@ pub const Error = union(enum) { |
| 360 | 360 | token: TokenIndex, |
| 361 | 361 | end_id: Token.Id, |
| 362 | 362 | |
| 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 | 364 | const actual_token = tokens[self.token]; |
| 365 | 365 | return stream.print("expected ',' or '{}', found '{}'", .{ |
| 366 | 366 | self.end_id.symbol(), |
| ... | ... | @@ -375,7 +375,7 @@ pub const Error = union(enum) { |
| 375 | 375 | |
| 376 | 376 | token: TokenIndex, |
| 377 | 377 | |
| 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 | 379 | const actual_token = tokens[self.token]; |
| 380 | 380 | return stream.print(msg, .{actual_token.symbol()}); |
| 381 | 381 | } |
| ... | ... | @@ -388,7 +388,7 @@ pub const Error = union(enum) { |
| 388 | 388 | |
| 389 | 389 | token: TokenIndex, |
| 390 | 390 | |
| 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 | 392 | return stream.writeAll(msg); |
| 393 | 393 | } |
| 394 | 394 | }; |
| ... | ... | @@ -434,7 +434,7 @@ pub const Node = struct { |
| 434 | 434 | Suspend, |
| 435 | 435 | |
| 436 | 436 | // Type expressions |
| 437 | VarType, | |
| 437 | AnyType, | |
| 438 | 438 | ErrorType, |
| 439 | 439 | FnProto, |
| 440 | 440 | AnyFrameType, |
| ... | ... | @@ -993,7 +993,7 @@ pub const Node = struct { |
| 993 | 993 | param_type: ParamType, |
| 994 | 994 | |
| 995 | 995 | pub const ParamType = union(enum) { |
| 996 | var_type: *Node, | |
| 996 | any_type: *Node, | |
| 997 | 997 | var_args: TokenIndex, |
| 998 | 998 | type_expr: *Node, |
| 999 | 999 | }; |
| ... | ... | @@ -1004,7 +1004,7 @@ pub const Node = struct { |
| 1004 | 1004 | if (i < 1) { |
| 1005 | 1005 | switch (self.param_type) { |
| 1006 | 1006 | .var_args => return null, |
| 1007 | .var_type, .type_expr => |node| return node, | |
| 1007 | .any_type, .type_expr => |node| return node, | |
| 1008 | 1008 | } |
| 1009 | 1009 | } |
| 1010 | 1010 | i -= 1; |
| ... | ... | @@ -1018,14 +1018,14 @@ pub const Node = struct { |
| 1018 | 1018 | if (self.name_token) |name_token| return name_token; |
| 1019 | 1019 | switch (self.param_type) { |
| 1020 | 1020 | .var_args => |tok| return tok, |
| 1021 | .var_type, .type_expr => |node| return node.firstToken(), | |
| 1021 | .any_type, .type_expr => |node| return node.firstToken(), | |
| 1022 | 1022 | } |
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | 1025 | pub fn lastToken(self: *const ParamDecl) TokenIndex { |
| 1026 | 1026 | switch (self.param_type) { |
| 1027 | 1027 | .var_args => |tok| return tok, |
| 1028 | .var_type, .type_expr => |node| return node.lastToken(), | |
| 1028 | .any_type, .type_expr => |node| return node.lastToken(), | |
| 1029 | 1029 | } |
| 1030 | 1030 | } |
| 1031 | 1031 | }; |
| ... | ... | @@ -1052,12 +1052,12 @@ pub const Node = struct { |
| 1052 | 1052 | const params_len: usize = if (self.params_len == 0) |
| 1053 | 1053 | 0 |
| 1054 | 1054 | else switch (self.paramsConst()[self.params_len - 1].param_type) { |
| 1055 | .var_type, .type_expr => self.params_len, | |
| 1055 | .any_type, .type_expr => self.params_len, | |
| 1056 | 1056 | .var_args => self.params_len - 1, |
| 1057 | 1057 | }; |
| 1058 | 1058 | if (i < params_len) { |
| 1059 | 1059 | switch (self.paramsConst()[i].param_type) { |
| 1060 | .var_type => |n| return n, | |
| 1060 | .any_type => |n| return n, | |
| 1061 | 1061 | .var_args => unreachable, |
| 1062 | 1062 | .type_expr => |n| return n, |
| 1063 | 1063 | } |
| ... | ... | @@ -2732,19 +2732,19 @@ pub const Node = struct { |
| 2732 | 2732 | } |
| 2733 | 2733 | }; |
| 2734 | 2734 | |
| 2735 | pub const VarType = struct { | |
| 2736 | base: Node = Node{ .id = .VarType }, | |
| 2735 | pub const AnyType = struct { | |
| 2736 | base: Node = Node{ .id = .AnyType }, | |
| 2737 | 2737 | token: TokenIndex, |
| 2738 | 2738 | |
| 2739 | pub fn iterate(self: *const VarType, index: usize) ?*Node { | |
| 2739 | pub fn iterate(self: *const AnyType, index: usize) ?*Node { | |
| 2740 | 2740 | return null; |
| 2741 | 2741 | } |
| 2742 | 2742 | |
| 2743 | pub fn firstToken(self: *const VarType) TokenIndex { | |
| 2743 | pub fn firstToken(self: *const AnyType) TokenIndex { | |
| 2744 | 2744 | return self.token; |
| 2745 | 2745 | } |
| 2746 | 2746 | |
| 2747 | pub fn lastToken(self: *const VarType) TokenIndex { | |
| 2747 | pub fn lastToken(self: *const AnyType) TokenIndex { | |
| 2748 | 2748 | return self.token; |
| 2749 | 2749 | } |
| 2750 | 2750 | }; |
lib/std/zig/parse.zig+12-11| ... | ... | @@ -488,7 +488,7 @@ const Parser = struct { |
| 488 | 488 | return p.parseUse(); |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | /// FnProto <- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_var / TypeExpr) | |
| 491 | /// FnProto <- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (Keyword_anytype / TypeExpr) | |
| 492 | 492 | fn parseFnProto(p: *Parser) !?*Node { |
| 493 | 493 | // TODO: Remove once extern/async fn rewriting is |
| 494 | 494 | var is_async = false; |
| ... | ... | @@ -519,7 +519,7 @@ const Parser = struct { |
| 519 | 519 | const callconv_expr = try p.parseCallconv(); |
| 520 | 520 | const exclamation_token = p.eatToken(.Bang); |
| 521 | 521 | |
| 522 | const return_type_expr = (try p.parseVarType()) orelse | |
| 522 | const return_type_expr = (try p.parseAnyType()) orelse | |
| 523 | 523 | try p.expectNodeRecoverable(parseTypeExpr, .{ |
| 524 | 524 | // most likely the user forgot to specify the return type. |
| 525 | 525 | // Mark return type as invalid and try to continue. |
| ... | ... | @@ -618,9 +618,9 @@ const Parser = struct { |
| 618 | 618 | var align_expr: ?*Node = null; |
| 619 | 619 | var type_expr: ?*Node = null; |
| 620 | 620 | if (p.eatToken(.Colon)) |_| { |
| 621 | if (p.eatToken(.Keyword_var)) |var_tok| { | |
| 622 | const node = try p.arena.allocator.create(Node.VarType); | |
| 623 | node.* = .{ .token = var_tok }; | |
| 621 | if (p.eatToken(.Keyword_anytype) orelse p.eatToken(.Keyword_var)) |anytype_tok| { | |
| 622 | const node = try p.arena.allocator.create(Node.AnyType); | |
| 623 | node.* = .{ .token = anytype_tok }; | |
| 624 | 624 | type_expr = &node.base; |
| 625 | 625 | } else { |
| 626 | 626 | type_expr = try p.expectNode(parseTypeExpr, .{ |
| ... | ... | @@ -2022,13 +2022,13 @@ const Parser = struct { |
| 2022 | 2022 | } |
| 2023 | 2023 | |
| 2024 | 2024 | /// ParamType |
| 2025 | /// <- KEYWORD_var | |
| 2025 | /// <- Keyword_anytype | |
| 2026 | 2026 | /// / DOT3 |
| 2027 | 2027 | /// / TypeExpr |
| 2028 | 2028 | fn parseParamType(p: *Parser) !?Node.FnProto.ParamDecl.ParamType { |
| 2029 | 2029 | // TODO cast from tuple to error union is broken |
| 2030 | 2030 | const P = Node.FnProto.ParamDecl.ParamType; |
| 2031 | if (try p.parseVarType()) |node| return P{ .var_type = node }; | |
| 2031 | if (try p.parseAnyType()) |node| return P{ .any_type = node }; | |
| 2032 | 2032 | if (p.eatToken(.Ellipsis3)) |token| return P{ .var_args = token }; |
| 2033 | 2033 | if (try p.parseTypeExpr()) |node| return P{ .type_expr = node }; |
| 2034 | 2034 | return null; |
| ... | ... | @@ -2955,7 +2955,7 @@ const Parser = struct { |
| 2955 | 2955 | |
| 2956 | 2956 | const NodeParseFn = fn (p: *Parser) Error!?*Node; |
| 2957 | 2957 | |
| 2958 | fn ListParseFn(comptime E: type, comptime nodeParseFn: var) ParseFn([]E) { | |
| 2958 | fn ListParseFn(comptime E: type, comptime nodeParseFn: anytype) ParseFn([]E) { | |
| 2959 | 2959 | return struct { |
| 2960 | 2960 | pub fn parse(p: *Parser) ![]E { |
| 2961 | 2961 | var list = std.ArrayList(E).init(p.gpa); |
| ... | ... | @@ -3057,9 +3057,10 @@ const Parser = struct { |
| 3057 | 3057 | return &node.base; |
| 3058 | 3058 | } |
| 3059 | 3059 | |
| 3060 | fn parseVarType(p: *Parser) !?*Node { | |
| 3061 | const token = p.eatToken(.Keyword_var) orelse return null; | |
| 3062 | const node = try p.arena.allocator.create(Node.VarType); | |
| 3060 | fn parseAnyType(p: *Parser) !?*Node { | |
| 3061 | const token = p.eatToken(.Keyword_anytype) orelse | |
| 3062 | p.eatToken(.Keyword_var) orelse return null; // TODO remove in next release cycle | |
| 3063 | const node = try p.arena.allocator.create(Node.AnyType); | |
| 3063 | 3064 | node.* = .{ |
| 3064 | 3065 | .token = token, |
| 3065 | 3066 | }; |
lib/std/zig/parser_test.zig+21-5| ... | ... | @@ -422,10 +422,10 @@ test "zig fmt: asm expression with comptime content" { |
| 422 | 422 | ); |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | test "zig fmt: var struct field" { | |
| 425 | test "zig fmt: anytype struct field" { | |
| 426 | 426 | try testCanonical( |
| 427 | 427 | \\pub const Pointer = struct { |
| 428 | \\ sentinel: var, | |
| 428 | \\ sentinel: anytype, | |
| 429 | 429 | \\}; |
| 430 | 430 | \\ |
| 431 | 431 | ); |
| ... | ... | @@ -1932,7 +1932,7 @@ test "zig fmt: preserve spacing" { |
| 1932 | 1932 | test "zig fmt: return types" { |
| 1933 | 1933 | try testCanonical( |
| 1934 | 1934 | \\pub fn main() !void {} |
| 1935 | \\pub fn main() var {} | |
| 1935 | \\pub fn main() anytype {} | |
| 1936 | 1936 | \\pub fn main() i32 {} |
| 1937 | 1937 | \\ |
| 1938 | 1938 | ); |
| ... | ... | @@ -2140,9 +2140,9 @@ test "zig fmt: call expression" { |
| 2140 | 2140 | ); |
| 2141 | 2141 | } |
| 2142 | 2142 | |
| 2143 | test "zig fmt: var type" { | |
| 2143 | test "zig fmt: anytype type" { | |
| 2144 | 2144 | try testCanonical( |
| 2145 | \\fn print(args: var) var {} | |
| 2145 | \\fn print(args: anytype) anytype {} | |
| 2146 | 2146 | \\ |
| 2147 | 2147 | ); |
| 2148 | 2148 | } |
| ... | ... | @@ -3180,6 +3180,22 @@ test "zig fmt: convert extern fn proto into callconv(.C)" { |
| 3180 | 3180 | ); |
| 3181 | 3181 | } |
| 3182 | 3182 | |
| 3183 | test "zig fmt: convert var to anytype" { | |
| 3184 | // TODO remove in next release cycle | |
| 3185 | try testTransform( | |
| 3186 | \\pub fn main( | |
| 3187 | \\ a: var, | |
| 3188 | \\ bar: var, | |
| 3189 | \\) void {} | |
| 3190 | , | |
| 3191 | \\pub fn main( | |
| 3192 | \\ a: anytype, | |
| 3193 | \\ bar: anytype, | |
| 3194 | \\) void {} | |
| 3195 | \\ | |
| 3196 | ); | |
| 3197 | } | |
| 3198 | ||
| 3183 | 3199 | const std = @import("std"); |
| 3184 | 3200 | const mem = std.mem; |
| 3185 | 3201 | const warn = std.debug.warn; |
lib/std/zig/render.zig+28-22| ... | ... | @@ -12,7 +12,7 @@ pub const Error = error{ |
| 12 | 12 | }; |
| 13 | 13 | |
| 14 | 14 | /// Returns whether anything changed |
| 15 | pub fn render(allocator: *mem.Allocator, stream: var, tree: *ast.Tree) (@TypeOf(stream).Error || Error)!bool { | |
| 15 | pub fn render(allocator: *mem.Allocator, stream: anytype, tree: *ast.Tree) (@TypeOf(stream).Error || Error)!bool { | |
| 16 | 16 | // cannot render an invalid tree |
| 17 | 17 | std.debug.assert(tree.errors.len == 0); |
| 18 | 18 | |
| ... | ... | @@ -64,7 +64,7 @@ pub fn render(allocator: *mem.Allocator, stream: var, tree: *ast.Tree) (@TypeOf( |
| 64 | 64 | |
| 65 | 65 | fn renderRoot( |
| 66 | 66 | allocator: *mem.Allocator, |
| 67 | stream: var, | |
| 67 | stream: anytype, | |
| 68 | 68 | tree: *ast.Tree, |
| 69 | 69 | ) (@TypeOf(stream).Error || Error)!void { |
| 70 | 70 | // render all the line comments at the beginning of the file |
| ... | ... | @@ -191,13 +191,13 @@ fn renderRoot( |
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | fn renderExtraNewline(tree: *ast.Tree, stream: var, start_col: *usize, node: *ast.Node) @TypeOf(stream).Error!void { | |
| 194 | fn renderExtraNewline(tree: *ast.Tree, stream: anytype, start_col: *usize, node: *ast.Node) @TypeOf(stream).Error!void { | |
| 195 | 195 | return renderExtraNewlineToken(tree, stream, start_col, node.firstToken()); |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | fn renderExtraNewlineToken( |
| 199 | 199 | tree: *ast.Tree, |
| 200 | stream: var, | |
| 200 | stream: anytype, | |
| 201 | 201 | start_col: *usize, |
| 202 | 202 | first_token: ast.TokenIndex, |
| 203 | 203 | ) @TypeOf(stream).Error!void { |
| ... | ... | @@ -218,11 +218,11 @@ fn renderExtraNewlineToken( |
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | fn renderTopLevelDecl(allocator: *mem.Allocator, stream: var, tree: *ast.Tree, indent: usize, start_col: *usize, decl: *ast.Node) (@TypeOf(stream).Error || Error)!void { | |
| 221 | fn renderTopLevelDecl(allocator: *mem.Allocator, stream: anytype, tree: *ast.Tree, indent: usize, start_col: *usize, decl: *ast.Node) (@TypeOf(stream).Error || Error)!void { | |
| 222 | 222 | try renderContainerDecl(allocator, stream, tree, indent, start_col, decl, .Newline); |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | fn renderContainerDecl(allocator: *mem.Allocator, stream: var, tree: *ast.Tree, indent: usize, start_col: *usize, decl: *ast.Node, space: Space) (@TypeOf(stream).Error || Error)!void { | |
| 225 | fn renderContainerDecl(allocator: *mem.Allocator, stream: anytype, tree: *ast.Tree, indent: usize, start_col: *usize, decl: *ast.Node, space: Space) (@TypeOf(stream).Error || Error)!void { | |
| 226 | 226 | switch (decl.id) { |
| 227 | 227 | .FnProto => { |
| 228 | 228 | const fn_proto = @fieldParentPtr(ast.Node.FnProto, "base", decl); |
| ... | ... | @@ -358,7 +358,7 @@ fn renderContainerDecl(allocator: *mem.Allocator, stream: var, tree: *ast.Tree, |
| 358 | 358 | |
| 359 | 359 | fn renderExpression( |
| 360 | 360 | allocator: *mem.Allocator, |
| 361 | stream: var, | |
| 361 | stream: anytype, | |
| 362 | 362 | tree: *ast.Tree, |
| 363 | 363 | indent: usize, |
| 364 | 364 | start_col: *usize, |
| ... | ... | @@ -1179,9 +1179,15 @@ fn renderExpression( |
| 1179 | 1179 | const error_type = @fieldParentPtr(ast.Node.ErrorType, "base", base); |
| 1180 | 1180 | return renderToken(tree, stream, error_type.token, indent, start_col, space); |
| 1181 | 1181 | }, |
| 1182 | .VarType => { | |
| 1183 | const var_type = @fieldParentPtr(ast.Node.VarType, "base", base); | |
| 1184 | return renderToken(tree, stream, var_type.token, indent, start_col, space); | |
| 1182 | .AnyType => { | |
| 1183 | const any_type = @fieldParentPtr(ast.Node.AnyType, "base", base); | |
| 1184 | if (mem.eql(u8, tree.tokenSlice(any_type.token), "var")) { | |
| 1185 | // TODO remove in next release cycle | |
| 1186 | try stream.writeAll("anytype"); | |
| 1187 | if (space == .Comma) try stream.writeAll(",\n"); | |
| 1188 | return; | |
| 1189 | } | |
| 1190 | return renderToken(tree, stream, any_type.token, indent, start_col, space); | |
| 1185 | 1191 | }, |
| 1186 | 1192 | .ContainerDecl => { |
| 1187 | 1193 | const container_decl = @fieldParentPtr(ast.Node.ContainerDecl, "base", base); |
| ... | ... | @@ -2053,7 +2059,7 @@ fn renderExpression( |
| 2053 | 2059 | |
| 2054 | 2060 | fn renderAsmOutput( |
| 2055 | 2061 | allocator: *mem.Allocator, |
| 2056 | stream: var, | |
| 2062 | stream: anytype, | |
| 2057 | 2063 | tree: *ast.Tree, |
| 2058 | 2064 | indent: usize, |
| 2059 | 2065 | start_col: *usize, |
| ... | ... | @@ -2081,7 +2087,7 @@ fn renderAsmOutput( |
| 2081 | 2087 | |
| 2082 | 2088 | fn renderAsmInput( |
| 2083 | 2089 | allocator: *mem.Allocator, |
| 2084 | stream: var, | |
| 2090 | stream: anytype, | |
| 2085 | 2091 | tree: *ast.Tree, |
| 2086 | 2092 | indent: usize, |
| 2087 | 2093 | start_col: *usize, |
| ... | ... | @@ -2099,7 +2105,7 @@ fn renderAsmInput( |
| 2099 | 2105 | |
| 2100 | 2106 | fn renderVarDecl( |
| 2101 | 2107 | allocator: *mem.Allocator, |
| 2102 | stream: var, | |
| 2108 | stream: anytype, | |
| 2103 | 2109 | tree: *ast.Tree, |
| 2104 | 2110 | indent: usize, |
| 2105 | 2111 | start_col: *usize, |
| ... | ... | @@ -2171,7 +2177,7 @@ fn renderVarDecl( |
| 2171 | 2177 | |
| 2172 | 2178 | fn renderParamDecl( |
| 2173 | 2179 | allocator: *mem.Allocator, |
| 2174 | stream: var, | |
| 2180 | stream: anytype, | |
| 2175 | 2181 | tree: *ast.Tree, |
| 2176 | 2182 | indent: usize, |
| 2177 | 2183 | start_col: *usize, |
| ... | ... | @@ -2192,13 +2198,13 @@ fn renderParamDecl( |
| 2192 | 2198 | } |
| 2193 | 2199 | switch (param_decl.param_type) { |
| 2194 | 2200 | .var_args => |token| try renderToken(tree, stream, token, indent, start_col, space), |
| 2195 | .var_type, .type_expr => |node| try renderExpression(allocator, stream, tree, indent, start_col, node, space), | |
| 2201 | .any_type, .type_expr => |node| try renderExpression(allocator, stream, tree, indent, start_col, node, space), | |
| 2196 | 2202 | } |
| 2197 | 2203 | } |
| 2198 | 2204 | |
| 2199 | 2205 | fn renderStatement( |
| 2200 | 2206 | allocator: *mem.Allocator, |
| 2201 | stream: var, | |
| 2207 | stream: anytype, | |
| 2202 | 2208 | tree: *ast.Tree, |
| 2203 | 2209 | indent: usize, |
| 2204 | 2210 | start_col: *usize, |
| ... | ... | @@ -2236,7 +2242,7 @@ const Space = enum { |
| 2236 | 2242 | |
| 2237 | 2243 | fn renderTokenOffset( |
| 2238 | 2244 | tree: *ast.Tree, |
| 2239 | stream: var, | |
| 2245 | stream: anytype, | |
| 2240 | 2246 | token_index: ast.TokenIndex, |
| 2241 | 2247 | indent: usize, |
| 2242 | 2248 | start_col: *usize, |
| ... | ... | @@ -2434,7 +2440,7 @@ fn renderTokenOffset( |
| 2434 | 2440 | |
| 2435 | 2441 | fn renderToken( |
| 2436 | 2442 | tree: *ast.Tree, |
| 2437 | stream: var, | |
| 2443 | stream: anytype, | |
| 2438 | 2444 | token_index: ast.TokenIndex, |
| 2439 | 2445 | indent: usize, |
| 2440 | 2446 | start_col: *usize, |
| ... | ... | @@ -2445,8 +2451,8 @@ fn renderToken( |
| 2445 | 2451 | |
| 2446 | 2452 | fn renderDocComments( |
| 2447 | 2453 | tree: *ast.Tree, |
| 2448 | stream: var, | |
| 2449 | node: var, | |
| 2454 | stream: anytype, | |
| 2455 | node: anytype, | |
| 2450 | 2456 | indent: usize, |
| 2451 | 2457 | start_col: *usize, |
| 2452 | 2458 | ) (@TypeOf(stream).Error || Error)!void { |
| ... | ... | @@ -2456,7 +2462,7 @@ fn renderDocComments( |
| 2456 | 2462 | |
| 2457 | 2463 | fn renderDocCommentsToken( |
| 2458 | 2464 | tree: *ast.Tree, |
| 2459 | stream: var, | |
| 2465 | stream: anytype, | |
| 2460 | 2466 | comment: *ast.Node.DocComment, |
| 2461 | 2467 | first_token: ast.TokenIndex, |
| 2462 | 2468 | indent: usize, |
| ... | ... | @@ -2532,7 +2538,7 @@ const FindByteOutStream = struct { |
| 2532 | 2538 | } |
| 2533 | 2539 | }; |
| 2534 | 2540 | |
| 2535 | fn copyFixingWhitespace(stream: var, slice: []const u8) @TypeOf(stream).Error!void { | |
| 2541 | fn copyFixingWhitespace(stream: anytype, slice: []const u8) @TypeOf(stream).Error!void { | |
| 2536 | 2542 | for (slice) |byte| switch (byte) { |
| 2537 | 2543 | '\t' => try stream.writeAll(" "), |
| 2538 | 2544 | '\r' => {}, |
lib/std/zig/string_literal.zig+1-1| ... | ... | @@ -125,7 +125,7 @@ test "parse" { |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /// Writes a Zig-syntax escaped string literal to the stream. Includes the double quotes. |
| 128 | pub fn render(utf8: []const u8, out_stream: var) !void { | |
| 128 | pub fn render(utf8: []const u8, out_stream: anytype) !void { | |
| 129 | 129 | try out_stream.writeByte('"'); |
| 130 | 130 | for (utf8) |byte| switch (byte) { |
| 131 | 131 | '\n' => try out_stream.writeAll("\\n"), |
lib/std/zig/system.zig+4-4| ... | ... | @@ -130,7 +130,7 @@ pub const NativePaths = struct { |
| 130 | 130 | return self.appendArray(&self.include_dirs, s); |
| 131 | 131 | } |
| 132 | 132 | |
| 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 | 134 | const item = try std.fmt.allocPrint0(self.include_dirs.allocator, fmt, args); |
| 135 | 135 | errdefer self.include_dirs.allocator.free(item); |
| 136 | 136 | try self.include_dirs.append(item); |
| ... | ... | @@ -140,7 +140,7 @@ pub const NativePaths = struct { |
| 140 | 140 | return self.appendArray(&self.lib_dirs, s); |
| 141 | 141 | } |
| 142 | 142 | |
| 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 | 144 | const item = try std.fmt.allocPrint0(self.lib_dirs.allocator, fmt, args); |
| 145 | 145 | errdefer self.lib_dirs.allocator.free(item); |
| 146 | 146 | try self.lib_dirs.append(item); |
| ... | ... | @@ -150,7 +150,7 @@ pub const NativePaths = struct { |
| 150 | 150 | return self.appendArray(&self.warnings, s); |
| 151 | 151 | } |
| 152 | 152 | |
| 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 | 154 | const item = try std.fmt.allocPrint0(self.warnings.allocator, fmt, args); |
| 155 | 155 | errdefer self.warnings.allocator.free(item); |
| 156 | 156 | try self.warnings.append(item); |
| ... | ... | @@ -887,7 +887,7 @@ pub const NativeTargetInfo = struct { |
| 887 | 887 | abi: Target.Abi, |
| 888 | 888 | }; |
| 889 | 889 | |
| 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 | 891 | if (is_64) { |
| 892 | 892 | if (need_bswap) { |
| 893 | 893 | return @byteSwap(@TypeOf(int_64), int_64); |
lib/std/zig/tokenizer.zig+4-1| ... | ... | @@ -15,6 +15,7 @@ pub const Token = struct { |
| 15 | 15 | .{ "allowzero", .Keyword_allowzero }, |
| 16 | 16 | .{ "and", .Keyword_and }, |
| 17 | 17 | .{ "anyframe", .Keyword_anyframe }, |
| 18 | .{ "anytype", .Keyword_anytype }, | |
| 18 | 19 | .{ "asm", .Keyword_asm }, |
| 19 | 20 | .{ "async", .Keyword_async }, |
| 20 | 21 | .{ "await", .Keyword_await }, |
| ... | ... | @@ -140,6 +141,8 @@ pub const Token = struct { |
| 140 | 141 | Keyword_align, |
| 141 | 142 | Keyword_allowzero, |
| 142 | 143 | Keyword_and, |
| 144 | Keyword_anyframe, | |
| 145 | Keyword_anytype, | |
| 143 | 146 | Keyword_asm, |
| 144 | 147 | Keyword_async, |
| 145 | 148 | Keyword_await, |
| ... | ... | @@ -168,7 +171,6 @@ pub const Token = struct { |
| 168 | 171 | Keyword_or, |
| 169 | 172 | Keyword_orelse, |
| 170 | 173 | Keyword_packed, |
| 171 | Keyword_anyframe, | |
| 172 | 174 | Keyword_pub, |
| 173 | 175 | Keyword_resume, |
| 174 | 176 | Keyword_return, |
| ... | ... | @@ -263,6 +265,7 @@ pub const Token = struct { |
| 263 | 265 | .Keyword_allowzero => "allowzero", |
| 264 | 266 | .Keyword_and => "and", |
| 265 | 267 | .Keyword_anyframe => "anyframe", |
| 268 | .Keyword_anytype => "anytype", | |
| 266 | 269 | .Keyword_asm => "asm", |
| 267 | 270 | .Keyword_async => "async", |
| 268 | 271 | .Keyword_await => "await", |
src-self-hosted/Module.zig+6-6| ... | ... | @@ -1132,7 +1132,7 @@ fn astGenAndAnalyzeDecl(self: *Module, decl: *Decl) !bool { |
| 1132 | 1132 | const param_types = try fn_type_scope.arena.alloc(*zir.Inst, param_decls.len); |
| 1133 | 1133 | for (param_decls) |param_decl, i| { |
| 1134 | 1134 | const param_type_node = switch (param_decl.param_type) { |
| 1135 | .var_type => |node| return self.failNode(&fn_type_scope.base, node, "TODO implement anytype parameter", .{}), | |
| 1135 | .any_type => |node| return self.failNode(&fn_type_scope.base, node, "TODO implement anytype parameter", .{}), | |
| 1136 | 1136 | .var_args => |tok| return self.failTok(&fn_type_scope.base, tok, "TODO implement var args", .{}), |
| 1137 | 1137 | .type_expr => |node| node, |
| 1138 | 1138 | }; |
| ... | ... | @@ -3575,7 +3575,7 @@ fn coerceArrayPtrToSlice(self: *Module, scope: *Scope, dest_type: Type, inst: *I |
| 3575 | 3575 | return self.fail(scope, inst.src, "TODO implement coerceArrayPtrToSlice runtime instruction", .{}); |
| 3576 | 3576 | } |
| 3577 | 3577 | |
| 3578 | fn fail(self: *Module, scope: *Scope, src: usize, comptime format: []const u8, args: var) InnerError { | |
| 3578 | fn fail(self: *Module, scope: *Scope, src: usize, comptime format: []const u8, args: anytype) InnerError { | |
| 3579 | 3579 | @setCold(true); |
| 3580 | 3580 | const err_msg = try ErrorMsg.create(self.gpa, src, format, args); |
| 3581 | 3581 | return self.failWithOwnedErrorMsg(scope, src, err_msg); |
| ... | ... | @@ -3586,7 +3586,7 @@ fn failTok( |
| 3586 | 3586 | scope: *Scope, |
| 3587 | 3587 | token_index: ast.TokenIndex, |
| 3588 | 3588 | comptime format: []const u8, |
| 3589 | args: var, | |
| 3589 | args: anytype, | |
| 3590 | 3590 | ) InnerError { |
| 3591 | 3591 | @setCold(true); |
| 3592 | 3592 | const src = scope.tree().token_locs[token_index].start; |
| ... | ... | @@ -3598,7 +3598,7 @@ fn failNode( |
| 3598 | 3598 | scope: *Scope, |
| 3599 | 3599 | ast_node: *ast.Node, |
| 3600 | 3600 | comptime format: []const u8, |
| 3601 | args: var, | |
| 3601 | args: anytype, | |
| 3602 | 3602 | ) InnerError { |
| 3603 | 3603 | @setCold(true); |
| 3604 | 3604 | const src = scope.tree().token_locs[ast_node.firstToken()].start; |
| ... | ... | @@ -3662,7 +3662,7 @@ pub const ErrorMsg = struct { |
| 3662 | 3662 | byte_offset: usize, |
| 3663 | 3663 | msg: []const u8, |
| 3664 | 3664 | |
| 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 | 3666 | const self = try gpa.create(ErrorMsg); |
| 3667 | 3667 | errdefer gpa.destroy(self); |
| 3668 | 3668 | self.* = try init(gpa, byte_offset, format, args); |
| ... | ... | @@ -3675,7 +3675,7 @@ pub const ErrorMsg = struct { |
| 3675 | 3675 | gpa.destroy(self); |
| 3676 | 3676 | } |
| 3677 | 3677 | |
| 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 | 3679 | return ErrorMsg{ |
| 3680 | 3680 | .byte_offset = byte_offset, |
| 3681 | 3681 | .msg = try std.fmt.allocPrint(gpa, format, args), |
src-self-hosted/codegen.zig+11-10| ... | ... | @@ -230,7 +230,7 @@ pub fn generateSymbol( |
| 230 | 230 | } |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | const InnerError = error { | |
| 233 | const InnerError = error{ | |
| 234 | 234 | OutOfMemory, |
| 235 | 235 | CodegenFail, |
| 236 | 236 | }; |
| ... | ... | @@ -673,9 +673,9 @@ const Function = struct { |
| 673 | 673 | try self.genX8664BinMathCode(inst.base.src, dst_mcv, src_mcv, 7, 0x38); |
| 674 | 674 | const info = inst.args.lhs.ty.intInfo(self.target.*); |
| 675 | 675 | if (info.signed) { |
| 676 | return MCValue{.compare_flags_signed = inst.args.op}; | |
| 676 | return MCValue{ .compare_flags_signed = inst.args.op }; | |
| 677 | 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 | 681 | else => return self.fail(inst.base.src, "TODO implement cmp for {}", .{self.target.cpu.arch}), |
| ... | ... | @@ -721,7 +721,7 @@ const Function = struct { |
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 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 | 725 | const reloc = Reloc{ .rel32 = self.code.items.len }; |
| 726 | 726 | self.code.items.len += 4; |
| 727 | 727 | try self.genBody(inst.args.true_body, arch); |
| ... | ... | @@ -1081,10 +1081,12 @@ const Function = struct { |
| 1081 | 1081 | switch (mcv) { |
| 1082 | 1082 | .immediate => |imm| { |
| 1083 | 1083 | // This immediate is unsigned. |
| 1084 | const U = @Type(.{ .Int = .{ | |
| 1085 | .bits = ti.bits - @boolToInt(ti.is_signed), | |
| 1086 | .is_signed = false, | |
| 1087 | }}); | |
| 1084 | const U = @Type(.{ | |
| 1085 | .Int = .{ | |
| 1086 | .bits = ti.bits - @boolToInt(ti.is_signed), | |
| 1087 | .is_signed = false, | |
| 1088 | }, | |
| 1089 | }); | |
| 1088 | 1090 | if (imm >= std.math.maxInt(U)) { |
| 1089 | 1091 | return self.copyToNewRegister(inst); |
| 1090 | 1092 | } |
| ... | ... | @@ -1094,7 +1096,6 @@ const Function = struct { |
| 1094 | 1096 | return mcv; |
| 1095 | 1097 | } |
| 1096 | 1098 | |
| 1097 | ||
| 1098 | 1099 | fn genTypedValue(self: *Function, src: usize, typed_value: TypedValue) !MCValue { |
| 1099 | 1100 | const ptr_bits = self.target.cpu.arch.ptrBitWidth(); |
| 1100 | 1101 | const ptr_bytes: u64 = @divExact(ptr_bits, 8); |
| ... | ... | @@ -1121,7 +1122,7 @@ const Function = struct { |
| 1121 | 1122 | } |
| 1122 | 1123 | } |
| 1123 | 1124 | |
| 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 | 1126 | @setCold(true); |
| 1126 | 1127 | assert(self.err_msg == null); |
| 1127 | 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 | 299 | return null; |
| 300 | 300 | } |
| 301 | 301 | |
| 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 | 303 | self.error_text = try std.fmt.allocPrintZ(&self.arena.allocator, fmt, args); |
| 304 | 304 | return Error.InvalidInput; |
| 305 | 305 | } |
| 306 | 306 | |
| 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 | 308 | var buffer = try std.ArrayListSentineled(u8, 0).initSize(&self.arena.allocator, 0); |
| 309 | 309 | try buffer.outStream().print(fmt, args); |
| 310 | 310 | try buffer.appendSlice(" '"); |
| ... | ... | @@ -316,7 +316,7 @@ pub const Tokenizer = struct { |
| 316 | 316 | return Error.InvalidInput; |
| 317 | 317 | } |
| 318 | 318 | |
| 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 | 320 | var buffer = try std.ArrayListSentineled(u8, 0).initSize(&self.arena.allocator, 0); |
| 321 | 321 | try buffer.appendSlice("illegal char "); |
| 322 | 322 | try printUnderstandableChar(&buffer, char); |
| ... | ... | @@ -883,7 +883,7 @@ fn depTokenizer(input: []const u8, expect: []const u8) !void { |
| 883 | 883 | testing.expect(false); |
| 884 | 884 | } |
| 885 | 885 | |
| 886 | fn printSection(out: var, label: []const u8, bytes: []const u8) !void { | |
| 886 | fn printSection(out: anytype, label: []const u8, bytes: []const u8) !void { | |
| 887 | 887 | try printLabel(out, label, bytes); |
| 888 | 888 | try hexDump(out, bytes); |
| 889 | 889 | try printRuler(out); |
| ... | ... | @@ -891,7 +891,7 @@ fn printSection(out: var, label: []const u8, bytes: []const u8) !void { |
| 891 | 891 | try out.write("\n"); |
| 892 | 892 | } |
| 893 | 893 | |
| 894 | fn printLabel(out: var, label: []const u8, bytes: []const u8) !void { | |
| 894 | fn printLabel(out: anytype, label: []const u8, bytes: []const u8) !void { | |
| 895 | 895 | var buf: [80]u8 = undefined; |
| 896 | 896 | var text = try std.fmt.bufPrint(buf[0..], "{} {} bytes ", .{ label, bytes.len }); |
| 897 | 897 | try out.write(text); |
| ... | ... | @@ -903,7 +903,7 @@ fn printLabel(out: var, label: []const u8, bytes: []const u8) !void { |
| 903 | 903 | try out.write("\n"); |
| 904 | 904 | } |
| 905 | 905 | |
| 906 | fn printRuler(out: var) !void { | |
| 906 | fn printRuler(out: anytype) !void { | |
| 907 | 907 | var i: usize = 0; |
| 908 | 908 | const end = 79; |
| 909 | 909 | while (i < 79) : (i += 1) { |
| ... | ... | @@ -912,7 +912,7 @@ fn printRuler(out: var) !void { |
| 912 | 912 | try out.write("\n"); |
| 913 | 913 | } |
| 914 | 914 | |
| 915 | fn hexDump(out: var, bytes: []const u8) !void { | |
| 915 | fn hexDump(out: anytype, bytes: []const u8) !void { | |
| 916 | 916 | const n16 = bytes.len >> 4; |
| 917 | 917 | var line: usize = 0; |
| 918 | 918 | var offset: usize = 0; |
| ... | ... | @@ -959,7 +959,7 @@ fn hexDump(out: var, bytes: []const u8) !void { |
| 959 | 959 | try out.write("\n"); |
| 960 | 960 | } |
| 961 | 961 | |
| 962 | fn hexDump16(out: var, offset: usize, bytes: []const u8) !void { | |
| 962 | fn hexDump16(out: anytype, offset: usize, bytes: []const u8) !void { | |
| 963 | 963 | try printDecValue(out, offset, 8); |
| 964 | 964 | try out.write(":"); |
| 965 | 965 | try out.write(" "); |
| ... | ... | @@ -977,19 +977,19 @@ fn hexDump16(out: var, offset: usize, bytes: []const u8) !void { |
| 977 | 977 | try out.write("|\n"); |
| 978 | 978 | } |
| 979 | 979 | |
| 980 | fn printDecValue(out: var, value: u64, width: u8) !void { | |
| 980 | fn printDecValue(out: anytype, value: u64, width: u8) !void { | |
| 981 | 981 | var buffer: [20]u8 = undefined; |
| 982 | 982 | const len = std.fmt.formatIntBuf(buffer[0..], value, 10, false, width); |
| 983 | 983 | try out.write(buffer[0..len]); |
| 984 | 984 | } |
| 985 | 985 | |
| 986 | fn printHexValue(out: var, value: u64, width: u8) !void { | |
| 986 | fn printHexValue(out: anytype, value: u64, width: u8) !void { | |
| 987 | 987 | var buffer: [16]u8 = undefined; |
| 988 | 988 | const len = std.fmt.formatIntBuf(buffer[0..], value, 16, false, width); |
| 989 | 989 | try out.write(buffer[0..len]); |
| 990 | 990 | } |
| 991 | 991 | |
| 992 | fn printCharValues(out: var, bytes: []const u8) !void { | |
| 992 | fn printCharValues(out: anytype, bytes: []const u8) !void { | |
| 993 | 993 | for (bytes) |b| { |
| 994 | 994 | try out.write(&[_]u8{printable_char_tab[b]}); |
| 995 | 995 | } |
| ... | ... | @@ -1020,13 +1020,13 @@ comptime { |
| 1020 | 1020 | // output: must be a function that takes a `self` idiom parameter |
| 1021 | 1021 | // and a bytes parameter |
| 1022 | 1022 | // context: must be that self |
| 1023 | fn makeOutput(comptime output: var, context: var) Output(output, @TypeOf(context)) { | |
| 1023 | fn makeOutput(comptime output: anytype, context: anytype) Output(output, @TypeOf(context)) { | |
| 1024 | 1024 | return Output(output, @TypeOf(context)){ |
| 1025 | 1025 | .context = context, |
| 1026 | 1026 | }; |
| 1027 | 1027 | } |
| 1028 | 1028 | |
| 1029 | fn Output(comptime output_func: var, comptime Context: type) type { | |
| 1029 | fn Output(comptime output_func: anytype, comptime Context: type) type { | |
| 1030 | 1030 | return struct { |
| 1031 | 1031 | context: Context, |
| 1032 | 1032 |
src-self-hosted/ir.zig+1-1| ... | ... | @@ -13,7 +13,7 @@ const codegen = @import("codegen.zig"); |
| 13 | 13 | pub const Inst = struct { |
| 14 | 14 | tag: Tag, |
| 15 | 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 | 17 | /// instruction parameter. For example, 0b000_00101 means that the first and |
| 18 | 18 | /// third `Inst` parameters' lifetimes end after this instruction, and will |
| 19 | 19 | /// not have any more following references. |
src-self-hosted/libc_installation.zig+2-2| ... | ... | @@ -37,7 +37,7 @@ pub const LibCInstallation = struct { |
| 37 | 37 | pub fn parse( |
| 38 | 38 | allocator: *Allocator, |
| 39 | 39 | libc_file: []const u8, |
| 40 | stderr: var, | |
| 40 | stderr: anytype, | |
| 41 | 41 | ) !LibCInstallation { |
| 42 | 42 | var self: LibCInstallation = .{}; |
| 43 | 43 | |
| ... | ... | @@ -115,7 +115,7 @@ pub const LibCInstallation = struct { |
| 115 | 115 | return self; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | pub fn render(self: LibCInstallation, out: var) !void { | |
| 118 | pub fn render(self: LibCInstallation, out: anytype) !void { | |
| 119 | 119 | @setEvalBranchQuota(4000); |
| 120 | 120 | const include_dir = self.include_dir orelse ""; |
| 121 | 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 | 244 | need_noreturn: bool = false, |
| 245 | 245 | error_msg: *Module.ErrorMsg = undefined, |
| 246 | 246 | |
| 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 | 248 | self.error_msg = try Module.ErrorMsg.create(self.allocator, src, format, args); |
| 249 | 249 | return error.CGenFailure; |
| 250 | 250 | } |
| ... | ... | @@ -1167,10 +1167,10 @@ pub const File = struct { |
| 1167 | 1167 | try self.offset_table_free_list.ensureCapacity(self.allocator, self.local_symbols.items.len); |
| 1168 | 1168 | |
| 1169 | 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 | 1171 | decl.link.local_sym_index = i; |
| 1172 | 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 | 1174 | decl.link.local_sym_index = @intCast(u32, self.local_symbols.items.len); |
| 1175 | 1175 | _ = self.local_symbols.addOneAssumeCapacity(); |
| 1176 | 1176 | } |
| ... | ... | @@ -1657,7 +1657,7 @@ fn openBinFileInner(allocator: *Allocator, file: fs.File, options: Options) !Fil |
| 1657 | 1657 | } |
| 1658 | 1658 | |
| 1659 | 1659 | /// Saturating multiplication |
| 1660 | fn satMul(a: var, b: var) @TypeOf(a, b) { | |
| 1660 | fn satMul(a: anytype, b: anytype) @TypeOf(a, b) { | |
| 1661 | 1661 | const T = @TypeOf(a, b); |
| 1662 | 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 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
| 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 | 42 | comptime level: std.log.Level, |
| 43 | 43 | comptime scope: @TypeOf(.EnumLiteral), |
| 44 | 44 | comptime format: []const u8, |
| 45 | args: var, | |
| 45 | args: anytype, | |
| 46 | 46 | ) void { |
| 47 | 47 | if (@enumToInt(level) > @enumToInt(std.log.level)) |
| 48 | 48 | return; |
src-self-hosted/print_targets.zig+1-1| ... | ... | @@ -62,7 +62,7 @@ pub fn cmdTargets( |
| 62 | 62 | allocator: *Allocator, |
| 63 | 63 | args: []const []const u8, |
| 64 | 64 | /// Output stream |
| 65 | stdout: var, | |
| 65 | stdout: anytype, | |
| 66 | 66 | native_target: Target, |
| 67 | 67 | ) !void { |
| 68 | 68 | const available_glibcs = blk: { |
src-self-hosted/translate_c.zig+13-14| ... | ... | @@ -1117,7 +1117,7 @@ fn transEnumDecl(c: *Context, enum_decl: *const ZigClangEnumDecl) Error!?*ast.No |
| 1117 | 1117 | return transCreateNodeIdentifier(c, name); |
| 1118 | 1118 | } |
| 1119 | 1119 | |
| 1120 | fn createAlias(c: *Context, alias: var) !void { | |
| 1120 | fn createAlias(c: *Context, alias: anytype) !void { | |
| 1121 | 1121 | const node = try transCreateNodeVarDecl(c, true, true, alias.alias); |
| 1122 | 1122 | node.eq_token = try appendToken(c, .Equal, "="); |
| 1123 | 1123 | node.init_node = try transCreateNodeIdentifier(c, alias.name); |
| ... | ... | @@ -2161,7 +2161,7 @@ fn transCreateNodeArrayType( |
| 2161 | 2161 | rp: RestorePoint, |
| 2162 | 2162 | source_loc: ZigClangSourceLocation, |
| 2163 | 2163 | ty: *const ZigClangType, |
| 2164 | len: var, | |
| 2164 | len: anytype, | |
| 2165 | 2165 | ) TransError!*ast.Node { |
| 2166 | 2166 | var node = try transCreateNodePrefixOp( |
| 2167 | 2167 | rp.c, |
| ... | ... | @@ -4187,7 +4187,7 @@ fn transCreateNodeBoolLiteral(c: *Context, value: bool) !*ast.Node { |
| 4187 | 4187 | return &node.base; |
| 4188 | 4188 | } |
| 4189 | 4189 | |
| 4190 | fn transCreateNodeInt(c: *Context, int: var) !*ast.Node { | |
| 4190 | fn transCreateNodeInt(c: *Context, int: anytype) !*ast.Node { | |
| 4191 | 4191 | const token = try appendTokenFmt(c, .IntegerLiteral, "{}", .{int}); |
| 4192 | 4192 | const node = try c.arena.create(ast.Node.IntegerLiteral); |
| 4193 | 4193 | node.* = .{ |
| ... | ... | @@ -4196,7 +4196,7 @@ fn transCreateNodeInt(c: *Context, int: var) !*ast.Node { |
| 4196 | 4196 | return &node.base; |
| 4197 | 4197 | } |
| 4198 | 4198 | |
| 4199 | fn transCreateNodeFloat(c: *Context, int: var) !*ast.Node { | |
| 4199 | fn transCreateNodeFloat(c: *Context, int: anytype) !*ast.Node { | |
| 4200 | 4200 | const token = try appendTokenFmt(c, .FloatLiteral, "{}", .{int}); |
| 4201 | 4201 | const node = try c.arena.create(ast.Node.FloatLiteral); |
| 4202 | 4202 | node.* = .{ |
| ... | ... | @@ -4907,22 +4907,22 @@ fn finishTransFnProto( |
| 4907 | 4907 | |
| 4908 | 4908 | fn revertAndWarn( |
| 4909 | 4909 | rp: RestorePoint, |
| 4910 | err: var, | |
| 4910 | err: anytype, | |
| 4911 | 4911 | source_loc: ZigClangSourceLocation, |
| 4912 | 4912 | comptime format: []const u8, |
| 4913 | args: var, | |
| 4913 | args: anytype, | |
| 4914 | 4914 | ) (@TypeOf(err) || error{OutOfMemory}) { |
| 4915 | 4915 | rp.activate(); |
| 4916 | 4916 | try emitWarning(rp.c, source_loc, format, args); |
| 4917 | 4917 | return err; |
| 4918 | 4918 | } |
| 4919 | 4919 | |
| 4920 | fn emitWarning(c: *Context, loc: ZigClangSourceLocation, comptime format: []const u8, args: var) !void { | |
| 4920 | fn emitWarning(c: *Context, loc: ZigClangSourceLocation, comptime format: []const u8, args: anytype) !void { | |
| 4921 | 4921 | const args_prefix = .{c.locStr(loc)}; |
| 4922 | 4922 | _ = try appendTokenFmt(c, .LineComment, "// {}: warning: " ++ format, args_prefix ++ args); |
| 4923 | 4923 | } |
| 4924 | 4924 | |
| 4925 | pub fn failDecl(c: *Context, loc: ZigClangSourceLocation, name: []const u8, comptime format: []const u8, args: var) !void { | |
| 4925 | pub fn failDecl(c: *Context, loc: ZigClangSourceLocation, name: []const u8, comptime format: []const u8, args: anytype) !void { | |
| 4926 | 4926 | // pub const name = @compileError(msg); |
| 4927 | 4927 | const pub_tok = try appendToken(c, .Keyword_pub, "pub"); |
| 4928 | 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 | 4973 | return appendTokenFmt(c, token_id, "{}", .{bytes}); |
| 4974 | 4974 | } |
| 4975 | 4975 | |
| 4976 | fn appendTokenFmt(c: *Context, token_id: Token.Id, comptime format: []const u8, args: var) !ast.TokenIndex { | |
| 4976 | fn appendTokenFmt(c: *Context, token_id: Token.Id, comptime format: []const u8, args: anytype) !ast.TokenIndex { | |
| 4977 | 4977 | assert(token_id != .Invalid); |
| 4978 | 4978 | |
| 4979 | 4979 | try c.token_ids.ensureCapacity(c.gpa, c.token_ids.items.len + 1); |
| ... | ... | @@ -5215,10 +5215,9 @@ fn transMacroFnDefine(c: *Context, it: *CTokenList.Iterator, source: []const u8, |
| 5215 | 5215 | const param_name_tok = try appendIdentifier(c, mangled_name); |
| 5216 | 5216 | _ = try appendToken(c, .Colon, ":"); |
| 5217 | 5217 | |
| 5218 | const token_index = try appendToken(c, .Keyword_var, "var"); | |
| 5219 | const identifier = try c.arena.create(ast.Node.Identifier); | |
| 5220 | identifier.* = .{ | |
| 5221 | .token = token_index, | |
| 5218 | const any_type = try c.arena.create(ast.Node.AnyType); | |
| 5219 | any_type.* = .{ | |
| 5220 | .token = try appendToken(c, .Keyword_anytype, "anytype"), | |
| 5222 | 5221 | }; |
| 5223 | 5222 | |
| 5224 | 5223 | (try fn_params.addOne()).* = .{ |
| ... | ... | @@ -5226,7 +5225,7 @@ fn transMacroFnDefine(c: *Context, it: *CTokenList.Iterator, source: []const u8, |
| 5226 | 5225 | .comptime_token = null, |
| 5227 | 5226 | .noalias_token = null, |
| 5228 | 5227 | .name_token = param_name_tok, |
| 5229 | .param_type = .{ .type_expr = &identifier.base }, | |
| 5228 | .param_type = .{ .any_type = &any_type.base }, | |
| 5230 | 5229 | }; |
| 5231 | 5230 | |
| 5232 | 5231 | if (it.peek().?.id != .Comma) |
src-self-hosted/type.zig+1-2| ... | ... | @@ -277,7 +277,7 @@ pub const Type = extern union { |
| 277 | 277 | self: Type, |
| 278 | 278 | comptime fmt: []const u8, |
| 279 | 279 | options: std.fmt.FormatOptions, |
| 280 | out_stream: var, | |
| 280 | out_stream: anytype, | |
| 281 | 281 | ) @TypeOf(out_stream).Error!void { |
| 282 | 282 | comptime assert(fmt.len == 0); |
| 283 | 283 | var ty = self; |
| ... | ... | @@ -591,7 +591,6 @@ pub const Type = extern union { |
| 591 | 591 | |
| 592 | 592 | .anyerror => return 2, // TODO revisit this when we have the concept of the error tag type |
| 593 | 593 | |
| 594 | ||
| 595 | 594 | .int_signed, .int_unsigned => { |
| 596 | 595 | const bits: u16 = if (self.cast(Payload.IntSigned)) |pl| |
| 597 | 596 | pl.bits |
src-self-hosted/value.zig+1-1| ... | ... | @@ -227,7 +227,7 @@ pub const Value = extern union { |
| 227 | 227 | self: Value, |
| 228 | 228 | comptime fmt: []const u8, |
| 229 | 229 | options: std.fmt.FormatOptions, |
| 230 | out_stream: var, | |
| 230 | out_stream: anytype, | |
| 231 | 231 | ) !void { |
| 232 | 232 | comptime assert(fmt.len == 0); |
| 233 | 233 | var val = self; |
src-self-hosted/zir.zig+6-7| ... | ... | @@ -655,7 +655,7 @@ pub const Module = struct { |
| 655 | 655 | |
| 656 | 656 | /// The allocator is used for temporary storage, but this function always returns |
| 657 | 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 | 659 | var write = Writer{ |
| 660 | 660 | .module = &self, |
| 661 | 661 | .inst_table = InstPtrTable.init(allocator), |
| ... | ... | @@ -686,7 +686,6 @@ pub const Module = struct { |
| 686 | 686 | try stream.writeByte('\n'); |
| 687 | 687 | } |
| 688 | 688 | } |
| 689 | ||
| 690 | 689 | }; |
| 691 | 690 | |
| 692 | 691 | const InstPtrTable = std.AutoHashMap(*Inst, struct { inst: *Inst, index: ?usize, name: []const u8 }); |
| ... | ... | @@ -700,7 +699,7 @@ const Writer = struct { |
| 700 | 699 | |
| 701 | 700 | fn writeInstToStream( |
| 702 | 701 | self: *Writer, |
| 703 | stream: var, | |
| 702 | stream: anytype, | |
| 704 | 703 | inst: *Inst, |
| 705 | 704 | ) (@TypeOf(stream).Error || error{OutOfMemory})!void { |
| 706 | 705 | // TODO I tried implementing this with an inline for loop and hit a compiler bug |
| ... | ... | @@ -746,7 +745,7 @@ const Writer = struct { |
| 746 | 745 | |
| 747 | 746 | fn writeInstToStreamGeneric( |
| 748 | 747 | self: *Writer, |
| 749 | stream: var, | |
| 748 | stream: anytype, | |
| 750 | 749 | comptime inst_tag: Inst.Tag, |
| 751 | 750 | base: *Inst, |
| 752 | 751 | ) (@TypeOf(stream).Error || error{OutOfMemory})!void { |
| ... | ... | @@ -783,7 +782,7 @@ const Writer = struct { |
| 783 | 782 | try stream.writeByte(')'); |
| 784 | 783 | } |
| 785 | 784 | |
| 786 | fn writeParamToStream(self: *Writer, stream: var, param: var) !void { | |
| 785 | fn writeParamToStream(self: *Writer, stream: anytype, param: anytype) !void { | |
| 787 | 786 | if (@typeInfo(@TypeOf(param)) == .Enum) { |
| 788 | 787 | return stream.writeAll(@tagName(param)); |
| 789 | 788 | } |
| ... | ... | @@ -829,7 +828,7 @@ const Writer = struct { |
| 829 | 828 | } |
| 830 | 829 | } |
| 831 | 830 | |
| 832 | fn writeInstParamToStream(self: *Writer, stream: var, inst: *Inst) !void { | |
| 831 | fn writeInstParamToStream(self: *Writer, stream: anytype, inst: *Inst) !void { | |
| 833 | 832 | if (self.inst_table.get(inst)) |info| { |
| 834 | 833 | if (info.index) |i| { |
| 835 | 834 | try stream.print("%{}", .{info.index}); |
| ... | ... | @@ -1062,7 +1061,7 @@ const Parser = struct { |
| 1062 | 1061 | } |
| 1063 | 1062 | } |
| 1064 | 1063 | |
| 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 | 1065 | @setCold(true); |
| 1067 | 1066 | self.error_msg = ErrorMsg{ |
| 1068 | 1067 | .byte_offset = self.i, |
src/all_types.hpp+4-4| ... | ... | @@ -692,7 +692,7 @@ enum NodeType { |
| 692 | 692 | NodeTypeSuspend, |
| 693 | 693 | NodeTypeAnyFrameType, |
| 694 | 694 | NodeTypeEnumLiteral, |
| 695 | NodeTypeVarFieldType, | |
| 695 | NodeTypeAnyTypeField, | |
| 696 | 696 | }; |
| 697 | 697 | |
| 698 | 698 | enum FnInline { |
| ... | ... | @@ -705,7 +705,7 @@ struct AstNodeFnProto { |
| 705 | 705 | Buf *name; |
| 706 | 706 | ZigList<AstNode *> params; |
| 707 | 707 | AstNode *return_type; |
| 708 | Token *return_var_token; | |
| 708 | Token *return_anytype_token; | |
| 709 | 709 | AstNode *fn_def_node; |
| 710 | 710 | // populated if this is an extern declaration |
| 711 | 711 | Buf *lib_name; |
| ... | ... | @@ -734,7 +734,7 @@ struct AstNodeFnDef { |
| 734 | 734 | struct AstNodeParamDecl { |
| 735 | 735 | Buf *name; |
| 736 | 736 | AstNode *type; |
| 737 | Token *var_token; | |
| 737 | Token *anytype_token; | |
| 738 | 738 | Buf doc_comments; |
| 739 | 739 | bool is_noalias; |
| 740 | 740 | bool is_comptime; |
| ... | ... | @@ -2145,7 +2145,7 @@ struct CodeGen { |
| 2145 | 2145 | ZigType *entry_num_lit_float; |
| 2146 | 2146 | ZigType *entry_undef; |
| 2147 | 2147 | ZigType *entry_null; |
| 2148 | ZigType *entry_var; | |
| 2148 | ZigType *entry_anytype; | |
| 2149 | 2149 | ZigType *entry_global_error_set; |
| 2150 | 2150 | ZigType *entry_enum_literal; |
| 2151 | 2151 | ZigType *entry_any_frame; |
src/analyze.cpp+10-10| ... | ... | @@ -1129,7 +1129,7 @@ ZigValue *analyze_const_value(CodeGen *g, Scope *scope, AstNode *node, ZigType * |
| 1129 | 1129 | ZigValue *result = g->pass1_arena->create<ZigValue>(); |
| 1130 | 1130 | ZigValue *result_ptr = g->pass1_arena->create<ZigValue>(); |
| 1131 | 1131 | result->special = ConstValSpecialUndef; |
| 1132 | result->type = (type_entry == nullptr) ? g->builtin_types.entry_var : type_entry; | |
| 1132 | result->type = (type_entry == nullptr) ? g->builtin_types.entry_anytype : type_entry; | |
| 1133 | 1133 | result_ptr->special = ConstValSpecialStatic; |
| 1134 | 1134 | result_ptr->type = get_pointer_to_type(g, result->type, false); |
| 1135 | 1135 | result_ptr->data.x_ptr.mut = ConstPtrMutComptimeVar; |
| ... | ... | @@ -1230,7 +1230,7 @@ Error type_val_resolve_zero_bits(CodeGen *g, ZigValue *type_val, ZigType *parent |
| 1230 | 1230 | Error type_val_resolve_is_opaque_type(CodeGen *g, ZigValue *type_val, bool *is_opaque_type) { |
| 1231 | 1231 | if (type_val->special != ConstValSpecialLazy) { |
| 1232 | 1232 | assert(type_val->special == ConstValSpecialStatic); |
| 1233 | if (type_val->data.x_type == g->builtin_types.entry_var) { | |
| 1233 | if (type_val->data.x_type == g->builtin_types.entry_anytype) { | |
| 1234 | 1234 | *is_opaque_type = false; |
| 1235 | 1235 | return ErrorNone; |
| 1236 | 1236 | } |
| ... | ... | @@ -1511,13 +1511,13 @@ ZigType *get_generic_fn_type(CodeGen *g, FnTypeId *fn_type_id) { |
| 1511 | 1511 | } |
| 1512 | 1512 | for (; i < fn_type_id->param_count; i += 1) { |
| 1513 | 1513 | const char *comma_str = (i == 0) ? "" : ","; |
| 1514 | buf_appendf(&fn_type->name, "%svar", comma_str); | |
| 1514 | buf_appendf(&fn_type->name, "%sanytype", comma_str); | |
| 1515 | 1515 | } |
| 1516 | 1516 | buf_append_str(&fn_type->name, ")"); |
| 1517 | 1517 | if (fn_type_id->cc != CallingConventionUnspecified) { |
| 1518 | 1518 | buf_appendf(&fn_type->name, " callconv(.%s)", calling_convention_name(fn_type_id->cc)); |
| 1519 | 1519 | } |
| 1520 | buf_append_str(&fn_type->name, " var"); | |
| 1520 | buf_append_str(&fn_type->name, " anytype"); | |
| 1521 | 1521 | |
| 1522 | 1522 | fn_type->data.fn.fn_type_id = *fn_type_id; |
| 1523 | 1523 | fn_type->data.fn.is_generic = true; |
| ... | ... | @@ -1853,10 +1853,10 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc |
| 1853 | 1853 | buf_sprintf("var args only allowed in functions with C calling convention")); |
| 1854 | 1854 | return g->builtin_types.entry_invalid; |
| 1855 | 1855 | } |
| 1856 | } else if (param_node->data.param_decl.var_token != nullptr) { | |
| 1856 | } else if (param_node->data.param_decl.anytype_token != nullptr) { | |
| 1857 | 1857 | if (!calling_convention_allows_zig_types(fn_type_id.cc)) { |
| 1858 | 1858 | add_node_error(g, param_node, |
| 1859 | buf_sprintf("parameter of type 'var' not allowed in function with calling convention '%s'", | |
| 1859 | buf_sprintf("parameter of type 'anytype' not allowed in function with calling convention '%s'", | |
| 1860 | 1860 | calling_convention_name(fn_type_id.cc))); |
| 1861 | 1861 | return g->builtin_types.entry_invalid; |
| 1862 | 1862 | } |
| ... | ... | @@ -1942,10 +1942,10 @@ static ZigType *analyze_fn_type(CodeGen *g, AstNode *proto_node, Scope *child_sc |
| 1942 | 1942 | fn_entry->align_bytes = fn_type_id.alignment; |
| 1943 | 1943 | } |
| 1944 | 1944 | |
| 1945 | if (fn_proto->return_var_token != nullptr) { | |
| 1945 | if (fn_proto->return_anytype_token != nullptr) { | |
| 1946 | 1946 | if (!calling_convention_allows_zig_types(fn_type_id.cc)) { |
| 1947 | 1947 | add_node_error(g, fn_proto->return_type, |
| 1948 | buf_sprintf("return type 'var' not allowed in function with calling convention '%s'", | |
| 1948 | buf_sprintf("return type 'anytype' not allowed in function with calling convention '%s'", | |
| 1949 | 1949 | calling_convention_name(fn_type_id.cc))); |
| 1950 | 1950 | return g->builtin_types.entry_invalid; |
| 1951 | 1951 | } |
| ... | ... | @@ -3802,7 +3802,7 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) { |
| 3802 | 3802 | case NodeTypeEnumLiteral: |
| 3803 | 3803 | case NodeTypeAnyFrameType: |
| 3804 | 3804 | case NodeTypeErrorSetField: |
| 3805 | case NodeTypeVarFieldType: | |
| 3805 | case NodeTypeAnyTypeField: | |
| 3806 | 3806 | zig_unreachable(); |
| 3807 | 3807 | } |
| 3808 | 3808 | } |
| ... | ... | @@ -5868,7 +5868,7 @@ ZigValue *get_the_one_possible_value(CodeGen *g, ZigType *type_entry) { |
| 5868 | 5868 | |
| 5869 | 5869 | ReqCompTime type_requires_comptime(CodeGen *g, ZigType *ty) { |
| 5870 | 5870 | Error err; |
| 5871 | if (ty == g->builtin_types.entry_var) { | |
| 5871 | if (ty == g->builtin_types.entry_anytype) { | |
| 5872 | 5872 | return ReqCompTimeYes; |
| 5873 | 5873 | } |
| 5874 | 5874 | switch (ty->id) { |
src/ast_render.cpp+8-8| ... | ... | @@ -270,8 +270,8 @@ static const char *node_type_str(NodeType node_type) { |
| 270 | 270 | return "EnumLiteral"; |
| 271 | 271 | case NodeTypeErrorSetField: |
| 272 | 272 | return "ErrorSetField"; |
| 273 | case NodeTypeVarFieldType: | |
| 274 | return "VarFieldType"; | |
| 273 | case NodeTypeAnyTypeField: | |
| 274 | return "AnyTypeField"; | |
| 275 | 275 | } |
| 276 | 276 | zig_unreachable(); |
| 277 | 277 | } |
| ... | ... | @@ -466,8 +466,8 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) { |
| 466 | 466 | } |
| 467 | 467 | if (param_decl->data.param_decl.is_var_args) { |
| 468 | 468 | fprintf(ar->f, "..."); |
| 469 | } else if (param_decl->data.param_decl.var_token != nullptr) { | |
| 470 | fprintf(ar->f, "var"); | |
| 469 | } else if (param_decl->data.param_decl.anytype_token != nullptr) { | |
| 470 | fprintf(ar->f, "anytype"); | |
| 471 | 471 | } else { |
| 472 | 472 | render_node_grouped(ar, param_decl->data.param_decl.type); |
| 473 | 473 | } |
| ... | ... | @@ -496,8 +496,8 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) { |
| 496 | 496 | fprintf(ar->f, ")"); |
| 497 | 497 | } |
| 498 | 498 | |
| 499 | if (node->data.fn_proto.return_var_token != nullptr) { | |
| 500 | fprintf(ar->f, "var"); | |
| 499 | if (node->data.fn_proto.return_anytype_token != nullptr) { | |
| 500 | fprintf(ar->f, "anytype"); | |
| 501 | 501 | } else { |
| 502 | 502 | AstNode *return_type_node = node->data.fn_proto.return_type; |
| 503 | 503 | assert(return_type_node != nullptr); |
| ... | ... | @@ -1216,8 +1216,8 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) { |
| 1216 | 1216 | fprintf(ar->f, ".%s", buf_ptr(&node->data.enum_literal.identifier->data.str_lit.str)); |
| 1217 | 1217 | break; |
| 1218 | 1218 | } |
| 1219 | case NodeTypeVarFieldType: { | |
| 1220 | fprintf(ar->f, "var"); | |
| 1219 | case NodeTypeAnyTypeField: { | |
| 1220 | fprintf(ar->f, "anytype"); | |
| 1221 | 1221 | break; |
| 1222 | 1222 | } |
| 1223 | 1223 | case NodeTypeParamDecl: |
src/codegen.cpp+2-2| ... | ... | @@ -8448,8 +8448,8 @@ static void define_builtin_types(CodeGen *g) { |
| 8448 | 8448 | } |
| 8449 | 8449 | { |
| 8450 | 8450 | ZigType *entry = new_type_table_entry(ZigTypeIdOpaque); |
| 8451 | buf_init_from_str(&entry->name, "(var)"); | |
| 8452 | g->builtin_types.entry_var = entry; | |
| 8451 | buf_init_from_str(&entry->name, "(anytype)"); | |
| 8452 | g->builtin_types.entry_anytype = entry; | |
| 8453 | 8453 | } |
| 8454 | 8454 | |
| 8455 | 8455 | for (size_t i = 0; i < array_length(c_int_type_infos); i += 1) { |
src/ir.cpp+32-27| ... | ... | @@ -9942,7 +9942,7 @@ static IrInstSrc *ir_gen_fn_proto(IrBuilderSrc *irb, Scope *parent_scope, AstNod |
| 9942 | 9942 | is_var_args = true; |
| 9943 | 9943 | break; |
| 9944 | 9944 | } |
| 9945 | if (param_node->data.param_decl.var_token == nullptr) { | |
| 9945 | if (param_node->data.param_decl.anytype_token == nullptr) { | |
| 9946 | 9946 | AstNode *type_node = param_node->data.param_decl.type; |
| 9947 | 9947 | IrInstSrc *type_value = ir_gen_node(irb, type_node, parent_scope); |
| 9948 | 9948 | if (type_value == irb->codegen->invalid_inst_src) |
| ... | ... | @@ -9968,7 +9968,7 @@ static IrInstSrc *ir_gen_fn_proto(IrBuilderSrc *irb, Scope *parent_scope, AstNod |
| 9968 | 9968 | } |
| 9969 | 9969 | |
| 9970 | 9970 | IrInstSrc *return_type; |
| 9971 | if (node->data.fn_proto.return_var_token == nullptr) { | |
| 9971 | if (node->data.fn_proto.return_anytype_token == nullptr) { | |
| 9972 | 9972 | if (node->data.fn_proto.return_type == nullptr) { |
| 9973 | 9973 | return_type = ir_build_const_type(irb, parent_scope, node, irb->codegen->builtin_types.entry_void); |
| 9974 | 9974 | } else { |
| ... | ... | @@ -10226,9 +10226,9 @@ static IrInstSrc *ir_gen_node_raw(IrBuilderSrc *irb, AstNode *node, Scope *scope |
| 10226 | 10226 | add_node_error(irb->codegen, node, |
| 10227 | 10227 | buf_sprintf("inferred array size invalid here")); |
| 10228 | 10228 | return irb->codegen->invalid_inst_src; |
| 10229 | case NodeTypeVarFieldType: | |
| 10229 | case NodeTypeAnyTypeField: | |
| 10230 | 10230 | return ir_lval_wrap(irb, scope, |
| 10231 | ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_var), lval, result_loc); | |
| 10231 | ir_build_const_type(irb, scope, node, irb->codegen->builtin_types.entry_anytype), lval, result_loc); | |
| 10232 | 10232 | } |
| 10233 | 10233 | zig_unreachable(); |
| 10234 | 10234 | } |
| ... | ... | @@ -10296,7 +10296,7 @@ static IrInstSrc *ir_gen_node_extra(IrBuilderSrc *irb, AstNode *node, Scope *sco |
| 10296 | 10296 | case NodeTypeSuspend: |
| 10297 | 10297 | case NodeTypeEnumLiteral: |
| 10298 | 10298 | case NodeTypeInferredArrayType: |
| 10299 | case NodeTypeVarFieldType: | |
| 10299 | case NodeTypeAnyTypeField: | |
| 10300 | 10300 | case NodeTypePrefixOpExpr: |
| 10301 | 10301 | add_node_error(irb->codegen, node, |
| 10302 | 10302 | buf_sprintf("invalid left-hand side to assignment")); |
| ... | ... | @@ -10518,7 +10518,7 @@ ZigValue *const_ptr_pointee(IrAnalyze *ira, CodeGen *codegen, ZigValue *const_va |
| 10518 | 10518 | if (val == nullptr) return nullptr; |
| 10519 | 10519 | assert(const_val->type->id == ZigTypeIdPointer); |
| 10520 | 10520 | ZigType *expected_type = const_val->type->data.pointer.child_type; |
| 10521 | if (expected_type == codegen->builtin_types.entry_var) { | |
| 10521 | if (expected_type == codegen->builtin_types.entry_anytype) { | |
| 10522 | 10522 | return val; |
| 10523 | 10523 | } |
| 10524 | 10524 | switch (type_has_one_possible_value(codegen, expected_type)) { |
| ... | ... | @@ -15040,7 +15040,7 @@ static IrInstGen *ir_analyze_cast(IrAnalyze *ira, IrInst *source_instr, |
| 15040 | 15040 | } |
| 15041 | 15041 | |
| 15042 | 15042 | // This means the wanted type is anything. |
| 15043 | if (wanted_type == ira->codegen->builtin_types.entry_var) { | |
| 15043 | if (wanted_type == ira->codegen->builtin_types.entry_anytype) { | |
| 15044 | 15044 | return value; |
| 15045 | 15045 | } |
| 15046 | 15046 | |
| ... | ... | @@ -15635,7 +15635,7 @@ static IrInstGen *ir_implicit_cast(IrAnalyze *ira, IrInstGen *value, ZigType *ex |
| 15635 | 15635 | static ZigType *get_ptr_elem_type(CodeGen *g, IrInstGen *ptr) { |
| 15636 | 15636 | ir_assert_gen(ptr->value->type->id == ZigTypeIdPointer, ptr); |
| 15637 | 15637 | ZigType *elem_type = ptr->value->type->data.pointer.child_type; |
| 15638 | if (elem_type != g->builtin_types.entry_var) | |
| 15638 | if (elem_type != g->builtin_types.entry_anytype) | |
| 15639 | 15639 | return elem_type; |
| 15640 | 15640 | |
| 15641 | 15641 | if (ir_resolve_lazy(g, ptr->base.source_node, ptr->value)) |
| ... | ... | @@ -15687,7 +15687,7 @@ static IrInstGen *ir_get_deref(IrAnalyze *ira, IrInst* source_instruction, IrIns |
| 15687 | 15687 | } |
| 15688 | 15688 | if (ptr->value->data.x_ptr.mut != ConstPtrMutRuntimeVar) { |
| 15689 | 15689 | ZigValue *pointee = const_ptr_pointee_unchecked(ira->codegen, ptr->value); |
| 15690 | if (child_type == ira->codegen->builtin_types.entry_var) { | |
| 15690 | if (child_type == ira->codegen->builtin_types.entry_anytype) { | |
| 15691 | 15691 | child_type = pointee->type; |
| 15692 | 15692 | } |
| 15693 | 15693 | if (pointee->special != ConstValSpecialRuntime) { |
| ... | ... | @@ -19087,7 +19087,7 @@ static Error ir_result_has_type(IrAnalyze *ira, ResultLoc *result_loc, bool *out |
| 19087 | 19087 | ZigType *dest_type = ir_resolve_type(ira, result_cast->base.source_instruction->child); |
| 19088 | 19088 | if (type_is_invalid(dest_type)) |
| 19089 | 19089 | return ErrorSemanticAnalyzeFail; |
| 19090 | *out = (dest_type != ira->codegen->builtin_types.entry_var); | |
| 19090 | *out = (dest_type != ira->codegen->builtin_types.entry_anytype); | |
| 19091 | 19091 | return ErrorNone; |
| 19092 | 19092 | } |
| 19093 | 19093 | case ResultLocIdVar: |
| ... | ... | @@ -19293,7 +19293,7 @@ static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInst *suspend_source_i |
| 19293 | 19293 | if (type_is_invalid(dest_type)) |
| 19294 | 19294 | return ira->codegen->invalid_inst_gen; |
| 19295 | 19295 | |
| 19296 | if (dest_type == ira->codegen->builtin_types.entry_var) { | |
| 19296 | if (dest_type == ira->codegen->builtin_types.entry_anytype) { | |
| 19297 | 19297 | return ir_resolve_no_result_loc(ira, suspend_source_instr, result_loc, value_type); |
| 19298 | 19298 | } |
| 19299 | 19299 | |
| ... | ... | @@ -19439,7 +19439,7 @@ static IrInstGen *ir_resolve_result_raw(IrAnalyze *ira, IrInst *suspend_source_i |
| 19439 | 19439 | return ira->codegen->invalid_inst_gen; |
| 19440 | 19440 | } |
| 19441 | 19441 | |
| 19442 | if (child_type != ira->codegen->builtin_types.entry_var) { | |
| 19442 | if (child_type != ira->codegen->builtin_types.entry_anytype) { | |
| 19443 | 19443 | if (type_size(ira->codegen, child_type) != type_size(ira->codegen, value_type)) { |
| 19444 | 19444 | // pointer cast won't work; we need a temporary location. |
| 19445 | 19445 | result_bit_cast->parent->written = parent_was_written; |
| ... | ... | @@ -19600,9 +19600,9 @@ static IrInstGen *ir_analyze_instruction_resolve_result(IrAnalyze *ira, IrInstSr |
| 19600 | 19600 | if (type_is_invalid(implicit_elem_type)) |
| 19601 | 19601 | return ira->codegen->invalid_inst_gen; |
| 19602 | 19602 | } else { |
| 19603 | implicit_elem_type = ira->codegen->builtin_types.entry_var; | |
| 19603 | implicit_elem_type = ira->codegen->builtin_types.entry_anytype; | |
| 19604 | 19604 | } |
| 19605 | if (implicit_elem_type == ira->codegen->builtin_types.entry_var) { | |
| 19605 | if (implicit_elem_type == ira->codegen->builtin_types.entry_anytype) { | |
| 19606 | 19606 | Buf *bare_name = buf_alloc(); |
| 19607 | 19607 | Buf *name = get_anon_type_name(ira->codegen, nullptr, container_string(ContainerKindStruct), |
| 19608 | 19608 | instruction->base.base.scope, instruction->base.base.source_node, bare_name); |
| ... | ... | @@ -19759,7 +19759,7 @@ static bool ir_analyze_fn_call_inline_arg(IrAnalyze *ira, AstNode *fn_proto_node |
| 19759 | 19759 | assert(param_decl_node->type == NodeTypeParamDecl); |
| 19760 | 19760 | |
| 19761 | 19761 | IrInstGen *casted_arg; |
| 19762 | if (param_decl_node->data.param_decl.var_token == nullptr) { | |
| 19762 | if (param_decl_node->data.param_decl.anytype_token == nullptr) { | |
| 19763 | 19763 | AstNode *param_type_node = param_decl_node->data.param_decl.type; |
| 19764 | 19764 | ZigType *param_type = ir_analyze_type_expr(ira, *exec_scope, param_type_node); |
| 19765 | 19765 | if (type_is_invalid(param_type)) |
| ... | ... | @@ -19799,7 +19799,7 @@ static bool ir_analyze_fn_call_generic_arg(IrAnalyze *ira, AstNode *fn_proto_nod |
| 19799 | 19799 | arg_part_of_generic_id = true; |
| 19800 | 19800 | casted_arg = arg; |
| 19801 | 19801 | } else { |
| 19802 | if (param_decl_node->data.param_decl.var_token == nullptr) { | |
| 19802 | if (param_decl_node->data.param_decl.anytype_token == nullptr) { | |
| 19803 | 19803 | AstNode *param_type_node = param_decl_node->data.param_decl.type; |
| 19804 | 19804 | ZigType *param_type = ir_analyze_type_expr(ira, *child_scope, param_type_node); |
| 19805 | 19805 | if (type_is_invalid(param_type)) |
| ... | ... | @@ -20011,7 +20011,7 @@ static IrInstGen *ir_analyze_store_ptr(IrAnalyze *ira, IrInst* source_instr, |
| 20011 | 20011 | } |
| 20012 | 20012 | |
| 20013 | 20013 | if (ptr->value->type->data.pointer.inferred_struct_field != nullptr && |
| 20014 | child_type == ira->codegen->builtin_types.entry_var) | |
| 20014 | child_type == ira->codegen->builtin_types.entry_anytype) | |
| 20015 | 20015 | { |
| 20016 | 20016 | child_type = ptr->value->type->data.pointer.inferred_struct_field->inferred_struct_type; |
| 20017 | 20017 | } |
| ... | ... | @@ -20202,6 +20202,11 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 20202 | 20202 | } |
| 20203 | 20203 | |
| 20204 | 20204 | AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type; |
| 20205 | if (return_type_node == nullptr) { | |
| 20206 | ir_add_error(ira, &fn_ref->base, | |
| 20207 | buf_sprintf("TODO implement inferred return types https://github.com/ziglang/zig/issues/447")); | |
| 20208 | return ira->codegen->invalid_inst_gen; | |
| 20209 | } | |
| 20205 | 20210 | ZigType *specified_return_type = ir_analyze_type_expr(ira, exec_scope, return_type_node); |
| 20206 | 20211 | if (type_is_invalid(specified_return_type)) |
| 20207 | 20212 | return ira->codegen->invalid_inst_gen; |
| ... | ... | @@ -20364,7 +20369,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 20364 | 20369 | inst_fn_type_id.alignment = align_bytes; |
| 20365 | 20370 | } |
| 20366 | 20371 | |
| 20367 | if (fn_proto_node->data.fn_proto.return_var_token == nullptr) { | |
| 20372 | if (fn_proto_node->data.fn_proto.return_anytype_token == nullptr) { | |
| 20368 | 20373 | AstNode *return_type_node = fn_proto_node->data.fn_proto.return_type; |
| 20369 | 20374 | ZigType *specified_return_type = ir_analyze_type_expr(ira, impl_fn->child_scope, return_type_node); |
| 20370 | 20375 | if (type_is_invalid(specified_return_type)) |
| ... | ... | @@ -20463,7 +20468,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 20463 | 20468 | if (type_is_invalid(dummy_result->value->type)) |
| 20464 | 20469 | return ira->codegen->invalid_inst_gen; |
| 20465 | 20470 | ZigType *res_child_type = result_loc->value->type->data.pointer.child_type; |
| 20466 | if (res_child_type == ira->codegen->builtin_types.entry_var) { | |
| 20471 | if (res_child_type == ira->codegen->builtin_types.entry_anytype) { | |
| 20467 | 20472 | res_child_type = impl_fn_type_id->return_type; |
| 20468 | 20473 | } |
| 20469 | 20474 | if (!handle_is_ptr(ira->codegen, res_child_type)) { |
| ... | ... | @@ -20606,7 +20611,7 @@ static IrInstGen *ir_analyze_fn_call(IrAnalyze *ira, IrInst* source_instr, |
| 20606 | 20611 | if (type_is_invalid(dummy_result->value->type)) |
| 20607 | 20612 | return ira->codegen->invalid_inst_gen; |
| 20608 | 20613 | ZigType *res_child_type = result_loc->value->type->data.pointer.child_type; |
| 20609 | if (res_child_type == ira->codegen->builtin_types.entry_var) { | |
| 20614 | if (res_child_type == ira->codegen->builtin_types.entry_anytype) { | |
| 20610 | 20615 | res_child_type = return_type; |
| 20611 | 20616 | } |
| 20612 | 20617 | if (!handle_is_ptr(ira->codegen, res_child_type)) { |
| ... | ... | @@ -22337,7 +22342,7 @@ static IrInstGen *ir_analyze_inferred_field_ptr(IrAnalyze *ira, Buf *field_name, |
| 22337 | 22342 | inferred_struct_field->inferred_struct_type = container_type; |
| 22338 | 22343 | inferred_struct_field->field_name = field_name; |
| 22339 | 22344 | |
| 22340 | ZigType *elem_type = ira->codegen->builtin_types.entry_var; | |
| 22345 | ZigType *elem_type = ira->codegen->builtin_types.entry_anytype; | |
| 22341 | 22346 | ZigType *field_ptr_type = get_pointer_to_type_extra2(ira->codegen, elem_type, |
| 22342 | 22347 | container_ptr_type->data.pointer.is_const, container_ptr_type->data.pointer.is_volatile, |
| 22343 | 22348 | PtrLenSingle, 0, 0, 0, false, VECTOR_INDEX_NONE, inferred_struct_field, nullptr); |
| ... | ... | @@ -25115,7 +25120,7 @@ static ZigValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_type_ent |
| 25115 | 25120 | fields[5]->special = ConstValSpecialStatic; |
| 25116 | 25121 | fields[5]->type = ira->codegen->builtin_types.entry_bool; |
| 25117 | 25122 | fields[5]->data.x_bool = attrs_type->data.pointer.allow_zero; |
| 25118 | // sentinel: var | |
| 25123 | // sentinel: anytype | |
| 25119 | 25124 | ensure_field_index(result->type, "sentinel", 6); |
| 25120 | 25125 | fields[6]->special = ConstValSpecialStatic; |
| 25121 | 25126 | if (attrs_type->data.pointer.child_type->id != ZigTypeIdOpaque) { |
| ... | ... | @@ -25243,7 +25248,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 25243 | 25248 | fields[1]->special = ConstValSpecialStatic; |
| 25244 | 25249 | fields[1]->type = ira->codegen->builtin_types.entry_type; |
| 25245 | 25250 | fields[1]->data.x_type = type_entry->data.array.child_type; |
| 25246 | // sentinel: var | |
| 25251 | // sentinel: anytype | |
| 25247 | 25252 | fields[2]->special = ConstValSpecialStatic; |
| 25248 | 25253 | fields[2]->type = get_optional_type(ira->codegen, type_entry->data.array.child_type); |
| 25249 | 25254 | fields[2]->data.x_optional = type_entry->data.array.sentinel; |
| ... | ... | @@ -25598,7 +25603,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 25598 | 25603 | inner_fields[2]->type = ira->codegen->builtin_types.entry_type; |
| 25599 | 25604 | inner_fields[2]->data.x_type = struct_field->type_entry; |
| 25600 | 25605 | |
| 25601 | // default_value: var | |
| 25606 | // default_value: anytype | |
| 25602 | 25607 | inner_fields[3]->special = ConstValSpecialStatic; |
| 25603 | 25608 | inner_fields[3]->type = get_optional_type2(ira->codegen, struct_field->type_entry); |
| 25604 | 25609 | if (inner_fields[3]->type == nullptr) return ErrorSemanticAnalyzeFail; |
| ... | ... | @@ -25736,7 +25741,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy |
| 25736 | 25741 | ZigValue **fields = alloc_const_vals_ptrs(ira->codegen, 1); |
| 25737 | 25742 | result->data.x_struct.fields = fields; |
| 25738 | 25743 | ZigFn *fn = type_entry->data.frame.fn; |
| 25739 | // function: var | |
| 25744 | // function: anytype | |
| 25740 | 25745 | ensure_field_index(result->type, "function", 0); |
| 25741 | 25746 | fields[0] = create_const_fn(ira->codegen, fn); |
| 25742 | 25747 | break; |
| ... | ... | @@ -29996,7 +30001,7 @@ static IrInstGen *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstSrcArgTy |
| 29996 | 30001 | if (arg_index >= fn_type_id->param_count) { |
| 29997 | 30002 | if (instruction->allow_var) { |
| 29998 | 30003 | // TODO remove this with var args |
| 29999 | return ir_const_type(ira, &instruction->base.base, ira->codegen->builtin_types.entry_var); | |
| 30004 | return ir_const_type(ira, &instruction->base.base, ira->codegen->builtin_types.entry_anytype); | |
| 30000 | 30005 | } |
| 30001 | 30006 | ir_add_error(ira, &arg_index_inst->base, |
| 30002 | 30007 | buf_sprintf("arg index %" ZIG_PRI_u64 " out of bounds; '%s' has %" ZIG_PRI_usize " arguments", |
| ... | ... | @@ -30010,7 +30015,7 @@ static IrInstGen *ir_analyze_instruction_arg_type(IrAnalyze *ira, IrInstSrcArgTy |
| 30010 | 30015 | ir_assert(fn_type->data.fn.is_generic, &instruction->base.base); |
| 30011 | 30016 | |
| 30012 | 30017 | if (instruction->allow_var) { |
| 30013 | return ir_const_type(ira, &instruction->base.base, ira->codegen->builtin_types.entry_var); | |
| 30018 | return ir_const_type(ira, &instruction->base.base, ira->codegen->builtin_types.entry_anytype); | |
| 30014 | 30019 | } else { |
| 30015 | 30020 | ir_add_error(ira, &arg_index_inst->base, |
| 30016 | 30021 | buf_sprintf("@ArgType could not resolve the type of arg %" ZIG_PRI_u64 " because '%s' is generic", |
src/parser.cpp+13-13| ... | ... | @@ -786,7 +786,7 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B |
| 786 | 786 | return nullptr; |
| 787 | 787 | } |
| 788 | 788 | |
| 789 | // FnProto <- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_var / TypeExpr) | |
| 789 | // FnProto <- KEYWORD_fn IDENTIFIER? LPAREN ParamDeclList RPAREN ByteAlign? LinkSection? EXCLAMATIONMARK? (KEYWORD_anytype / TypeExpr) | |
| 790 | 790 | static AstNode *ast_parse_fn_proto(ParseContext *pc) { |
| 791 | 791 | Token *first = eat_token_if(pc, TokenIdKeywordFn); |
| 792 | 792 | if (first == nullptr) { |
| ... | ... | @@ -801,10 +801,10 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) { |
| 801 | 801 | AstNode *align_expr = ast_parse_byte_align(pc); |
| 802 | 802 | AstNode *section_expr = ast_parse_link_section(pc); |
| 803 | 803 | AstNode *callconv_expr = ast_parse_callconv(pc); |
| 804 | Token *var = eat_token_if(pc, TokenIdKeywordVar); | |
| 804 | Token *anytype = eat_token_if(pc, TokenIdKeywordAnyType); | |
| 805 | 805 | Token *exmark = nullptr; |
| 806 | 806 | AstNode *return_type = nullptr; |
| 807 | if (var == nullptr) { | |
| 807 | if (anytype == nullptr) { | |
| 808 | 808 | exmark = eat_token_if(pc, TokenIdBang); |
| 809 | 809 | return_type = ast_expect(pc, ast_parse_type_expr); |
| 810 | 810 | } |
| ... | ... | @@ -816,7 +816,7 @@ static AstNode *ast_parse_fn_proto(ParseContext *pc) { |
| 816 | 816 | res->data.fn_proto.align_expr = align_expr; |
| 817 | 817 | res->data.fn_proto.section_expr = section_expr; |
| 818 | 818 | res->data.fn_proto.callconv_expr = callconv_expr; |
| 819 | res->data.fn_proto.return_var_token = var; | |
| 819 | res->data.fn_proto.return_anytype_token = anytype; | |
| 820 | 820 | res->data.fn_proto.auto_err_set = exmark != nullptr; |
| 821 | 821 | res->data.fn_proto.return_type = return_type; |
| 822 | 822 | |
| ... | ... | @@ -870,9 +870,9 @@ static AstNode *ast_parse_container_field(ParseContext *pc) { |
| 870 | 870 | |
| 871 | 871 | AstNode *type_expr = nullptr; |
| 872 | 872 | if (eat_token_if(pc, TokenIdColon) != nullptr) { |
| 873 | Token *var_tok = eat_token_if(pc, TokenIdKeywordVar); | |
| 874 | if (var_tok != nullptr) { | |
| 875 | type_expr = ast_create_node(pc, NodeTypeVarFieldType, var_tok); | |
| 873 | Token *anytype_tok = eat_token_if(pc, TokenIdKeywordAnyType); | |
| 874 | if (anytype_tok != nullptr) { | |
| 875 | type_expr = ast_create_node(pc, NodeTypeAnyTypeField, anytype_tok); | |
| 876 | 876 | } else { |
| 877 | 877 | type_expr = ast_expect(pc, ast_parse_type_expr); |
| 878 | 878 | } |
| ... | ... | @@ -2191,14 +2191,14 @@ static AstNode *ast_parse_param_decl(ParseContext *pc) { |
| 2191 | 2191 | } |
| 2192 | 2192 | |
| 2193 | 2193 | // ParamType |
| 2194 | // <- KEYWORD_var | |
| 2194 | // <- KEYWORD_anytype | |
| 2195 | 2195 | // / DOT3 |
| 2196 | 2196 | // / TypeExpr |
| 2197 | 2197 | static AstNode *ast_parse_param_type(ParseContext *pc) { |
| 2198 | Token *var_token = eat_token_if(pc, TokenIdKeywordVar); | |
| 2199 | if (var_token != nullptr) { | |
| 2200 | AstNode *res = ast_create_node(pc, NodeTypeParamDecl, var_token); | |
| 2201 | res->data.param_decl.var_token = var_token; | |
| 2198 | Token *anytype_token = eat_token_if(pc, TokenIdKeywordAnyType); | |
| 2199 | if (anytype_token != nullptr) { | |
| 2200 | AstNode *res = ast_create_node(pc, NodeTypeParamDecl, anytype_token); | |
| 2201 | res->data.param_decl.anytype_token = anytype_token; | |
| 2202 | 2202 | return res; |
| 2203 | 2203 | } |
| 2204 | 2204 | |
| ... | ... | @@ -3207,7 +3207,7 @@ void ast_visit_node_children(AstNode *node, void (*visit)(AstNode **, void *cont |
| 3207 | 3207 | visit_field(&node->data.suspend.block, visit, context); |
| 3208 | 3208 | break; |
| 3209 | 3209 | case NodeTypeEnumLiteral: |
| 3210 | case NodeTypeVarFieldType: | |
| 3210 | case NodeTypeAnyTypeField: | |
| 3211 | 3211 | break; |
| 3212 | 3212 | } |
| 3213 | 3213 | } |
src/tokenizer.cpp+2| ... | ... | @@ -106,6 +106,7 @@ static const struct ZigKeyword zig_keywords[] = { |
| 106 | 106 | {"allowzero", TokenIdKeywordAllowZero}, |
| 107 | 107 | {"and", TokenIdKeywordAnd}, |
| 108 | 108 | {"anyframe", TokenIdKeywordAnyFrame}, |
| 109 | {"anytype", TokenIdKeywordAnyType}, | |
| 109 | 110 | {"asm", TokenIdKeywordAsm}, |
| 110 | 111 | {"async", TokenIdKeywordAsync}, |
| 111 | 112 | {"await", TokenIdKeywordAwait}, |
| ... | ... | @@ -1569,6 +1570,7 @@ const char * token_name(TokenId id) { |
| 1569 | 1570 | case TokenIdKeywordAlign: return "align"; |
| 1570 | 1571 | case TokenIdKeywordAnd: return "and"; |
| 1571 | 1572 | case TokenIdKeywordAnyFrame: return "anyframe"; |
| 1573 | case TokenIdKeywordAnyType: return "anytype"; | |
| 1572 | 1574 | case TokenIdKeywordAsm: return "asm"; |
| 1573 | 1575 | case TokenIdKeywordBreak: return "break"; |
| 1574 | 1576 | case TokenIdKeywordCatch: return "catch"; |
src/tokenizer.hpp+1| ... | ... | @@ -54,6 +54,7 @@ enum TokenId { |
| 54 | 54 | TokenIdKeywordAllowZero, |
| 55 | 55 | TokenIdKeywordAnd, |
| 56 | 56 | TokenIdKeywordAnyFrame, |
| 57 | TokenIdKeywordAnyType, | |
| 57 | 58 | TokenIdKeywordAsm, |
| 58 | 59 | TokenIdKeywordAsync, |
| 59 | 60 | TokenIdKeywordAwait, |
test/compile_errors.zig+17-17| ... | ... | @@ -42,7 +42,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 42 | 42 | \\fn foo() Foo { |
| 43 | 43 | \\ return .{ .x = 42 }; |
| 44 | 44 | \\} |
| 45 | \\fn bar(val: var) Foo { | |
| 45 | \\fn bar(val: anytype) Foo { | |
| 46 | 46 | \\ return .{ .x = val }; |
| 47 | 47 | \\} |
| 48 | 48 | \\export fn entry() void { |
| ... | ... | @@ -1034,7 +1034,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 1034 | 1034 | \\ storev(&v[i], 42); |
| 1035 | 1035 | \\} |
| 1036 | 1036 | \\ |
| 1037 | \\fn storev(ptr: var, val: i32) void { | |
| 1037 | \\fn storev(ptr: anytype, val: i32) void { | |
| 1038 | 1038 | \\ ptr.* = val; |
| 1039 | 1039 | \\} |
| 1040 | 1040 | , &[_][]const u8{ |
| ... | ... | @@ -1049,7 +1049,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 1049 | 1049 | \\ var x = loadv(&v[i]); |
| 1050 | 1050 | \\} |
| 1051 | 1051 | \\ |
| 1052 | \\fn loadv(ptr: var) i32 { | |
| 1052 | \\fn loadv(ptr: anytype) i32 { | |
| 1053 | 1053 | \\ return ptr.*; |
| 1054 | 1054 | \\} |
| 1055 | 1055 | , &[_][]const u8{ |
| ... | ... | @@ -1832,7 +1832,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 1832 | 1832 | \\ while (true) {} |
| 1833 | 1833 | \\} |
| 1834 | 1834 | , &[_][]const u8{ |
| 1835 | "error: expected type 'fn([]const u8, ?*std.builtin.StackTrace) noreturn', found 'fn([]const u8,var) var'", | |
| 1835 | "error: expected type 'fn([]const u8, ?*std.builtin.StackTrace) noreturn', found 'fn([]const u8,anytype) anytype'", | |
| 1836 | 1836 | "note: only one of the functions is generic", |
| 1837 | 1837 | }); |
| 1838 | 1838 | |
| ... | ... | @@ -2032,11 +2032,11 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2032 | 2032 | }); |
| 2033 | 2033 | |
| 2034 | 2034 | cases.add("export generic function", |
| 2035 | \\export fn foo(num: var) i32 { | |
| 2035 | \\export fn foo(num: anytype) i32 { | |
| 2036 | 2036 | \\ return 0; |
| 2037 | 2037 | \\} |
| 2038 | 2038 | , &[_][]const u8{ |
| 2039 | "tmp.zig:1:15: error: parameter of type 'var' not allowed in function with calling convention 'C'", | |
| 2039 | "tmp.zig:1:15: error: parameter of type 'anytype' not allowed in function with calling convention 'C'", | |
| 2040 | 2040 | }); |
| 2041 | 2041 | |
| 2042 | 2042 | cases.add("C pointer to c_void", |
| ... | ... | @@ -2836,7 +2836,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2836 | 2836 | }); |
| 2837 | 2837 | |
| 2838 | 2838 | cases.add("missing parameter name of generic function", |
| 2839 | \\fn dump(var) void {} | |
| 2839 | \\fn dump(anytype) void {} | |
| 2840 | 2840 | \\export fn entry() void { |
| 2841 | 2841 | \\ var a: u8 = 9; |
| 2842 | 2842 | \\ dump(a); |
| ... | ... | @@ -2859,13 +2859,13 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2859 | 2859 | }); |
| 2860 | 2860 | |
| 2861 | 2861 | cases.add("generic fn as parameter without comptime keyword", |
| 2862 | \\fn f(_: fn (var) void) void {} | |
| 2863 | \\fn g(_: var) void {} | |
| 2862 | \\fn f(_: fn (anytype) void) void {} | |
| 2863 | \\fn g(_: anytype) void {} | |
| 2864 | 2864 | \\export fn entry() void { |
| 2865 | 2865 | \\ f(g); |
| 2866 | 2866 | \\} |
| 2867 | 2867 | , &[_][]const u8{ |
| 2868 | "tmp.zig:1:9: error: parameter of type 'fn(var) var' must be declared comptime", | |
| 2868 | "tmp.zig:1:9: error: parameter of type 'fn(anytype) anytype' must be declared comptime", | |
| 2869 | 2869 | }); |
| 2870 | 2870 | |
| 2871 | 2871 | cases.add("optional pointer to void in extern struct", |
| ... | ... | @@ -3165,7 +3165,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 3165 | 3165 | |
| 3166 | 3166 | cases.add("var makes structs required to be comptime known", |
| 3167 | 3167 | \\export fn entry() void { |
| 3168 | \\ const S = struct{v: var}; | |
| 3168 | \\ const S = struct{v: anytype}; | |
| 3169 | 3169 | \\ var s = S{.v=@as(i32, 10)}; |
| 3170 | 3170 | \\} |
| 3171 | 3171 | , &[_][]const u8{ |
| ... | ... | @@ -6072,10 +6072,10 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 6072 | 6072 | }); |
| 6073 | 6073 | |
| 6074 | 6074 | cases.add("calling a generic function only known at runtime", |
| 6075 | \\var foos = [_]fn(var) void { foo1, foo2 }; | |
| 6075 | \\var foos = [_]fn(anytype) void { foo1, foo2 }; | |
| 6076 | 6076 | \\ |
| 6077 | \\fn foo1(arg: var) void {} | |
| 6078 | \\fn foo2(arg: var) void {} | |
| 6077 | \\fn foo1(arg: anytype) void {} | |
| 6078 | \\fn foo2(arg: anytype) void {} | |
| 6079 | 6079 | \\ |
| 6080 | 6080 | \\pub fn main() !void { |
| 6081 | 6081 | \\ foos[0](true); |
| ... | ... | @@ -6920,12 +6920,12 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 6920 | 6920 | }); |
| 6921 | 6921 | |
| 6922 | 6922 | cases.add("getting return type of generic function", |
| 6923 | \\fn generic(a: var) void {} | |
| 6923 | \\fn generic(a: anytype) void {} | |
| 6924 | 6924 | \\comptime { |
| 6925 | 6925 | \\ _ = @TypeOf(generic).ReturnType; |
| 6926 | 6926 | \\} |
| 6927 | 6927 | , &[_][]const u8{ |
| 6928 | "tmp.zig:3:25: error: ReturnType has not been resolved because 'fn(var) var' is generic", | |
| 6928 | "tmp.zig:3:25: error: ReturnType has not been resolved because 'fn(anytype) anytype' is generic", | |
| 6929 | 6929 | }); |
| 6930 | 6930 | |
| 6931 | 6931 | cases.add("unsupported modifier at start of asm output constraint", |
| ... | ... | @@ -7493,7 +7493,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 7493 | 7493 | }); |
| 7494 | 7494 | |
| 7495 | 7495 | cases.add("issue #5221: invalid struct init type referenced by @typeInfo and passed into function", |
| 7496 | \\fn ignore(comptime param: var) void {} | |
| 7496 | \\fn ignore(comptime param: anytype) void {} | |
| 7497 | 7497 | \\ |
| 7498 | 7498 | \\export fn foo() void { |
| 7499 | 7499 | \\ const MyStruct = struct { |
test/stage1/behavior/async_fn.zig+5-5| ... | ... | @@ -1016,7 +1016,7 @@ test "@asyncCall using the result location inside the frame" { |
| 1016 | 1016 | |
| 1017 | 1017 | test "@TypeOf an async function call of generic fn with error union type" { |
| 1018 | 1018 | const S = struct { |
| 1019 | fn func(comptime x: var) anyerror!i32 { | |
| 1019 | fn func(comptime x: anytype) anyerror!i32 { | |
| 1020 | 1020 | const T = @TypeOf(async func(x)); |
| 1021 | 1021 | comptime expect(T == @TypeOf(@frame()).Child); |
| 1022 | 1022 | return undefined; |
| ... | ... | @@ -1032,7 +1032,7 @@ test "using @TypeOf on a generic function call" { |
| 1032 | 1032 | |
| 1033 | 1033 | var buf: [100]u8 align(16) = undefined; |
| 1034 | 1034 | |
| 1035 | fn amain(x: var) void { | |
| 1035 | fn amain(x: anytype) void { | |
| 1036 | 1036 | if (x == 0) { |
| 1037 | 1037 | global_ok = true; |
| 1038 | 1038 | return; |
| ... | ... | @@ -1057,7 +1057,7 @@ test "recursive call of await @asyncCall with struct return type" { |
| 1057 | 1057 | |
| 1058 | 1058 | var buf: [100]u8 align(16) = undefined; |
| 1059 | 1059 | |
| 1060 | fn amain(x: var) Foo { | |
| 1060 | fn amain(x: anytype) Foo { | |
| 1061 | 1061 | if (x == 0) { |
| 1062 | 1062 | global_ok = true; |
| 1063 | 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 | 1336 | bar(1, .{}) catch unreachable; |
| 1337 | 1337 | } |
| 1338 | 1338 | |
| 1339 | fn bar(x: i32, args: var) anyerror!void { | |
| 1339 | fn bar(x: i32, args: anytype) anyerror!void { | |
| 1340 | 1340 | global_frame = @frame(); |
| 1341 | 1341 | suspend; |
| 1342 | 1342 | global_int = x; |
| ... | ... | @@ -1357,7 +1357,7 @@ test "async function passed align(16) arg after align(8) arg" { |
| 1357 | 1357 | bar(10, .{a}) catch unreachable; |
| 1358 | 1358 | } |
| 1359 | 1359 | |
| 1360 | fn bar(x: u64, args: var) anyerror!void { | |
| 1360 | fn bar(x: u64, args: anytype) anyerror!void { | |
| 1361 | 1361 | expect(x == 10); |
| 1362 | 1362 | global_frame = @frame(); |
| 1363 | 1363 | suspend; |
test/stage1/behavior/bitcast.zig+2-2| ... | ... | @@ -171,7 +171,7 @@ test "nested bitcast" { |
| 171 | 171 | |
| 172 | 172 | test "bitcast passed as tuple element" { |
| 173 | 173 | const S = struct { |
| 174 | fn foo(args: var) void { | |
| 174 | fn foo(args: anytype) void { | |
| 175 | 175 | comptime expect(@TypeOf(args[0]) == f32); |
| 176 | 176 | expect(args[0] == 12.34); |
| 177 | 177 | } |
| ... | ... | @@ -181,7 +181,7 @@ test "bitcast passed as tuple element" { |
| 181 | 181 | |
| 182 | 182 | test "triple level result location with bitcast sandwich passed as tuple element" { |
| 183 | 183 | const S = struct { |
| 184 | fn foo(args: var) void { | |
| 184 | fn foo(args: anytype) void { | |
| 185 | 185 | comptime expect(@TypeOf(args[0]) == f64); |
| 186 | 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 | 2 | const expect = std.testing.expect; |
| 3 | 3 | const math = std.math; |
| 4 | 4 | |
| 5 | fn ctz(x: var) usize { | |
| 5 | fn ctz(x: anytype) usize { | |
| 6 | 6 | return @ctz(@TypeOf(x), x); |
| 7 | 7 | } |
| 8 | 8 |
test/stage1/behavior/bugs/3742.zig+1-1| ... | ... | @@ -23,7 +23,7 @@ pub fn isCommand(comptime T: type) bool { |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | pub const ArgSerializer = struct { |
| 26 | pub fn serializeCommand(command: var) void { | |
| 26 | pub fn serializeCommand(command: anytype) void { | |
| 27 | 27 | const CmdT = @TypeOf(command); |
| 28 | 28 | |
| 29 | 29 | if (comptime isCommand(CmdT)) { |
test/stage1/behavior/bugs/4328.zig+4-4| ... | ... | @@ -17,11 +17,11 @@ const S = extern struct { |
| 17 | 17 | |
| 18 | 18 | test "Extern function calls in @TypeOf" { |
| 19 | 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 | 21 | return 0; |
| 22 | 22 | } |
| 23 | 23 | |
| 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 | 25 | return 1; |
| 26 | 26 | } |
| 27 | 27 | |
| ... | ... | @@ -56,7 +56,7 @@ test "Extern function calls, dereferences and field access in @TypeOf" { |
| 56 | 56 | return .{ .dummy_field = 0 }; |
| 57 | 57 | } |
| 58 | 58 | |
| 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 | 60 | return 255; |
| 61 | 61 | } |
| 62 | 62 | |
| ... | ... | @@ -68,4 +68,4 @@ test "Extern function calls, dereferences and field access in @TypeOf" { |
| 68 | 68 | |
| 69 | 69 | Test.doTheTest(); |
| 70 | 70 | comptime Test.doTheTest(); |
| 71 | } | |
| \ No newline at end of file | ||
| 71 | } |
test/stage1/behavior/bugs/4769_a.zig+1-1| ... | ... | @@ -1 +1 @@ |
| 1 | // | |
| \ No newline at end of file | ||
| 1 | // |
test/stage1/behavior/bugs/4769_b.zig+1-1| ... | ... | @@ -1 +1 @@ |
| 1 | //! | |
| \ No newline at end of file | ||
| 1 | //! |
test/stage1/behavior/byval_arg_var.zig+2-2| ... | ... | @@ -13,11 +13,11 @@ fn start() void { |
| 13 | 13 | foo("string literal"); |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | fn foo(x: var) void { | |
| 16 | fn foo(x: anytype) void { | |
| 17 | 17 | bar(x); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | fn bar(x: var) void { | |
| 20 | fn bar(x: anytype) void { | |
| 21 | 21 | result = x; |
| 22 | 22 | } |
| 23 | 23 |
test/stage1/behavior/call.zig+1-1| ... | ... | @@ -57,7 +57,7 @@ test "tuple parameters" { |
| 57 | 57 | |
| 58 | 58 | test "comptime call with bound function as parameter" { |
| 59 | 59 | const S = struct { |
| 60 | fn ReturnType(func: var) type { | |
| 60 | fn ReturnType(func: anytype) type { | |
| 61 | 61 | return switch (@typeInfo(@TypeOf(func))) { |
| 62 | 62 | .BoundFn => |info| info, |
| 63 | 63 | else => unreachable, |
test/stage1/behavior/enum.zig+1-1| ... | ... | @@ -208,7 +208,7 @@ test "@tagName non-exhaustive enum" { |
| 208 | 208 | comptime expect(mem.eql(u8, testEnumTagNameBare(NonExhaustive.B), "B")); |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | fn testEnumTagNameBare(n: var) []const u8 { | |
| 211 | fn testEnumTagNameBare(n: anytype) []const u8 { | |
| 212 | 212 | return @tagName(n); |
| 213 | 213 | } |
| 214 | 214 |
test/stage1/behavior/error.zig+1-1| ... | ... | @@ -227,7 +227,7 @@ test "error: Infer error set from literals" { |
| 227 | 227 | _ = comptime intLiteral("n") catch |err| handleErrors(err); |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | fn handleErrors(err: var) noreturn { | |
| 230 | fn handleErrors(err: anytype) noreturn { | |
| 231 | 231 | switch (err) { |
| 232 | 232 | error.T => {}, |
| 233 | 233 | } |
test/stage1/behavior/eval.zig+4-5| ... | ... | @@ -670,10 +670,10 @@ fn loopNTimes(comptime n: usize) void { |
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | test "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 | } |
| 675 | 675 | |
| 676 | fn testVarInsideInlineLoop(args: var) void { | |
| 676 | fn testVarInsideInlineLoop(args: anytype) void { | |
| 677 | 677 | comptime var i = 0; |
| 678 | 678 | inline while (i < args.len) : (i += 1) { |
| 679 | 679 | const x = args[i]; |
| ... | ... | @@ -814,17 +814,16 @@ test "two comptime calls with array default initialized to undefined" { |
| 814 | 814 | dynamic_linker: DynamicLinker = DynamicLinker{}, |
| 815 | 815 | |
| 816 | 816 | pub fn parse() void { |
| 817 | var result: CrossTarget = .{ }; | |
| 817 | var result: CrossTarget = .{}; | |
| 818 | 818 | result.getCpuArch(); |
| 819 | 819 | } |
| 820 | 820 | |
| 821 | pub fn getCpuArch(self: CrossTarget) void { } | |
| 821 | pub fn getCpuArch(self: CrossTarget) void {} | |
| 822 | 822 | }; |
| 823 | 823 | |
| 824 | 824 | const DynamicLinker = struct { |
| 825 | 825 | buffer: [255]u8 = undefined, |
| 826 | 826 | }; |
| 827 | ||
| 828 | 827 | }; |
| 829 | 828 | |
| 830 | 829 | comptime { |
test/stage1/behavior/fn.zig+3-3| ... | ... | @@ -104,7 +104,7 @@ test "number literal as an argument" { |
| 104 | 104 | comptime numberLiteralArg(3); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | fn numberLiteralArg(a: var) void { | |
| 107 | fn numberLiteralArg(a: anytype) void { | |
| 108 | 108 | expect(a == 3); |
| 109 | 109 | } |
| 110 | 110 | |
| ... | ... | @@ -132,7 +132,7 @@ test "pass by non-copying value through var arg" { |
| 132 | 132 | expect(addPointCoordsVar(Point{ .x = 1, .y = 2 }) == 3); |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | fn addPointCoordsVar(pt: var) i32 { | |
| 135 | fn addPointCoordsVar(pt: anytype) i32 { | |
| 136 | 136 | comptime expect(@TypeOf(pt) == Point); |
| 137 | 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 | 267 | expect(foo(i32) == 20); |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | fn foo(arg: var) i32 { | |
| 270 | fn foo(arg: anytype) i32 { | |
| 271 | 271 | if (@typeInfo(@TypeOf(arg)) == .Type and arg == i32) return 20; |
| 272 | 272 | return 9 + arg; |
| 273 | 273 | } |
test/stage1/behavior/generics.zig+4-4| ... | ... | @@ -47,7 +47,7 @@ comptime { |
| 47 | 47 | expect(max_f64(1.2, 3.4) == 3.4); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | fn max_var(a: var, b: var) @TypeOf(a + b) { | |
| 50 | fn max_var(a: anytype, b: anytype) @TypeOf(a + b) { | |
| 51 | 51 | return if (a > b) a else b; |
| 52 | 52 | } |
| 53 | 53 | |
| ... | ... | @@ -133,15 +133,15 @@ fn getFirstByte(comptime T: type, mem: []const T) u8 { |
| 133 | 133 | return getByte(@ptrCast(*const u8, &mem[0])); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | const foos = [_]fn (var) bool{ | |
| 136 | const foos = [_]fn (anytype) bool{ | |
| 137 | 137 | foo1, |
| 138 | 138 | foo2, |
| 139 | 139 | }; |
| 140 | 140 | |
| 141 | fn foo1(arg: var) bool { | |
| 141 | fn foo1(arg: anytype) bool { | |
| 142 | 142 | return arg; |
| 143 | 143 | } |
| 144 | fn foo2(arg: var) bool { | |
| 144 | fn foo2(arg: anytype) bool { | |
| 145 | 145 | return !arg; |
| 146 | 146 | } |
| 147 | 147 |
test/stage1/behavior/optional.zig+14-2| ... | ... | @@ -67,8 +67,20 @@ fn test_cmp_optional_non_optional() void { |
| 67 | 67 | // test evaluation is always lexical |
| 68 | 68 | // ensure that the optional isn't always computed before the non-optional |
| 69 | 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); }; | |
| 71 | _ = blk1: { mutable_state += 1; break :blk1 @as(f64, 10.0); } != blk2: { expect(mutable_state == 2); break :blk2 @as(?f64, 5.0); }; | |
| 70 | _ = blk1: { | |
| 71 | mutable_state += 1; | |
| 72 | break :blk1 @as(?f64, 10.0); | |
| 73 | } != blk2: { | |
| 74 | expect(mutable_state == 1); | |
| 75 | break :blk2 @as(f64, 5.0); | |
| 76 | }; | |
| 77 | _ = blk1: { | |
| 78 | mutable_state += 1; | |
| 79 | break :blk1 @as(f64, 10.0); | |
| 80 | } != blk2: { | |
| 81 | expect(mutable_state == 2); | |
| 82 | break :blk2 @as(?f64, 5.0); | |
| 83 | }; | |
| 72 | 84 | } |
| 73 | 85 | |
| 74 | 86 | test "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 | 713 | a: u1, |
| 714 | 714 | }; |
| 715 | 715 | |
| 716 | fn genericReadPackedField(ptr: var) u5 { | |
| 716 | fn genericReadPackedField(ptr: anytype) u5 { | |
| 717 | 717 | return ptr.*; |
| 718 | 718 | } |
| 719 | 719 | }; |
| ... | ... | @@ -754,7 +754,7 @@ test "fully anonymous struct" { |
| 754 | 754 | .s = "hi", |
| 755 | 755 | }); |
| 756 | 756 | } |
| 757 | fn dump(args: var) void { | |
| 757 | fn dump(args: anytype) void { | |
| 758 | 758 | expect(args.int == 1234); |
| 759 | 759 | expect(args.float == 12.34); |
| 760 | 760 | expect(args.b); |
| ... | ... | @@ -771,7 +771,7 @@ test "fully anonymous list literal" { |
| 771 | 771 | fn doTheTest() void { |
| 772 | 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 | 775 | expect(args.@"0" == 1234); |
| 776 | 776 | expect(args.@"1" == 12.34); |
| 777 | 777 | expect(args.@"2"); |
| ... | ... | @@ -792,8 +792,8 @@ test "anonymous struct literal assigned to variable" { |
| 792 | 792 | |
| 793 | 793 | test "struct with var field" { |
| 794 | 794 | const Point = struct { |
| 795 | x: var, | |
| 796 | y: var, | |
| 795 | x: anytype, | |
| 796 | y: anytype, | |
| 797 | 797 | }; |
| 798 | 798 | const pt = Point{ |
| 799 | 799 | .x = 1, |
test/stage1/behavior/tuple.zig+2-2| ... | ... | @@ -42,7 +42,7 @@ test "tuple multiplication" { |
| 42 | 42 | comptime S.doTheTest(); |
| 43 | 43 | |
| 44 | 44 | const T = struct { |
| 45 | fn consume_tuple(tuple: var, len: usize) void { | |
| 45 | fn consume_tuple(tuple: anytype, len: usize) void { | |
| 46 | 46 | expect(tuple.len == len); |
| 47 | 47 | } |
| 48 | 48 | |
| ... | ... | @@ -82,7 +82,7 @@ test "tuple multiplication" { |
| 82 | 82 | |
| 83 | 83 | test "pass tuple to comptime var parameter" { |
| 84 | 84 | const S = struct { |
| 85 | fn Foo(comptime args: var) void { | |
| 85 | fn Foo(comptime args: anytype) void { | |
| 86 | 86 | expect(args[0] == 1); |
| 87 | 87 | } |
| 88 | 88 |
test/stage1/behavior/type_info.zig+1-1| ... | ... | @@ -385,7 +385,7 @@ test "@typeInfo does not force declarations into existence" { |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | test "defaut value for a var-typed field" { |
| 388 | const S = struct { x: var }; | |
| 388 | const S = struct { x: anytype }; | |
| 389 | 389 | expect(@typeInfo(S).Struct.fields[0].default_value == null); |
| 390 | 390 | } |
| 391 | 391 |
test/stage1/behavior/union.zig+1-1| ... | ... | @@ -296,7 +296,7 @@ const TaggedUnionWithAVoid = union(enum) { |
| 296 | 296 | B: i32, |
| 297 | 297 | }; |
| 298 | 298 | |
| 299 | fn testTaggedUnionInit(x: var) bool { | |
| 299 | fn testTaggedUnionInit(x: anytype) bool { | |
| 300 | 300 | const y = TaggedUnionWithAVoid{ .A = x }; |
| 301 | 301 | return @as(@TagType(TaggedUnionWithAVoid), y) == TaggedUnionWithAVoid.A; |
| 302 | 302 | } |
test/stage1/behavior/var_args.zig+8-8| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | const expect = @import("std").testing.expect; |
| 2 | 2 | |
| 3 | fn add(args: var) i32 { | |
| 3 | fn add(args: anytype) i32 { | |
| 4 | 4 | var sum = @as(i32, 0); |
| 5 | 5 | { |
| 6 | 6 | comptime var i: usize = 0; |
| ... | ... | @@ -17,7 +17,7 @@ test "add arbitrary args" { |
| 17 | 17 | expect(add(.{}) == 0); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | fn readFirstVarArg(args: var) void { | |
| 20 | fn readFirstVarArg(args: anytype) void { | |
| 21 | 21 | const value = args[0]; |
| 22 | 22 | } |
| 23 | 23 | |
| ... | ... | @@ -31,7 +31,7 @@ test "pass args directly" { |
| 31 | 31 | expect(addSomeStuff(.{}) == 0); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | fn addSomeStuff(args: var) i32 { | |
| 34 | fn addSomeStuff(args: anytype) i32 { | |
| 35 | 35 | return add(args); |
| 36 | 36 | } |
| 37 | 37 | |
| ... | ... | @@ -47,7 +47,7 @@ test "runtime parameter before var args" { |
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | fn extraFn(extra: u32, args: var) usize { | |
| 50 | fn extraFn(extra: u32, args: anytype) usize { | |
| 51 | 51 | if (args.len >= 1) { |
| 52 | 52 | expect(args[0] == false); |
| 53 | 53 | } |
| ... | ... | @@ -57,15 +57,15 @@ fn extraFn(extra: u32, args: var) usize { |
| 57 | 57 | return args.len; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | const foos = [_]fn (var) bool{ | |
| 60 | const foos = [_]fn (anytype) bool{ | |
| 61 | 61 | foo1, |
| 62 | 62 | foo2, |
| 63 | 63 | }; |
| 64 | 64 | |
| 65 | fn foo1(args: var) bool { | |
| 65 | fn foo1(args: anytype) bool { | |
| 66 | 66 | return true; |
| 67 | 67 | } |
| 68 | fn foo2(args: var) bool { | |
| 68 | fn foo2(args: anytype) bool { | |
| 69 | 69 | return false; |
| 70 | 70 | } |
| 71 | 71 | |
| ... | ... | @@ -78,6 +78,6 @@ test "pass zero length array to var args param" { |
| 78 | 78 | doNothingWithFirstArg(.{""}); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | fn doNothingWithFirstArg(args: var) void { | |
| 81 | fn doNothingWithFirstArg(args: anytype) void { | |
| 82 | 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 | 171 | expect(v[1] == 2); |
| 172 | 172 | expect(loadv(&v[2]) == 3); |
| 173 | 173 | } |
| 174 | fn loadv(ptr: var) i32 { | |
| 174 | fn loadv(ptr: anytype) i32 { | |
| 175 | 175 | return ptr.*; |
| 176 | 176 | } |
| 177 | 177 | }; |
| ... | ... | @@ -194,7 +194,7 @@ test "store vector elements via comptime index" { |
| 194 | 194 | storev(&v[0], 100); |
| 195 | 195 | expect(v[0] == 100); |
| 196 | 196 | } |
| 197 | fn storev(ptr: var, x: i32) void { | |
| 197 | fn storev(ptr: anytype, x: i32) void { | |
| 198 | 198 | ptr.* = x; |
| 199 | 199 | } |
| 200 | 200 | }; |
| ... | ... | @@ -392,7 +392,7 @@ test "vector shift operators" { |
| 392 | 392 | if (builtin.os.tag == .wasi) return error.SkipZigTest; |
| 393 | 393 | |
| 394 | 394 | const S = struct { |
| 395 | fn doTheTestShift(x: var, y: var) void { | |
| 395 | fn doTheTestShift(x: anytype, y: anytype) void { | |
| 396 | 396 | const N = @typeInfo(@TypeOf(x)).Array.len; |
| 397 | 397 | const TX = @typeInfo(@TypeOf(x)).Array.child; |
| 398 | 398 | const TY = @typeInfo(@TypeOf(y)).Array.child; |
| ... | ... | @@ -409,7 +409,7 @@ test "vector shift operators" { |
| 409 | 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 | 413 | const N = @typeInfo(@TypeOf(x)).Array.len; |
| 414 | 414 | const TX = @typeInfo(@TypeOf(x)).Array.child; |
| 415 | 415 | const TY = @typeInfo(@TypeOf(y)).Array.child; |
test/translate_c.zig+10-10| ... | ... | @@ -21,7 +21,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 21 | 21 | cases.add("correct semicolon after infixop", |
| 22 | 22 | \\#define __ferror_unlocked_body(_fp) (((_fp)->_flags & _IO_ERR_SEEN) != 0) |
| 23 | 23 | , &[_][]const u8{ |
| 24 | \\pub inline fn __ferror_unlocked_body(_fp: var) @TypeOf(((_fp.*._flags) & _IO_ERR_SEEN) != 0) { | |
| 24 | \\pub inline fn __ferror_unlocked_body(_fp: anytype) @TypeOf(((_fp.*._flags) & _IO_ERR_SEEN) != 0) { | |
| 25 | 25 | \\ return ((_fp.*._flags) & _IO_ERR_SEEN) != 0; |
| 26 | 26 | \\} |
| 27 | 27 | }); |
| ... | ... | @@ -30,7 +30,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 30 | 30 | \\#define FOO(x) ((x >= 0) + (x >= 0)) |
| 31 | 31 | \\#define BAR 1 && 2 > 4 |
| 32 | 32 | , &[_][]const u8{ |
| 33 | \\pub inline fn FOO(x: var) @TypeOf(@boolToInt(x >= 0) + @boolToInt(x >= 0)) { | |
| 33 | \\pub inline fn FOO(x: anytype) @TypeOf(@boolToInt(x >= 0) + @boolToInt(x >= 0)) { | |
| 34 | 34 | \\ return @boolToInt(x >= 0) + @boolToInt(x >= 0); |
| 35 | 35 | \\} |
| 36 | 36 | , |
| ... | ... | @@ -81,7 +81,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 81 | 81 | \\ break :blk bar; |
| 82 | 82 | \\}; |
| 83 | 83 | , |
| 84 | \\pub inline fn bar(x: var) @TypeOf(baz(1, 2)) { | |
| 84 | \\pub inline fn bar(x: anytype) @TypeOf(baz(1, 2)) { | |
| 85 | 85 | \\ return blk: { |
| 86 | 86 | \\ _ = &x; |
| 87 | 87 | \\ _ = 3; |
| ... | ... | @@ -1483,11 +1483,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1483 | 1483 | , &[_][]const u8{ |
| 1484 | 1484 | \\pub extern var c: c_int; |
| 1485 | 1485 | , |
| 1486 | \\pub inline fn BASIC(c_1: var) @TypeOf(c_1 * 2) { | |
| 1486 | \\pub inline fn BASIC(c_1: anytype) @TypeOf(c_1 * 2) { | |
| 1487 | 1487 | \\ return c_1 * 2; |
| 1488 | 1488 | \\} |
| 1489 | 1489 | , |
| 1490 | \\pub inline fn FOO(L: var, b: var) @TypeOf(L + b) { | |
| 1490 | \\pub inline fn FOO(L: anytype, b: anytype) @TypeOf(L + b) { | |
| 1491 | 1491 | \\ return L + b; |
| 1492 | 1492 | \\} |
| 1493 | 1493 | }); |
| ... | ... | @@ -2123,7 +2123,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2123 | 2123 | cases.add("macro call", |
| 2124 | 2124 | \\#define CALL(arg) bar(arg) |
| 2125 | 2125 | , &[_][]const u8{ |
| 2126 | \\pub inline fn CALL(arg: var) @TypeOf(bar(arg)) { | |
| 2126 | \\pub inline fn CALL(arg: anytype) @TypeOf(bar(arg)) { | |
| 2127 | 2127 | \\ return bar(arg); |
| 2128 | 2128 | \\} |
| 2129 | 2129 | }); |
| ... | ... | @@ -2683,7 +2683,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2683 | 2683 | \\#define FOO(bar) baz((void *)(baz)) |
| 2684 | 2684 | \\#define BAR (void*) a |
| 2685 | 2685 | , &[_][]const u8{ |
| 2686 | \\pub inline fn FOO(bar: var) @TypeOf(baz((@import("std").meta.cast(?*c_void, baz)))) { | |
| 2686 | \\pub inline fn FOO(bar: anytype) @TypeOf(baz((@import("std").meta.cast(?*c_void, baz)))) { | |
| 2687 | 2687 | \\ return baz((@import("std").meta.cast(?*c_void, baz))); |
| 2688 | 2688 | \\} |
| 2689 | 2689 | , |
| ... | ... | @@ -2713,11 +2713,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2713 | 2713 | \\#define MIN(a, b) ((b) < (a) ? (b) : (a)) |
| 2714 | 2714 | \\#define MAX(a, b) ((b) > (a) ? (b) : (a)) |
| 2715 | 2715 | , &[_][]const u8{ |
| 2716 | \\pub inline fn MIN(a: var, b: var) @TypeOf(if (b < a) b else a) { | |
| 2716 | \\pub inline fn MIN(a: anytype, b: anytype) @TypeOf(if (b < a) b else a) { | |
| 2717 | 2717 | \\ return if (b < a) b else a; |
| 2718 | 2718 | \\} |
| 2719 | 2719 | , |
| 2720 | \\pub inline fn MAX(a: var, b: var) @TypeOf(if (b > a) b else a) { | |
| 2720 | \\pub inline fn MAX(a: anytype, b: anytype) @TypeOf(if (b > a) b else a) { | |
| 2721 | 2721 | \\ return if (b > a) b else a; |
| 2722 | 2722 | \\} |
| 2723 | 2723 | }); |
| ... | ... | @@ -2905,7 +2905,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2905 | 2905 | \\#define DefaultScreen(dpy) (((_XPrivDisplay)(dpy))->default_screen) |
| 2906 | 2906 | \\ |
| 2907 | 2907 | , &[_][]const u8{ |
| 2908 | \\pub inline fn DefaultScreen(dpy: var) @TypeOf((@import("std").meta.cast(_XPrivDisplay, dpy)).*.default_screen) { | |
| 2908 | \\pub inline fn DefaultScreen(dpy: anytype) @TypeOf((@import("std").meta.cast(_XPrivDisplay, dpy)).*.default_screen) { | |
| 2909 | 2909 | \\ return (@import("std").meta.cast(_XPrivDisplay, dpy)).*.default_screen; |
| 2910 | 2910 | \\} |
| 2911 | 2911 | }); |