authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-12-09 10:51:47-05:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2019-12-09 10:51:47-05:00
log640e09183d3100c477a26c6cdc26f1eae31472a1
tree0bddf7eb99d6daaaa2e5ee80b51a6766aefb7d9c
parent5874cb04bd544ca155d1489bb0bdf9397fa3b41c
parent8b3c0bbeeef080b77d0cb7999682abc52de437e3
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #3873 from ziglang/format-no-var-args

std.fmt.format: tuple parameter instead of var args

63 files changed, 1052 insertions(+), 1234 deletions(-)

build.zig+5-5
......@@ -154,7 +154,7 @@ fn dependOnLib(b: *Builder, lib_exe_obj: var, dep: LibraryDep) void {
154154 const static_bare_name = if (mem.eql(u8, lib, "curses"))
155155 @as([]const u8, "libncurses.a")
156156 else
157 b.fmt("lib{}.a", lib);
157 b.fmt("lib{}.a", .{lib});
158158 const static_lib_name = fs.path.join(
159159 b.allocator,
160160 &[_][]const u8{ lib_dir, static_bare_name },
......@@ -186,7 +186,7 @@ fn addCppLib(b: *Builder, lib_exe_obj: var, cmake_binary_dir: []const u8, lib_na
186186 lib_exe_obj.addObjectFile(fs.path.join(b.allocator, &[_][]const u8{
187187 cmake_binary_dir,
188188 "zig_cpp",
189 b.fmt("{}{}{}", lib_exe_obj.target.libPrefix(), lib_name, lib_exe_obj.target.staticLibSuffix()),
189 b.fmt("{}{}{}", .{ lib_exe_obj.target.libPrefix(), lib_name, lib_exe_obj.target.staticLibSuffix() }),
190190 }) catch unreachable);
191191}
192192
......@@ -343,14 +343,14 @@ fn addCxxKnownPath(
343343) !void {
344344 const path_padded = try b.exec(&[_][]const u8{
345345 ctx.cxx_compiler,
346 b.fmt("-print-file-name={}", objname),
346 b.fmt("-print-file-name={}", .{objname}),
347347 });
348348 const path_unpadded = mem.tokenize(path_padded, "\r\n").next().?;
349349 if (mem.eql(u8, path_unpadded, objname)) {
350350 if (errtxt) |msg| {
351 warn("{}", msg);
351 warn("{}", .{msg});
352352 } else {
353 warn("Unable to determine path to {}\n", objname);
353 warn("Unable to determine path to {}\n", .{objname});
354354 }
355355 return error.RequiredLibraryNotFound;
356356 }
doc/docgen.zig+146-135
......@@ -215,32 +215,33 @@ const Tokenizer = struct {
215215 }
216216};
217217
218fn parseError(tokenizer: *Tokenizer, token: Token, comptime fmt: []const u8, args: ...) anyerror {
218fn parseError(tokenizer: *Tokenizer, token: Token, comptime fmt: []const u8, args: var) anyerror {
219219 const loc = tokenizer.getTokenLocation(token);
220 warn("{}:{}:{}: error: " ++ fmt ++ "\n", tokenizer.source_file_name, loc.line + 1, loc.column + 1, args);
220 const args_prefix = .{ tokenizer.source_file_name, loc.line + 1, loc.column + 1 };
221 warn("{}:{}:{}: error: " ++ fmt ++ "\n", args_prefix ++ args);
221222 if (loc.line_start <= loc.line_end) {
222 warn("{}\n", tokenizer.buffer[loc.line_start..loc.line_end]);
223 warn("{}\n", .{tokenizer.buffer[loc.line_start..loc.line_end]});
223224 {
224225 var i: usize = 0;
225226 while (i < loc.column) : (i += 1) {
226 warn(" ");
227 warn(" ", .{});
227228 }
228229 }
229230 {
230231 const caret_count = token.end - token.start;
231232 var i: usize = 0;
232233 while (i < caret_count) : (i += 1) {
233 warn("~");
234 warn("~", .{});
234235 }
235236 }
236 warn("\n");
237 warn("\n", .{});
237238 }
238239 return error.ParseError;
239240}
240241
241242fn assertToken(tokenizer: *Tokenizer, token: Token, id: Token.Id) !void {
242243 if (token.id != id) {
243 return parseError(tokenizer, token, "expected {}, found {}", @tagName(id), @tagName(token.id));
244 return parseError(tokenizer, token, "expected {}, found {}", .{ @tagName(id), @tagName(token.id) });
244245 }
245246}
246247
......@@ -339,7 +340,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
339340 switch (token.id) {
340341 Token.Id.Eof => {
341342 if (header_stack_size != 0) {
342 return parseError(tokenizer, token, "unbalanced headers");
343 return parseError(tokenizer, token, "unbalanced headers", .{});
343344 }
344345 try toc.write(" </ul>\n");
345346 break;
......@@ -373,10 +374,15 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
373374 if (mem.eql(u8, param, "3col")) {
374375 columns = 3;
375376 } else {
376 return parseError(tokenizer, bracket_tok, "unrecognized header_open param: {}", param);
377 return parseError(
378 tokenizer,
379 bracket_tok,
380 "unrecognized header_open param: {}",
381 .{param},
382 );
377383 }
378384 },
379 else => return parseError(tokenizer, bracket_tok, "invalid header_open token"),
385 else => return parseError(tokenizer, bracket_tok, "invalid header_open token", .{}),
380386 }
381387 }
382388
......@@ -391,15 +397,15 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
391397 },
392398 });
393399 if (try urls.put(urlized, tag_token)) |entry| {
394 parseError(tokenizer, tag_token, "duplicate header url: #{}", urlized) catch {};
395 parseError(tokenizer, entry.value, "other tag here") catch {};
400 parseError(tokenizer, tag_token, "duplicate header url: #{}", .{urlized}) catch {};
401 parseError(tokenizer, entry.value, "other tag here", .{}) catch {};
396402 return error.ParseError;
397403 }
398404 if (last_action == Action.Open) {
399405 try toc.writeByte('\n');
400406 try toc.writeByteNTimes(' ', header_stack_size * 4);
401407 if (last_columns) |n| {
402 try toc.print("<ul style=\"columns: {}\">\n", n);
408 try toc.print("<ul style=\"columns: {}\">\n", .{n});
403409 } else {
404410 try toc.write("<ul>\n");
405411 }
......@@ -408,10 +414,10 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
408414 }
409415 last_columns = columns;
410416 try toc.writeByteNTimes(' ', 4 + header_stack_size * 4);
411 try toc.print("<li><a id=\"toc-{}\" href=\"#{}\">{}</a>", urlized, urlized, content);
417 try toc.print("<li><a id=\"toc-{}\" href=\"#{}\">{}</a>", .{ urlized, urlized, content });
412418 } else if (mem.eql(u8, tag_name, "header_close")) {
413419 if (header_stack_size == 0) {
414 return parseError(tokenizer, tag_token, "unbalanced close header");
420 return parseError(tokenizer, tag_token, "unbalanced close header", .{});
415421 }
416422 header_stack_size -= 1;
417423 _ = try eatToken(tokenizer, Token.Id.BracketClose);
......@@ -442,7 +448,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
442448 try nodes.append(Node{ .SeeAlso = list.toOwnedSlice() });
443449 break;
444450 },
445 else => return parseError(tokenizer, see_also_tok, "invalid see_also token"),
451 else => return parseError(tokenizer, see_also_tok, "invalid see_also token", .{}),
446452 }
447453 }
448454 } else if (mem.eql(u8, tag_name, "link")) {
......@@ -459,7 +465,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
459465 _ = try eatToken(tokenizer, Token.Id.BracketClose);
460466 break :blk tokenizer.buffer[explicit_text.start..explicit_text.end];
461467 },
462 else => return parseError(tokenizer, tok, "invalid link token"),
468 else => return parseError(tokenizer, tok, "invalid link token", .{}),
463469 }
464470 };
465471
......@@ -482,7 +488,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
482488 _ = try eatToken(tokenizer, Token.Id.BracketClose);
483489 },
484490 Token.Id.BracketClose => {},
485 else => return parseError(tokenizer, token, "invalid token"),
491 else => return parseError(tokenizer, token, "invalid token", .{}),
486492 }
487493 const code_kind_str = tokenizer.buffer[code_kind_tok.start..code_kind_tok.end];
488494 var code_kind_id: Code.Id = undefined;
......@@ -512,7 +518,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
512518 code_kind_id = Code.Id{ .Obj = null };
513519 is_inline = true;
514520 } else {
515 return parseError(tokenizer, code_kind_tok, "unrecognized code kind: {}", code_kind_str);
521 return parseError(tokenizer, code_kind_tok, "unrecognized code kind: {}", .{code_kind_str});
516522 }
517523
518524 var mode = builtin.Mode.Debug;
......@@ -550,7 +556,12 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
550556 _ = try eatToken(tokenizer, Token.Id.BracketClose);
551557 break content_tok;
552558 } else {
553 return parseError(tokenizer, end_code_tag, "invalid token inside code_begin: {}", end_tag_name);
559 return parseError(
560 tokenizer,
561 end_code_tag,
562 "invalid token inside code_begin: {}",
563 .{end_tag_name},
564 );
554565 }
555566 _ = try eatToken(tokenizer, Token.Id.BracketClose);
556567 } else
......@@ -575,15 +586,20 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc {
575586 const end_syntax_tag = try eatToken(tokenizer, Token.Id.TagContent);
576587 const end_tag_name = tokenizer.buffer[end_syntax_tag.start..end_syntax_tag.end];
577588 if (!mem.eql(u8, end_tag_name, "endsyntax")) {
578 return parseError(tokenizer, end_syntax_tag, "invalid token inside syntax: {}", end_tag_name);
589 return parseError(
590 tokenizer,
591 end_syntax_tag,
592 "invalid token inside syntax: {}",
593 .{end_tag_name},
594 );
579595 }
580596 _ = try eatToken(tokenizer, Token.Id.BracketClose);
581597 try nodes.append(Node{ .Syntax = content_tok });
582598 } else {
583 return parseError(tokenizer, tag_token, "unrecognized tag name: {}", tag_name);
599 return parseError(tokenizer, tag_token, "unrecognized tag name: {}", .{tag_name});
584600 }
585601 },
586 else => return parseError(tokenizer, token, "invalid token"),
602 else => return parseError(tokenizer, token, "invalid token", .{}),
587603 }
588604 }
589605
......@@ -729,7 +745,7 @@ fn termColor(allocator: *mem.Allocator, input: []const u8) ![]u8 {
729745 try out.write("</span>");
730746 }
731747 if (first_number != 0 or second_number != 0) {
732 try out.print("<span class=\"t{}_{}\">", first_number, second_number);
748 try out.print("<span class=\"t{}_{}\">", .{ first_number, second_number });
733749 open_span_count += 1;
734750 }
735751 },
......@@ -960,6 +976,7 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok
960976 docgen_tokenizer,
961977 source_token,
962978 "syntax error",
979 .{},
963980 ),
964981 }
965982 index = token.end;
......@@ -987,9 +1004,9 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
9871004 },
9881005 Node.Link => |info| {
9891006 if (!toc.urls.contains(info.url)) {
990 return parseError(tokenizer, info.token, "url not found: {}", info.url);
1007 return parseError(tokenizer, info.token, "url not found: {}", .{info.url});
9911008 }
992 try out.print("<a href=\"#{}\">{}</a>", info.url, info.name);
1009 try out.print("<a href=\"#{}\">{}</a>", .{ info.url, info.name });
9931010 },
9941011 Node.Nav => {
9951012 try out.write(toc.toc);
......@@ -1002,12 +1019,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
10021019 Node.HeaderOpen => |info| {
10031020 try out.print(
10041021 "<h{} id=\"{}\"><a href=\"#toc-{}\">{}</a> <a class=\"hdr\" href=\"#{}\">§</a></h{}>\n",
1005 info.n,
1006 info.url,
1007 info.url,
1008 info.name,
1009 info.url,
1010 info.n,
1022 .{ info.n, info.url, info.url, info.name, info.url, info.n },
10111023 );
10121024 },
10131025 Node.SeeAlso => |items| {
......@@ -1015,9 +1027,9 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
10151027 for (items) |item| {
10161028 const url = try urlize(allocator, item.name);
10171029 if (!toc.urls.contains(url)) {
1018 return parseError(tokenizer, item.token, "url not found: {}", url);
1030 return parseError(tokenizer, item.token, "url not found: {}", .{url});
10191031 }
1020 try out.print("<li><a href=\"#{}\">{}</a></li>\n", url, item.name);
1032 try out.print("<li><a href=\"#{}\">{}</a></li>\n", .{ url, item.name });
10211033 }
10221034 try out.write("</ul>\n");
10231035 },
......@@ -1026,17 +1038,17 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
10261038 },
10271039 Node.Code => |code| {
10281040 code_progress_index += 1;
1029 warn("docgen example code {}/{}...", code_progress_index, tokenizer.code_node_count);
1041 warn("docgen example code {}/{}...", .{ code_progress_index, tokenizer.code_node_count });
10301042
10311043 const raw_source = tokenizer.buffer[code.source_token.start..code.source_token.end];
10321044 const trimmed_raw_source = mem.trim(u8, raw_source, " \n");
10331045 if (!code.is_inline) {
1034 try out.print("<p class=\"file\">{}.zig</p>", code.name);
1046 try out.print("<p class=\"file\">{}.zig</p>", .{code.name});
10351047 }
10361048 try out.write("<pre>");
10371049 try tokenizeAndPrint(tokenizer, out, code.source_token);
10381050 try out.write("</pre>");
1039 const name_plus_ext = try std.fmt.allocPrint(allocator, "{}.zig", code.name);
1051 const name_plus_ext = try std.fmt.allocPrint(allocator, "{}.zig", .{code.name});
10401052 const tmp_source_file_name = try fs.path.join(
10411053 allocator,
10421054 &[_][]const u8{ tmp_dir_name, name_plus_ext },
......@@ -1045,7 +1057,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
10451057
10461058 switch (code.id) {
10471059 Code.Id.Exe => |expected_outcome| code_block: {
1048 const name_plus_bin_ext = try std.fmt.allocPrint(allocator, "{}{}", code.name, exe_ext);
1060 const name_plus_bin_ext = try std.fmt.allocPrint(allocator, "{}{}", .{ code.name, exe_ext });
10491061 var build_args = std.ArrayList([]const u8).init(allocator);
10501062 defer build_args.deinit();
10511063 try build_args.appendSlice(&[_][]const u8{
......@@ -1059,40 +1071,40 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
10591071 "--cache",
10601072 "on",
10611073 });
1062 try out.print("<pre><code class=\"shell\">$ zig build-exe {}.zig", code.name);
1074 try out.print("<pre><code class=\"shell\">$ zig build-exe {}.zig", .{code.name});
10631075 switch (code.mode) {
10641076 builtin.Mode.Debug => {},
10651077 builtin.Mode.ReleaseSafe => {
10661078 try build_args.append("--release-safe");
1067 try out.print(" --release-safe");
1079 try out.print(" --release-safe", .{});
10681080 },
10691081 builtin.Mode.ReleaseFast => {
10701082 try build_args.append("--release-fast");
1071 try out.print(" --release-fast");
1083 try out.print(" --release-fast", .{});
10721084 },
10731085 builtin.Mode.ReleaseSmall => {
10741086 try build_args.append("--release-small");
1075 try out.print(" --release-small");
1087 try out.print(" --release-small", .{});
10761088 },
10771089 }
10781090 for (code.link_objects) |link_object| {
1079 const name_with_ext = try std.fmt.allocPrint(allocator, "{}{}", link_object, obj_ext);
1091 const name_with_ext = try std.fmt.allocPrint(allocator, "{}{}", .{ link_object, obj_ext });
10801092 const full_path_object = try fs.path.join(
10811093 allocator,
10821094 &[_][]const u8{ tmp_dir_name, name_with_ext },
10831095 );
10841096 try build_args.append("--object");
10851097 try build_args.append(full_path_object);
1086 try out.print(" --object {}", name_with_ext);
1098 try out.print(" --object {}", .{name_with_ext});
10871099 }
10881100 if (code.link_libc) {
10891101 try build_args.append("-lc");
1090 try out.print(" -lc");
1102 try out.print(" -lc", .{});
10911103 }
10921104 if (code.target_str) |triple| {
10931105 try build_args.appendSlice(&[_][]const u8{ "-target", triple });
10941106 if (!code.is_inline) {
1095 try out.print(" -target {}", triple);
1107 try out.print(" -target {}", .{triple});
10961108 }
10971109 }
10981110 if (expected_outcome == .BuildFail) {
......@@ -1106,29 +1118,29 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
11061118 switch (result.term) {
11071119 .Exited => |exit_code| {
11081120 if (exit_code == 0) {
1109 warn("{}\nThe following command incorrectly succeeded:\n", result.stderr);
1121 warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr});
11101122 for (build_args.toSliceConst()) |arg|
1111 warn("{} ", arg)
1123 warn("{} ", .{arg})
11121124 else
1113 warn("\n");
1114 return parseError(tokenizer, code.source_token, "example incorrectly compiled");
1125 warn("\n", .{});
1126 return parseError(tokenizer, code.source_token, "example incorrectly compiled", .{});
11151127 }
11161128 },
11171129 else => {
1118 warn("{}\nThe following command crashed:\n", result.stderr);
1130 warn("{}\nThe following command crashed:\n", .{result.stderr});
11191131 for (build_args.toSliceConst()) |arg|
1120 warn("{} ", arg)
1132 warn("{} ", .{arg})
11211133 else
1122 warn("\n");
1123 return parseError(tokenizer, code.source_token, "example compile crashed");
1134 warn("\n", .{});
1135 return parseError(tokenizer, code.source_token, "example compile crashed", .{});
11241136 },
11251137 }
11261138 const escaped_stderr = try escapeHtml(allocator, result.stderr);
11271139 const colored_stderr = try termColor(allocator, escaped_stderr);
1128 try out.print("\n{}</code></pre>\n", colored_stderr);
1140 try out.print("\n{}</code></pre>\n", .{colored_stderr});
11291141 break :code_block;
11301142 }
1131 const exec_result = exec(allocator, &env_map, build_args.toSliceConst()) catch return parseError(tokenizer, code.source_token, "example failed to compile");
1143 const exec_result = exec(allocator, &env_map, build_args.toSliceConst()) catch return parseError(tokenizer, code.source_token, "example failed to compile", .{});
11321144
11331145 if (code.target_str) |triple| {
11341146 if (mem.startsWith(u8, triple, "wasm32") or
......@@ -1137,7 +1149,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
11371149 (builtin.os != .linux or builtin.arch != .x86_64))
11381150 {
11391151 // skip execution
1140 try out.print("</code></pre>\n");
1152 try out.print("</code></pre>\n", .{});
11411153 break :code_block;
11421154 }
11431155 }
......@@ -1152,12 +1164,12 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
11521164 switch (result.term) {
11531165 .Exited => |exit_code| {
11541166 if (exit_code == 0) {
1155 warn("{}\nThe following command incorrectly succeeded:\n", result.stderr);
1167 warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr});
11561168 for (run_args) |arg|
1157 warn("{} ", arg)
1169 warn("{} ", .{arg})
11581170 else
1159 warn("\n");
1160 return parseError(tokenizer, code.source_token, "example incorrectly compiled");
1171 warn("\n", .{});
1172 return parseError(tokenizer, code.source_token, "example incorrectly compiled", .{});
11611173 }
11621174 },
11631175 .Signal => exited_with_signal = true,
......@@ -1165,7 +1177,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
11651177 }
11661178 break :blk result;
11671179 } else blk: {
1168 break :blk exec(allocator, &env_map, run_args) catch return parseError(tokenizer, code.source_token, "example crashed");
1180 break :blk exec(allocator, &env_map, run_args) catch return parseError(tokenizer, code.source_token, "example crashed", .{});
11691181 };
11701182
11711183 const escaped_stderr = try escapeHtml(allocator, result.stderr);
......@@ -1174,11 +1186,11 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
11741186 const colored_stderr = try termColor(allocator, escaped_stderr);
11751187 const colored_stdout = try termColor(allocator, escaped_stdout);
11761188
1177 try out.print("\n$ ./{}\n{}{}", code.name, colored_stdout, colored_stderr);
1189 try out.print("\n$ ./{}\n{}{}", .{ code.name, colored_stdout, colored_stderr });
11781190 if (exited_with_signal) {
1179 try out.print("(process terminated by signal)");
1191 try out.print("(process terminated by signal)", .{});
11801192 }
1181 try out.print("</code></pre>\n");
1193 try out.print("</code></pre>\n", .{});
11821194 },
11831195 Code.Id.Test => {
11841196 var test_args = std.ArrayList([]const u8).init(allocator);
......@@ -1191,34 +1203,34 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
11911203 "--cache",
11921204 "on",
11931205 });
1194 try out.print("<pre><code class=\"shell\">$ zig test {}.zig", code.name);
1206 try out.print("<pre><code class=\"shell\">$ zig test {}.zig", .{code.name});
11951207 switch (code.mode) {
11961208 builtin.Mode.Debug => {},
11971209 builtin.Mode.ReleaseSafe => {
11981210 try test_args.append("--release-safe");
1199 try out.print(" --release-safe");
1211 try out.print(" --release-safe", .{});
12001212 },
12011213 builtin.Mode.ReleaseFast => {
12021214 try test_args.append("--release-fast");
1203 try out.print(" --release-fast");
1215 try out.print(" --release-fast", .{});
12041216 },
12051217 builtin.Mode.ReleaseSmall => {
12061218 try test_args.append("--release-small");
1207 try out.print(" --release-small");
1219 try out.print(" --release-small", .{});
12081220 },
12091221 }
12101222 if (code.link_libc) {
12111223 try test_args.append("-lc");
1212 try out.print(" -lc");
1224 try out.print(" -lc", .{});
12131225 }
12141226 if (code.target_str) |triple| {
12151227 try test_args.appendSlice(&[_][]const u8{ "-target", triple });
1216 try out.print(" -target {}", triple);
1228 try out.print(" -target {}", .{triple});
12171229 }
1218 const result = exec(allocator, &env_map, test_args.toSliceConst()) catch return parseError(tokenizer, code.source_token, "test failed");
1230 const result = exec(allocator, &env_map, test_args.toSliceConst()) catch return parseError(tokenizer, code.source_token, "test failed", .{});
12191231 const escaped_stderr = try escapeHtml(allocator, result.stderr);
12201232 const escaped_stdout = try escapeHtml(allocator, result.stdout);
1221 try out.print("\n{}{}</code></pre>\n", escaped_stderr, escaped_stdout);
1233 try out.print("\n{}{}</code></pre>\n", .{ escaped_stderr, escaped_stdout });
12221234 },
12231235 Code.Id.TestError => |error_match| {
12241236 var test_args = std.ArrayList([]const u8).init(allocator);
......@@ -1233,50 +1245,50 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
12331245 "--output-dir",
12341246 tmp_dir_name,
12351247 });
1236 try out.print("<pre><code class=\"shell\">$ zig test {}.zig", code.name);
1248 try out.print("<pre><code class=\"shell\">$ zig test {}.zig", .{code.name});
12371249 switch (code.mode) {
12381250 builtin.Mode.Debug => {},
12391251 builtin.Mode.ReleaseSafe => {
12401252 try test_args.append("--release-safe");
1241 try out.print(" --release-safe");
1253 try out.print(" --release-safe", .{});
12421254 },
12431255 builtin.Mode.ReleaseFast => {
12441256 try test_args.append("--release-fast");
1245 try out.print(" --release-fast");
1257 try out.print(" --release-fast", .{});
12461258 },
12471259 builtin.Mode.ReleaseSmall => {
12481260 try test_args.append("--release-small");
1249 try out.print(" --release-small");
1261 try out.print(" --release-small", .{});
12501262 },
12511263 }
12521264 const result = try ChildProcess.exec(allocator, test_args.toSliceConst(), null, &env_map, max_doc_file_size);
12531265 switch (result.term) {
12541266 .Exited => |exit_code| {
12551267 if (exit_code == 0) {
1256 warn("{}\nThe following command incorrectly succeeded:\n", result.stderr);
1268 warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr});
12571269 for (test_args.toSliceConst()) |arg|
1258 warn("{} ", arg)
1270 warn("{} ", .{arg})
12591271 else
1260 warn("\n");
1261 return parseError(tokenizer, code.source_token, "example incorrectly compiled");
1272 warn("\n", .{});
1273 return parseError(tokenizer, code.source_token, "example incorrectly compiled", .{});
12621274 }
12631275 },
12641276 else => {
1265 warn("{}\nThe following command crashed:\n", result.stderr);
1277 warn("{}\nThe following command crashed:\n", .{result.stderr});
12661278 for (test_args.toSliceConst()) |arg|
1267 warn("{} ", arg)
1279 warn("{} ", .{arg})
12681280 else
1269 warn("\n");
1270 return parseError(tokenizer, code.source_token, "example compile crashed");
1281 warn("\n", .{});
1282 return parseError(tokenizer, code.source_token, "example compile crashed", .{});
12711283 },
12721284 }
12731285 if (mem.indexOf(u8, result.stderr, error_match) == null) {
1274 warn("{}\nExpected to find '{}' in stderr", result.stderr, error_match);
1275 return parseError(tokenizer, code.source_token, "example did not have expected compile error");
1286 warn("{}\nExpected to find '{}' in stderr", .{ result.stderr, error_match });
1287 return parseError(tokenizer, code.source_token, "example did not have expected compile error", .{});
12761288 }
12771289 const escaped_stderr = try escapeHtml(allocator, result.stderr);
12781290 const colored_stderr = try termColor(allocator, escaped_stderr);
1279 try out.print("\n{}</code></pre>\n", colored_stderr);
1291 try out.print("\n{}</code></pre>\n", .{colored_stderr});
12801292 },
12811293
12821294 Code.Id.TestSafety => |error_match| {
......@@ -1311,38 +1323,37 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
13111323 switch (result.term) {
13121324 .Exited => |exit_code| {
13131325 if (exit_code == 0) {
1314 warn("{}\nThe following command incorrectly succeeded:\n", result.stderr);
1326 warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr});
13151327 for (test_args.toSliceConst()) |arg|
1316 warn("{} ", arg)
1328 warn("{} ", .{arg})
13171329 else
1318 warn("\n");
1319 return parseError(tokenizer, code.source_token, "example test incorrectly succeeded");
1330 warn("\n", .{});
1331 return parseError(tokenizer, code.source_token, "example test incorrectly succeeded", .{});
13201332 }
13211333 },
13221334 else => {
1323 warn("{}\nThe following command crashed:\n", result.stderr);
1335 warn("{}\nThe following command crashed:\n", .{result.stderr});
13241336 for (test_args.toSliceConst()) |arg|
1325 warn("{} ", arg)
1337 warn("{} ", .{arg})
13261338 else
1327 warn("\n");
1328 return parseError(tokenizer, code.source_token, "example compile crashed");
1339 warn("\n", .{});
1340 return parseError(tokenizer, code.source_token, "example compile crashed", .{});
13291341 },
13301342 }
13311343 if (mem.indexOf(u8, result.stderr, error_match) == null) {
1332 warn("{}\nExpected to find '{}' in stderr", result.stderr, error_match);
1333 return parseError(tokenizer, code.source_token, "example did not have expected runtime safety error message");
1344 warn("{}\nExpected to find '{}' in stderr", .{ result.stderr, error_match });
1345 return parseError(tokenizer, code.source_token, "example did not have expected runtime safety error message", .{});
13341346 }
13351347 const escaped_stderr = try escapeHtml(allocator, result.stderr);
13361348 const colored_stderr = try termColor(allocator, escaped_stderr);
1337 try out.print(
1338 "<pre><code class=\"shell\">$ zig test {}.zig{}\n{}</code></pre>\n",
1349 try out.print("<pre><code class=\"shell\">$ zig test {}.zig{}\n{}</code></pre>\n", .{
13391350 code.name,
13401351 mode_arg,
13411352 colored_stderr,
1342 );
1353 });
13431354 },
13441355 Code.Id.Obj => |maybe_error_match| {
1345 const name_plus_obj_ext = try std.fmt.allocPrint(allocator, "{}{}", code.name, obj_ext);
1356 const name_plus_obj_ext = try std.fmt.allocPrint(allocator, "{}{}", .{ code.name, obj_ext });
13461357 const tmp_obj_file_name = try fs.path.join(
13471358 allocator,
13481359 &[_][]const u8{ tmp_dir_name, name_plus_obj_ext },
......@@ -1350,7 +1361,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
13501361 var build_args = std.ArrayList([]const u8).init(allocator);
13511362 defer build_args.deinit();
13521363
1353 const name_plus_h_ext = try std.fmt.allocPrint(allocator, "{}.h", code.name);
1364 const name_plus_h_ext = try std.fmt.allocPrint(allocator, "{}.h", .{code.name});
13541365 const output_h_file_name = try fs.path.join(
13551366 allocator,
13561367 &[_][]const u8{ tmp_dir_name, name_plus_h_ext },
......@@ -1369,7 +1380,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
13691380 });
13701381
13711382 if (!code.is_inline) {
1372 try out.print("<pre><code class=\"shell\">$ zig build-obj {}.zig", code.name);
1383 try out.print("<pre><code class=\"shell\">$ zig build-obj {}.zig", .{code.name});
13731384 }
13741385
13751386 switch (code.mode) {
......@@ -1377,26 +1388,26 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
13771388 builtin.Mode.ReleaseSafe => {
13781389 try build_args.append("--release-safe");
13791390 if (!code.is_inline) {
1380 try out.print(" --release-safe");
1391 try out.print(" --release-safe", .{});
13811392 }
13821393 },
13831394 builtin.Mode.ReleaseFast => {
13841395 try build_args.append("--release-fast");
13851396 if (!code.is_inline) {
1386 try out.print(" --release-fast");
1397 try out.print(" --release-fast", .{});
13871398 }
13881399 },
13891400 builtin.Mode.ReleaseSmall => {
13901401 try build_args.append("--release-small");
13911402 if (!code.is_inline) {
1392 try out.print(" --release-small");
1403 try out.print(" --release-small", .{});
13931404 }
13941405 },
13951406 }
13961407
13971408 if (code.target_str) |triple| {
13981409 try build_args.appendSlice(&[_][]const u8{ "-target", triple });
1399 try out.print(" -target {}", triple);
1410 try out.print(" -target {}", .{triple});
14001411 }
14011412
14021413 if (maybe_error_match) |error_match| {
......@@ -1404,35 +1415,35 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
14041415 switch (result.term) {
14051416 .Exited => |exit_code| {
14061417 if (exit_code == 0) {
1407 warn("{}\nThe following command incorrectly succeeded:\n", result.stderr);
1418 warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr});
14081419 for (build_args.toSliceConst()) |arg|
1409 warn("{} ", arg)
1420 warn("{} ", .{arg})
14101421 else
1411 warn("\n");
1412 return parseError(tokenizer, code.source_token, "example build incorrectly succeeded");
1422 warn("\n", .{});
1423 return parseError(tokenizer, code.source_token, "example build incorrectly succeeded", .{});
14131424 }
14141425 },
14151426 else => {
1416 warn("{}\nThe following command crashed:\n", result.stderr);
1427 warn("{}\nThe following command crashed:\n", .{result.stderr});
14171428 for (build_args.toSliceConst()) |arg|
1418 warn("{} ", arg)
1429 warn("{} ", .{arg})
14191430 else
1420 warn("\n");
1421 return parseError(tokenizer, code.source_token, "example compile crashed");
1431 warn("\n", .{});
1432 return parseError(tokenizer, code.source_token, "example compile crashed", .{});
14221433 },
14231434 }
14241435 if (mem.indexOf(u8, result.stderr, error_match) == null) {
1425 warn("{}\nExpected to find '{}' in stderr", result.stderr, error_match);
1426 return parseError(tokenizer, code.source_token, "example did not have expected compile error message");
1436 warn("{}\nExpected to find '{}' in stderr", .{ result.stderr, error_match });
1437 return parseError(tokenizer, code.source_token, "example did not have expected compile error message", .{});
14271438 }
14281439 const escaped_stderr = try escapeHtml(allocator, result.stderr);
14291440 const colored_stderr = try termColor(allocator, escaped_stderr);
1430 try out.print("\n{}", colored_stderr);
1441 try out.print("\n{}", .{colored_stderr});
14311442 } else {
1432 _ = exec(allocator, &env_map, build_args.toSliceConst()) catch return parseError(tokenizer, code.source_token, "example failed to compile");
1443 _ = exec(allocator, &env_map, build_args.toSliceConst()) catch return parseError(tokenizer, code.source_token, "example failed to compile", .{});
14331444 }
14341445 if (!code.is_inline) {
1435 try out.print("</code></pre>\n");
1446 try out.print("</code></pre>\n", .{});
14361447 }
14371448 },
14381449 Code.Id.Lib => {
......@@ -1446,33 +1457,33 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var
14461457 "--output-dir",
14471458 tmp_dir_name,
14481459 });
1449 try out.print("<pre><code class=\"shell\">$ zig build-lib {}.zig", code.name);
1460 try out.print("<pre><code class=\"shell\">$ zig build-lib {}.zig", .{code.name});
14501461 switch (code.mode) {
14511462 builtin.Mode.Debug => {},
14521463 builtin.Mode.ReleaseSafe => {
14531464 try test_args.append("--release-safe");
1454 try out.print(" --release-safe");
1465 try out.print(" --release-safe", .{});
14551466 },
14561467 builtin.Mode.ReleaseFast => {
14571468 try test_args.append("--release-fast");
1458 try out.print(" --release-fast");
1469 try out.print(" --release-fast", .{});
14591470 },
14601471 builtin.Mode.ReleaseSmall => {
14611472 try test_args.append("--release-small");
1462 try out.print(" --release-small");
1473 try out.print(" --release-small", .{});
14631474 },
14641475 }
14651476 if (code.target_str) |triple| {
14661477 try test_args.appendSlice(&[_][]const u8{ "-target", triple });
1467 try out.print(" -target {}", triple);
1478 try out.print(" -target {}", .{triple});
14681479 }
1469 const result = exec(allocator, &env_map, test_args.toSliceConst()) catch return parseError(tokenizer, code.source_token, "test failed");
1480 const result = exec(allocator, &env_map, test_args.toSliceConst()) catch return parseError(tokenizer, code.source_token, "test failed", .{});
14701481 const escaped_stderr = try escapeHtml(allocator, result.stderr);
14711482 const escaped_stdout = try escapeHtml(allocator, result.stdout);
1472 try out.print("\n{}{}</code></pre>\n", escaped_stderr, escaped_stdout);
1483 try out.print("\n{}{}</code></pre>\n", .{ escaped_stderr, escaped_stdout });
14731484 },
14741485 }
1475 warn("OK\n");
1486 warn("OK\n", .{});
14761487 },
14771488 }
14781489 }
......@@ -1483,20 +1494,20 @@ fn exec(allocator: *mem.Allocator, env_map: *std.BufMap, args: []const []const u
14831494 switch (result.term) {
14841495 .Exited => |exit_code| {
14851496 if (exit_code != 0) {
1486 warn("{}\nThe following command exited with code {}:\n", result.stderr, exit_code);
1497 warn("{}\nThe following command exited with code {}:\n", .{ result.stderr, exit_code });
14871498 for (args) |arg|
1488 warn("{} ", arg)
1499 warn("{} ", .{arg})
14891500 else
1490 warn("\n");
1501 warn("\n", .{});
14911502 return error.ChildExitError;
14921503 }
14931504 },
14941505 else => {
1495 warn("{}\nThe following command crashed:\n", result.stderr);
1506 warn("{}\nThe following command crashed:\n", .{result.stderr});
14961507 for (args) |arg|
1497 warn("{} ", arg)
1508 warn("{} ", .{arg})
14981509 else
1499 warn("\n");
1510 warn("\n", .{});
15001511 return error.ChildCrashed;
15011512 },
15021513 }
doc/langref.html.in+82-70
......@@ -205,7 +205,7 @@ const std = @import("std");
205205
206206pub fn main() !void {
207207 const stdout = &std.io.getStdOut().outStream().stream;
208 try stdout.print("Hello, {}!\n", "world");
208 try stdout.print("Hello, {}!\n", .{"world"});
209209}
210210 {#code_end#}
211211 <p>
......@@ -217,7 +217,7 @@ pub fn main() !void {
217217const warn = @import("std").debug.warn;
218218
219219pub fn main() void {
220 warn("Hello, world!\n");
220 warn("Hello, world!\n", .{});
221221}
222222 {#code_end#}
223223 <p>
......@@ -289,41 +289,50 @@ const assert = std.debug.assert;
289289pub fn main() void {
290290 // integers
291291 const one_plus_one: i32 = 1 + 1;
292 warn("1 + 1 = {}\n", one_plus_one);
292 warn("1 + 1 = {}\n", .{one_plus_one});
293293
294294 // floats
295295 const seven_div_three: f32 = 7.0 / 3.0;
296 warn("7.0 / 3.0 = {}\n", seven_div_three);
296 warn("7.0 / 3.0 = {}\n", .{seven_div_three});
297297
298298 // boolean
299 warn("{}\n{}\n{}\n",
299 warn("{}\n{}\n{}\n", .{
300300 true and false,
301301 true or false,
302 !true);
302 !true,
303 });
303304
304305 // optional
305306 var optional_value: ?[]const u8 = null;
306307 assert(optional_value == null);
307308
308 warn("\noptional 1\ntype: {}\nvalue: {}\n",
309 @typeName(@typeOf(optional_value)), optional_value);
309 warn("\noptional 1\ntype: {}\nvalue: {}\n", .{
310 @typeName(@typeOf(optional_value)),
311 optional_value,
312 });
310313
311314 optional_value = "hi";
312315 assert(optional_value != null);
313316
314 warn("\noptional 2\ntype: {}\nvalue: {}\n",
315 @typeName(@typeOf(optional_value)), optional_value);
317 warn("\noptional 2\ntype: {}\nvalue: {}\n", .{
318 @typeName(@typeOf(optional_value)),
319 optional_value,
320 });
316321
317322 // error union
318323 var number_or_error: anyerror!i32 = error.ArgNotFound;
319324
320 warn("\nerror union 1\ntype: {}\nvalue: {}\n",
321 @typeName(@typeOf(number_or_error)), number_or_error);
325 warn("\nerror union 1\ntype: {}\nvalue: {}\n", .{
326 @typeName(@typeOf(number_or_error)),
327 number_or_error,
328 });
322329
323330 number_or_error = 1234;
324331
325 warn("\nerror union 2\ntype: {}\nvalue: {}\n",
326 @typeName(@typeOf(number_or_error)), number_or_error);
332 warn("\nerror union 2\ntype: {}\nvalue: {}\n", .{
333 @typeName(@typeOf(number_or_error)),
334 number_or_error,
335 });
327336}
328337 {#code_end#}
329338 {#header_open|Primitive Types#}
......@@ -954,8 +963,8 @@ extern fn foo_optimized(x: f64) f64;
954963
955964pub fn main() void {
956965 const x = 0.001;
957 warn("optimized = {}\n", foo_optimized(x));
958 warn("strict = {}\n", foo_strict(x));
966 warn("optimized = {}\n", .{foo_optimized(x)});
967 warn("strict = {}\n", .{foo_strict(x)});
959968}
960969 {#code_end#}
961970 {#see_also|@setFloatMode|Division by Zero#}
......@@ -2182,7 +2191,7 @@ test "using slices for strings" {
21822191 // You can use slice syntax on an array to convert an array into a slice.
21832192 const all_together_slice = all_together[0..];
21842193 // String concatenation example.
2185 const hello_world = try fmt.bufPrint(all_together_slice, "{} {}", hello, world);
2194 const hello_world = try fmt.bufPrint(all_together_slice, "{} {}", .{hello, world});
21862195
21872196 // Generally, you can use UTF-8 and not worry about whether something is a
21882197 // string. If you don't need to deal with individual characters, no need
......@@ -2623,9 +2632,9 @@ const std = @import("std");
26232632
26242633pub fn main() void {
26252634 const Foo = struct {};
2626 std.debug.warn("variable: {}\n", @typeName(Foo));
2627 std.debug.warn("anonymous: {}\n", @typeName(struct {}));
2628 std.debug.warn("function: {}\n", @typeName(List(i32)));
2635 std.debug.warn("variable: {}\n", .{@typeName(Foo)});
2636 std.debug.warn("anonymous: {}\n", .{@typeName(struct {})});
2637 std.debug.warn("function: {}\n", .{@typeName(List(i32))});
26292638}
26302639
26312640fn List(comptime T: type) type {
......@@ -3806,18 +3815,18 @@ test "defer basics" {
38063815// If multiple defer statements are specified, they will be executed in
38073816// the reverse order they were run.
38083817fn deferUnwindExample() void {
3809 warn("\n");
3818 warn("\n", .{});
38103819
38113820 defer {
3812 warn("1 ");
3821 warn("1 ", .{});
38133822 }
38143823 defer {
3815 warn("2 ");
3824 warn("2 ", .{});
38163825 }
38173826 if (false) {
38183827 // defers are not run if they are never executed.
38193828 defer {
3820 warn("3 ");
3829 warn("3 ", .{});
38213830 }
38223831 }
38233832}
......@@ -3832,15 +3841,15 @@ test "defer unwinding" {
38323841// This is especially useful in allowing a function to clean up properly
38333842// on error, and replaces goto error handling tactics as seen in c.
38343843fn deferErrorExample(is_error: bool) !void {
3835 warn("\nstart of function\n");
3844 warn("\nstart of function\n", .{});
38363845
38373846 // This will always be executed on exit
38383847 defer {
3839 warn("end of function\n");
3848 warn("end of function\n", .{});
38403849 }
38413850
38423851 errdefer {
3843 warn("encountered an error!\n");
3852 warn("encountered an error!\n", .{});
38443853 }
38453854
38463855 if (is_error) {
......@@ -5843,7 +5852,7 @@ const a_number: i32 = 1234;
58435852const a_string = "foobar";
58445853
58455854pub fn main() void {
5846 warn("here is a string: '{}' here is a number: {}\n", a_string, a_number);
5855 warn("here is a string: '{}' here is a number: {}\n", .{a_string, a_number});
58475856}
58485857 {#code_end#}
58495858
......@@ -5960,8 +5969,11 @@ const a_number: i32 = 1234;
59605969const a_string = "foobar";
59615970
59625971test "printf too many arguments" {
5963 warn("here is a string: '{}' here is a number: {}\n",
5964 a_string, a_number, a_number);
5972 warn("here is a string: '{}' here is a number: {}\n", .{
5973 a_string,
5974 a_number,
5975 a_number,
5976 });
59655977}
59665978 {#code_end#}
59675979 <p>
......@@ -5979,7 +5991,7 @@ const a_string = "foobar";
59795991const fmt = "here is a string: '{}' here is a number: {}\n";
59805992
59815993pub fn main() void {
5982 warn(fmt, a_string, a_number);
5994 warn(fmt, .{a_string, a_number});
59835995}
59845996 {#code_end#}
59855997 <p>
......@@ -6417,7 +6429,7 @@ pub fn main() void {
64176429
64186430fn amainWrap() void {
64196431 amain() catch |e| {
6420 std.debug.warn("{}\n", e);
6432 std.debug.warn("{}\n", .{e});
64216433 if (@errorReturnTrace()) |trace| {
64226434 std.debug.dumpStackTrace(trace.*);
64236435 }
......@@ -6447,8 +6459,8 @@ fn amain() !void {
64476459 const download_text = try await download_frame;
64486460 defer allocator.free(download_text);
64496461
6450 std.debug.warn("download_text: {}\n", download_text);
6451 std.debug.warn("file_text: {}\n", file_text);
6462 std.debug.warn("download_text: {}\n", .{download_text});
6463 std.debug.warn("file_text: {}\n", .{file_text});
64526464}
64536465
64546466var global_download_frame: anyframe = undefined;
......@@ -6458,7 +6470,7 @@ fn fetchUrl(allocator: *Allocator, url: []const u8) ![]u8 {
64586470 suspend {
64596471 global_download_frame = @frame();
64606472 }
6461 std.debug.warn("fetchUrl returning\n");
6473 std.debug.warn("fetchUrl returning\n", .{});
64626474 return result;
64636475}
64646476
......@@ -6469,7 +6481,7 @@ fn readFile(allocator: *Allocator, filename: []const u8) ![]u8 {
64696481 suspend {
64706482 global_file_frame = @frame();
64716483 }
6472 std.debug.warn("readFile returning\n");
6484 std.debug.warn("readFile returning\n", .{});
64736485 return result;
64746486}
64756487 {#code_end#}
......@@ -6487,7 +6499,7 @@ pub fn main() void {
64876499
64886500fn amainWrap() void {
64896501 amain() catch |e| {
6490 std.debug.warn("{}\n", e);
6502 std.debug.warn("{}\n", .{e});
64916503 if (@errorReturnTrace()) |trace| {
64926504 std.debug.dumpStackTrace(trace.*);
64936505 }
......@@ -6517,21 +6529,21 @@ fn amain() !void {
65176529 const download_text = try await download_frame;
65186530 defer allocator.free(download_text);
65196531
6520 std.debug.warn("download_text: {}\n", download_text);
6521 std.debug.warn("file_text: {}\n", file_text);
6532 std.debug.warn("download_text: {}\n", .{download_text});
6533 std.debug.warn("file_text: {}\n", .{file_text});
65226534}
65236535
65246536fn fetchUrl(allocator: *Allocator, url: []const u8) ![]u8 {
65256537 const result = try std.mem.dupe(allocator, u8, "this is the downloaded url contents");
65266538 errdefer allocator.free(result);
6527 std.debug.warn("fetchUrl returning\n");
6539 std.debug.warn("fetchUrl returning\n", .{});
65286540 return result;
65296541}
65306542
65316543fn readFile(allocator: *Allocator, filename: []const u8) ![]u8 {
65326544 const result = try std.mem.dupe(allocator, u8, "this is the file contents");
65336545 errdefer allocator.free(result);
6534 std.debug.warn("readFile returning\n");
6546 std.debug.warn("readFile returning\n", .{});
65356547 return result;
65366548}
65376549 {#code_end#}
......@@ -7103,7 +7115,7 @@ const num1 = blk: {
71037115test "main" {
71047116 @compileLog("comptime in main");
71057117
7106 warn("Runtime in main, num1 = {}.\n", num1);
7118 warn("Runtime in main, num1 = {}.\n", .{num1});
71077119}
71087120 {#code_end#}
71097121 <p>
......@@ -7124,7 +7136,7 @@ const num1 = blk: {
71247136};
71257137
71267138test "main" {
7127 warn("Runtime in main, num1 = {}.\n", num1);
7139 warn("Runtime in main, num1 = {}.\n", .{num1});
71287140}
71297141 {#code_end#}
71307142 {#header_close#}
......@@ -8706,7 +8718,7 @@ const std = @import("std");
87068718pub fn main() void {
87078719 var value: i32 = -1;
87088720 var unsigned = @intCast(u32, value);
8709 std.debug.warn("value: {}\n", unsigned);
8721 std.debug.warn("value: {}\n", .{unsigned});
87108722}
87118723 {#code_end#}
87128724 <p>
......@@ -8728,7 +8740,7 @@ const std = @import("std");
87288740pub fn main() void {
87298741 var spartan_count: u16 = 300;
87308742 const byte = @intCast(u8, spartan_count);
8731 std.debug.warn("value: {}\n", byte);
8743 std.debug.warn("value: {}\n", .{byte});
87328744}
87338745 {#code_end#}
87348746 <p>
......@@ -8762,7 +8774,7 @@ const std = @import("std");
87628774pub fn main() void {
87638775 var byte: u8 = 255;
87648776 byte += 1;
8765 std.debug.warn("value: {}\n", byte);
8777 std.debug.warn("value: {}\n", .{byte});
87668778}
87678779 {#code_end#}
87688780 {#header_close#}
......@@ -8785,11 +8797,11 @@ pub fn main() !void {
87858797 var byte: u8 = 255;
87868798
87878799 byte = if (math.add(u8, byte, 1)) |result| result else |err| {
8788 warn("unable to add one: {}\n", @errorName(err));
8800 warn("unable to add one: {}\n", .{@errorName(err)});
87898801 return err;
87908802 };
87918803
8792 warn("result: {}\n", byte);
8804 warn("result: {}\n", .{byte});
87938805}
87948806 {#code_end#}
87958807 {#header_close#}
......@@ -8814,9 +8826,9 @@ pub fn main() void {
88148826
88158827 var result: u8 = undefined;
88168828 if (@addWithOverflow(u8, byte, 10, &result)) {
8817 warn("overflowed result: {}\n", result);
8829 warn("overflowed result: {}\n", .{result});
88188830 } else {
8819 warn("result: {}\n", result);
8831 warn("result: {}\n", .{result});
88208832 }
88218833}
88228834 {#code_end#}
......@@ -8861,7 +8873,7 @@ const std = @import("std");
88618873pub fn main() void {
88628874 var x: u8 = 0b01010101;
88638875 var y = @shlExact(x, 2);
8864 std.debug.warn("value: {}\n", y);
8876 std.debug.warn("value: {}\n", .{y});
88658877}
88668878 {#code_end#}
88678879 {#header_close#}
......@@ -8879,7 +8891,7 @@ const std = @import("std");
88798891pub fn main() void {
88808892 var x: u8 = 0b10101010;
88818893 var y = @shrExact(x, 2);
8882 std.debug.warn("value: {}\n", y);
8894 std.debug.warn("value: {}\n", .{y});
88838895}
88848896 {#code_end#}
88858897 {#header_close#}
......@@ -8900,7 +8912,7 @@ pub fn main() void {
89008912 var a: u32 = 1;
89018913 var b: u32 = 0;
89028914 var c = a / b;
8903 std.debug.warn("value: {}\n", c);
8915 std.debug.warn("value: {}\n", .{c});
89048916}
89058917 {#code_end#}
89068918 {#header_close#}
......@@ -8921,7 +8933,7 @@ pub fn main() void {
89218933 var a: u32 = 10;
89228934 var b: u32 = 0;
89238935 var c = a % b;
8924 std.debug.warn("value: {}\n", c);
8936 std.debug.warn("value: {}\n", .{c});
89258937}
89268938 {#code_end#}
89278939 {#header_close#}
......@@ -8942,7 +8954,7 @@ pub fn main() void {
89428954 var a: u32 = 10;
89438955 var b: u32 = 3;
89448956 var c = @divExact(a, b);
8945 std.debug.warn("value: {}\n", c);
8957 std.debug.warn("value: {}\n", .{c});
89468958}
89478959 {#code_end#}
89488960 {#header_close#}
......@@ -8961,7 +8973,7 @@ const std = @import("std");
89618973pub fn main() void {
89628974 var bytes = [5]u8{ 1, 2, 3, 4, 5 };
89638975 var slice = @bytesToSlice(u32, bytes[0..]);
8964 std.debug.warn("value: {}\n", slice[0]);
8976 std.debug.warn("value: {}\n", .{slice[0]});
89658977}
89668978 {#code_end#}
89678979 {#header_close#}
......@@ -8980,7 +8992,7 @@ const std = @import("std");
89808992pub fn main() void {
89818993 var optional_number: ?i32 = null;
89828994 var number = optional_number.?;
8983 std.debug.warn("value: {}\n", number);
8995 std.debug.warn("value: {}\n", .{number});
89848996}
89858997 {#code_end#}
89868998 <p>One way to avoid this crash is to test for null instead of assuming non-null, with
......@@ -8991,9 +9003,9 @@ pub fn main() void {
89919003 const optional_number: ?i32 = null;
89929004
89939005 if (optional_number) |number| {
8994 warn("got number: {}\n", number);
9006 warn("got number: {}\n", .{number});
89959007 } else {
8996 warn("it's null\n");
9008 warn("it's null\n", .{});
89979009 }
89989010}
89999011 {#code_end#}
......@@ -9016,7 +9028,7 @@ const std = @import("std");
90169028
90179029pub fn main() void {
90189030 const number = getNumberOrFail() catch unreachable;
9019 std.debug.warn("value: {}\n", number);
9031 std.debug.warn("value: {}\n", .{number});
90209032}
90219033
90229034fn getNumberOrFail() !i32 {
......@@ -9032,9 +9044,9 @@ pub fn main() void {
90329044 const result = getNumberOrFail();
90339045
90349046 if (result) |number| {
9035 warn("got number: {}\n", number);
9047 warn("got number: {}\n", .{number});
90369048 } else |err| {
9037 warn("got error: {}\n", @errorName(err));
9049 warn("got error: {}\n", .{@errorName(err)});
90389050 }
90399051}
90409052
......@@ -9061,7 +9073,7 @@ pub fn main() void {
90619073 var err = error.AnError;
90629074 var number = @errorToInt(err) + 500;
90639075 var invalid_err = @intToError(number);
9064 std.debug.warn("value: {}\n", number);
9076 std.debug.warn("value: {}\n", .{number});
90659077}
90669078 {#code_end#}
90679079 {#header_close#}
......@@ -9091,7 +9103,7 @@ const Foo = enum {
90919103pub fn main() void {
90929104 var a: u2 = 3;
90939105 var b = @intToEnum(Foo, a);
9094 std.debug.warn("value: {}\n", @tagName(b));
9106 std.debug.warn("value: {}\n", .{@tagName(b)});
90959107}
90969108 {#code_end#}
90979109 {#header_close#}
......@@ -9128,7 +9140,7 @@ pub fn main() void {
91289140}
91299141fn foo(set1: Set1) void {
91309142 const x = @errSetCast(Set2, set1);
9131 std.debug.warn("value: {}\n", x);
9143 std.debug.warn("value: {}\n", .{x});
91329144}
91339145 {#code_end#}
91349146 {#header_close#}
......@@ -9184,7 +9196,7 @@ pub fn main() void {
91849196
91859197fn bar(f: *Foo) void {
91869198 f.float = 12.34;
9187 std.debug.warn("value: {}\n", f.float);
9199 std.debug.warn("value: {}\n", .{f.float});
91889200}
91899201 {#code_end#}
91909202 <p>
......@@ -9208,7 +9220,7 @@ pub fn main() void {
92089220
92099221fn bar(f: *Foo) void {
92109222 f.* = Foo{ .float = 12.34 };
9211 std.debug.warn("value: {}\n", f.float);
9223 std.debug.warn("value: {}\n", .{f.float});
92129224}
92139225 {#code_end#}
92149226 <p>
......@@ -9227,7 +9239,7 @@ pub fn main() void {
92279239 var f = Foo{ .int = 42 };
92289240 f = Foo{ .float = undefined };
92299241 bar(&f);
9230 std.debug.warn("value: {}\n", f.float);
9242 std.debug.warn("value: {}\n", .{f.float});
92319243}
92329244
92339245fn bar(f: *Foo) void {
......@@ -9348,7 +9360,7 @@ pub fn main() !void {
93489360 const allocator = &arena.allocator;
93499361
93509362 const ptr = try allocator.create(i32);
9351 std.debug.warn("ptr={*}\n", ptr);
9363 std.debug.warn("ptr={*}\n", .{ptr});
93529364}
93539365 {#code_end#}
93549366 When using this kind of allocator, there is no need to free anything manually. Everything
......@@ -9881,7 +9893,7 @@ pub fn main() !void {
98819893 defer std.process.argsFree(std.heap.page_allocator, args);
98829894
98839895 for (args) |arg, i| {
9884 std.debug.warn("{}: {}\n", i, arg);
9896 std.debug.warn("{}: {}\n", .{i, arg});
98859897 }
98869898}
98879899 {#code_end#}
lib/std/atomic/queue.zig+9-10
......@@ -116,19 +116,19 @@ pub fn Queue(comptime T: type) type {
116116 fn dumpRecursive(s: *std.io.OutStream(Error), optional_node: ?*Node, indent: usize) Error!void {
117117 try s.writeByteNTimes(' ', indent);
118118 if (optional_node) |node| {
119 try s.print("0x{x}={}\n", @ptrToInt(node), node.data);
119 try s.print("0x{x}={}\n", .{ @ptrToInt(node), node.data });
120120 try dumpRecursive(s, node.next, indent + 1);
121121 } else {
122 try s.print("(null)\n");
122 try s.print("(null)\n", .{});
123123 }
124124 }
125125 };
126126 const held = self.mutex.acquire();
127127 defer held.release();
128128
129 try stream.print("head: ");
129 try stream.print("head: ", .{});
130130 try S.dumpRecursive(stream, self.head, 0);
131 try stream.print("tail: ");
131 try stream.print("tail: ", .{});
132132 try S.dumpRecursive(stream, self.tail, 0);
133133 }
134134 };
......@@ -207,16 +207,15 @@ test "std.atomic.Queue" {
207207 }
208208
209209 if (context.put_sum != context.get_sum) {
210 std.debug.panic("failure\nput_sum:{} != get_sum:{}", context.put_sum, context.get_sum);
210 std.debug.panic("failure\nput_sum:{} != get_sum:{}", .{ context.put_sum, context.get_sum });
211211 }
212212
213213 if (context.get_count != puts_per_thread * put_thread_count) {
214 std.debug.panic(
215 "failure\nget_count:{} != puts_per_thread:{} * put_thread_count:{}",
214 std.debug.panic("failure\nget_count:{} != puts_per_thread:{} * put_thread_count:{}", .{
216215 context.get_count,
217216 @as(u32, puts_per_thread),
218217 @as(u32, put_thread_count),
219 );
218 });
220219 }
221220}
222221
......@@ -351,7 +350,7 @@ test "std.atomic.Queue dump" {
351350 \\tail: 0x{x}=1
352351 \\ (null)
353352 \\
354 , @ptrToInt(queue.head), @ptrToInt(queue.tail));
353 , .{ @ptrToInt(queue.head), @ptrToInt(queue.tail) });
355354 expect(mem.eql(u8, buffer[0..sos.pos], expected));
356355
357356 // Test a stream with two elements
......@@ -372,6 +371,6 @@ test "std.atomic.Queue dump" {
372371 \\tail: 0x{x}=2
373372 \\ (null)
374373 \\
375 , @ptrToInt(queue.head), @ptrToInt(queue.head.?.next), @ptrToInt(queue.tail));
374 , .{ @ptrToInt(queue.head), @ptrToInt(queue.head.?.next), @ptrToInt(queue.tail) });
376375 expect(mem.eql(u8, buffer[0..sos.pos], expected));
377376}
lib/std/atomic/stack.zig+3-4
......@@ -134,16 +134,15 @@ test "std.atomic.stack" {
134134 }
135135
136136 if (context.put_sum != context.get_sum) {
137 std.debug.panic("failure\nput_sum:{} != get_sum:{}", context.put_sum, context.get_sum);
137 std.debug.panic("failure\nput_sum:{} != get_sum:{}", .{ context.put_sum, context.get_sum });
138138 }
139139
140140 if (context.get_count != puts_per_thread * put_thread_count) {
141 std.debug.panic(
142 "failure\nget_count:{} != puts_per_thread:{} * put_thread_count:{}",
141 std.debug.panic("failure\nget_count:{} != puts_per_thread:{} * put_thread_count:{}", .{
143142 context.get_count,
144143 @as(u32, puts_per_thread),
145144 @as(u32, put_thread_count),
146 );
145 });
147146 }
148147}
149148
lib/std/buffer.zig+4-4
......@@ -16,7 +16,7 @@ pub const Buffer = struct {
1616 mem.copy(u8, self.list.items, m);
1717 return self;
1818 }
19
19
2020 /// Initialize memory to size bytes of undefined values.
2121 /// Must deinitialize with deinit.
2222 pub fn initSize(allocator: *Allocator, size: usize) !Buffer {
......@@ -24,7 +24,7 @@ pub const Buffer = struct {
2424 try self.resize(size);
2525 return self;
2626 }
27
27
2828 /// Initialize with capacity to hold at least num bytes.
2929 /// Must deinitialize with deinit.
3030 pub fn initCapacity(allocator: *Allocator, num: usize) !Buffer {
......@@ -64,7 +64,7 @@ pub const Buffer = struct {
6464 return result;
6565 }
6666
67 pub fn allocPrint(allocator: *Allocator, comptime format: []const u8, args: ...) !Buffer {
67 pub fn allocPrint(allocator: *Allocator, comptime format: []const u8, args: var) !Buffer {
6868 const countSize = struct {
6969 fn countSize(size: *usize, bytes: []const u8) (error{}!void) {
7070 size.* += bytes.len;
......@@ -107,7 +107,7 @@ pub const Buffer = struct {
107107 pub fn len(self: Buffer) usize {
108108 return self.list.len - 1;
109109 }
110
110
111111 pub fn capacity(self: Buffer) usize {
112112 return if (self.list.items.len > 0)
113113 self.list.items.len - 1
lib/std/build.zig+104-82
......@@ -232,7 +232,7 @@ pub const Builder = struct {
232232 /// To run an executable built with zig build, see `LibExeObjStep.run`.
233233 pub fn addSystemCommand(self: *Builder, argv: []const []const u8) *RunStep {
234234 assert(argv.len >= 1);
235 const run_step = RunStep.create(self, self.fmt("run {}", argv[0]));
235 const run_step = RunStep.create(self, self.fmt("run {}", .{argv[0]}));
236236 run_step.addArgs(argv);
237237 return run_step;
238238 }
......@@ -258,7 +258,7 @@ pub const Builder = struct {
258258 return write_file_step;
259259 }
260260
261 pub fn addLog(self: *Builder, comptime format: []const u8, args: ...) *LogStep {
261 pub fn addLog(self: *Builder, comptime format: []const u8, args: var) *LogStep {
262262 const data = self.fmt(format, args);
263263 const log_step = self.allocator.create(LogStep) catch unreachable;
264264 log_step.* = LogStep.init(self, data);
......@@ -330,7 +330,7 @@ pub const Builder = struct {
330330 for (self.installed_files.toSliceConst()) |installed_file| {
331331 const full_path = self.getInstallPath(installed_file.dir, installed_file.path);
332332 if (self.verbose) {
333 warn("rm {}\n", full_path);
333 warn("rm {}\n", .{full_path});
334334 }
335335 fs.deleteTree(full_path) catch {};
336336 }
......@@ -340,7 +340,7 @@ pub const Builder = struct {
340340
341341 fn makeOneStep(self: *Builder, s: *Step) anyerror!void {
342342 if (s.loop_flag) {
343 warn("Dependency loop detected:\n {}\n", s.name);
343 warn("Dependency loop detected:\n {}\n", .{s.name});
344344 return error.DependencyLoopDetected;
345345 }
346346 s.loop_flag = true;
......@@ -348,7 +348,7 @@ pub const Builder = struct {
348348 for (s.dependencies.toSlice()) |dep| {
349349 self.makeOneStep(dep) catch |err| {
350350 if (err == error.DependencyLoopDetected) {
351 warn(" {}\n", s.name);
351 warn(" {}\n", .{s.name});
352352 }
353353 return err;
354354 };
......@@ -365,7 +365,7 @@ pub const Builder = struct {
365365 return &top_level_step.step;
366366 }
367367 }
368 warn("Cannot run step '{}' because it does not exist\n", name);
368 warn("Cannot run step '{}' because it does not exist\n", .{name});
369369 return error.InvalidStepName;
370370 }
371371
......@@ -378,12 +378,12 @@ pub const Builder = struct {
378378 const word = it.next() orelse break;
379379 if (mem.eql(u8, word, "-isystem")) {
380380 const include_path = it.next() orelse {
381 warn("Expected argument after -isystem in NIX_CFLAGS_COMPILE\n");
381 warn("Expected argument after -isystem in NIX_CFLAGS_COMPILE\n", .{});
382382 break;
383383 };
384384 self.addNativeSystemIncludeDir(include_path);
385385 } else {
386 warn("Unrecognized C flag from NIX_CFLAGS_COMPILE: {}\n", word);
386 warn("Unrecognized C flag from NIX_CFLAGS_COMPILE: {}\n", .{word});
387387 break;
388388 }
389389 }
......@@ -397,7 +397,7 @@ pub const Builder = struct {
397397 const word = it.next() orelse break;
398398 if (mem.eql(u8, word, "-rpath")) {
399399 const rpath = it.next() orelse {
400 warn("Expected argument after -rpath in NIX_LDFLAGS\n");
400 warn("Expected argument after -rpath in NIX_LDFLAGS\n", .{});
401401 break;
402402 };
403403 self.addNativeSystemRPath(rpath);
......@@ -405,7 +405,7 @@ pub const Builder = struct {
405405 const lib_path = word[2..];
406406 self.addNativeSystemLibPath(lib_path);
407407 } else {
408 warn("Unrecognized C flag from NIX_LDFLAGS: {}\n", word);
408 warn("Unrecognized C flag from NIX_LDFLAGS: {}\n", .{word});
409409 break;
410410 }
411411 }
......@@ -431,8 +431,8 @@ pub const Builder = struct {
431431 self.addNativeSystemIncludeDir("/usr/local/include");
432432 self.addNativeSystemLibPath("/usr/local/lib");
433433
434 self.addNativeSystemIncludeDir(self.fmt("/usr/include/{}", triple));
435 self.addNativeSystemLibPath(self.fmt("/usr/lib/{}", triple));
434 self.addNativeSystemIncludeDir(self.fmt("/usr/include/{}", .{triple}));
435 self.addNativeSystemLibPath(self.fmt("/usr/lib/{}", .{triple}));
436436
437437 self.addNativeSystemIncludeDir("/usr/include");
438438 self.addNativeSystemLibPath("/usr/lib");
......@@ -440,7 +440,7 @@ pub const Builder = struct {
440440 // example: on a 64-bit debian-based linux distro, with zlib installed from apt:
441441 // zlib.h is in /usr/include (added above)
442442 // libz.so.1 is in /lib/x86_64-linux-gnu (added here)
443 self.addNativeSystemLibPath(self.fmt("/lib/{}", triple));
443 self.addNativeSystemLibPath(self.fmt("/lib/{}", .{triple}));
444444 },
445445 }
446446 }
......@@ -453,7 +453,7 @@ pub const Builder = struct {
453453 .description = description,
454454 };
455455 if ((self.available_options_map.put(name, available_option) catch unreachable) != null) {
456 panic("Option '{}' declared twice", name);
456 panic("Option '{}' declared twice", .{name});
457457 }
458458 self.available_options_list.append(available_option) catch unreachable;
459459
......@@ -468,33 +468,33 @@ pub const Builder = struct {
468468 } else if (mem.eql(u8, s, "false")) {
469469 return false;
470470 } else {
471 warn("Expected -D{} to be a boolean, but received '{}'\n", name, s);
471 warn("Expected -D{} to be a boolean, but received '{}'\n", .{ name, s });
472472 self.markInvalidUserInput();
473473 return null;
474474 }
475475 },
476476 UserValue.List => {
477 warn("Expected -D{} to be a boolean, but received a list.\n", name);
477 warn("Expected -D{} to be a boolean, but received a list.\n", .{name});
478478 self.markInvalidUserInput();
479479 return null;
480480 },
481481 },
482 TypeId.Int => panic("TODO integer options to build script"),
483 TypeId.Float => panic("TODO float options to build script"),
482 TypeId.Int => panic("TODO integer options to build script", .{}),
483 TypeId.Float => panic("TODO float options to build script", .{}),
484484 TypeId.String => switch (entry.value.value) {
485485 UserValue.Flag => {
486 warn("Expected -D{} to be a string, but received a boolean.\n", name);
486 warn("Expected -D{} to be a string, but received a boolean.\n", .{name});
487487 self.markInvalidUserInput();
488488 return null;
489489 },
490490 UserValue.List => {
491 warn("Expected -D{} to be a string, but received a list.\n", name);
491 warn("Expected -D{} to be a string, but received a list.\n", .{name});
492492 self.markInvalidUserInput();
493493 return null;
494494 },
495495 UserValue.Scalar => |s| return s,
496496 },
497 TypeId.List => panic("TODO list options to build script"),
497 TypeId.List => panic("TODO list options to build script", .{}),
498498 }
499499 }
500500
......@@ -513,7 +513,7 @@ pub const Builder = struct {
513513 if (self.release_mode != null) {
514514 @panic("setPreferredReleaseMode must be called before standardReleaseOptions and may not be called twice");
515515 }
516 const description = self.fmt("create a release build ({})", @tagName(mode));
516 const description = self.fmt("create a release build ({})", .{@tagName(mode)});
517517 self.is_release = self.option(bool, "release", description) orelse false;
518518 self.release_mode = if (self.is_release) mode else builtin.Mode.Debug;
519519 }
......@@ -536,7 +536,7 @@ pub const Builder = struct {
536536 else if (!release_fast and !release_safe and !release_small)
537537 builtin.Mode.Debug
538538 else x: {
539 warn("Multiple release modes (of -Drelease-safe, -Drelease-fast and -Drelease-small)");
539 warn("Multiple release modes (of -Drelease-safe, -Drelease-fast and -Drelease-small)", .{});
540540 self.markInvalidUserInput();
541541 break :x builtin.Mode.Debug;
542542 };
......@@ -599,7 +599,7 @@ pub const Builder = struct {
599599 }) catch unreachable;
600600 },
601601 UserValue.Flag => {
602 warn("Option '-D{}={}' conflicts with flag '-D{}'.\n", name, value, name);
602 warn("Option '-D{}={}' conflicts with flag '-D{}'.\n", .{ name, value, name });
603603 return true;
604604 },
605605 }
......@@ -620,11 +620,11 @@ pub const Builder = struct {
620620 // option already exists
621621 switch (gop.kv.value.value) {
622622 UserValue.Scalar => |s| {
623 warn("Flag '-D{}' conflicts with option '-D{}={}'.\n", name, name, s);
623 warn("Flag '-D{}' conflicts with option '-D{}={}'.\n", .{ name, name, s });
624624 return true;
625625 },
626626 UserValue.List => {
627 warn("Flag '-D{}' conflicts with multiple options of the same name.\n", name);
627 warn("Flag '-D{}' conflicts with multiple options of the same name.\n", .{name});
628628 return true;
629629 },
630630 UserValue.Flag => {},
......@@ -665,7 +665,7 @@ pub const Builder = struct {
665665 while (true) {
666666 const entry = it.next() orelse break;
667667 if (!entry.value.used) {
668 warn("Invalid option: -D{}\n\n", entry.key);
668 warn("Invalid option: -D{}\n\n", .{entry.key});
669669 self.markInvalidUserInput();
670670 }
671671 }
......@@ -678,11 +678,11 @@ pub const Builder = struct {
678678 }
679679
680680 fn printCmd(cwd: ?[]const u8, argv: []const []const u8) void {
681 if (cwd) |yes_cwd| warn("cd {} && ", yes_cwd);
681 if (cwd) |yes_cwd| warn("cd {} && ", .{yes_cwd});
682682 for (argv) |arg| {
683 warn("{} ", arg);
683 warn("{} ", .{arg});
684684 }
685 warn("\n");
685 warn("\n", .{});
686686 }
687687
688688 fn spawnChildEnvMap(self: *Builder, cwd: ?[]const u8, env_map: *const BufMap, argv: []const []const u8) !void {
......@@ -697,20 +697,20 @@ pub const Builder = struct {
697697 child.env_map = env_map;
698698
699699 const term = child.spawnAndWait() catch |err| {
700 warn("Unable to spawn {}: {}\n", argv[0], @errorName(err));
700 warn("Unable to spawn {}: {}\n", .{ argv[0], @errorName(err) });
701701 return err;
702702 };
703703
704704 switch (term) {
705705 .Exited => |code| {
706706 if (code != 0) {
707 warn("The following command exited with error code {}:\n", code);
707 warn("The following command exited with error code {}:\n", .{code});
708708 printCmd(cwd, argv);
709709 return error.UncleanExit;
710710 }
711711 },
712712 else => {
713 warn("The following command terminated unexpectedly:\n");
713 warn("The following command terminated unexpectedly:\n", .{});
714714 printCmd(cwd, argv);
715715
716716 return error.UncleanExit;
......@@ -720,7 +720,7 @@ pub const Builder = struct {
720720
721721 pub fn makePath(self: *Builder, path: []const u8) !void {
722722 fs.makePath(self.allocator, self.pathFromRoot(path)) catch |err| {
723 warn("Unable to create path {}: {}\n", path, @errorName(err));
723 warn("Unable to create path {}: {}\n", .{ path, @errorName(err) });
724724 return err;
725725 };
726726 }
......@@ -793,12 +793,12 @@ pub const Builder = struct {
793793
794794 fn updateFile(self: *Builder, source_path: []const u8, dest_path: []const u8) !void {
795795 if (self.verbose) {
796 warn("cp {} {} ", source_path, dest_path);
796 warn("cp {} {} ", .{ source_path, dest_path });
797797 }
798798 const prev_status = try fs.updateFile(source_path, dest_path);
799799 if (self.verbose) switch (prev_status) {
800 .stale => warn("# installed\n"),
801 .fresh => warn("# up-to-date\n"),
800 .stale => warn("# installed\n", .{}),
801 .fresh => warn("# up-to-date\n", .{}),
802802 };
803803 }
804804
......@@ -806,7 +806,7 @@ pub const Builder = struct {
806806 return fs.path.resolve(self.allocator, &[_][]const u8{ self.build_root, rel_path }) catch unreachable;
807807 }
808808
809 pub fn fmt(self: *Builder, comptime format: []const u8, args: ...) []u8 {
809 pub fn fmt(self: *Builder, comptime format: []const u8, args: var) []u8 {
810810 return fmt_lib.allocPrint(self.allocator, format, args) catch unreachable;
811811 }
812812
......@@ -818,7 +818,11 @@ pub const Builder = struct {
818818 if (fs.path.isAbsolute(name)) {
819819 return name;
820820 }
821 const full_path = try fs.path.join(self.allocator, &[_][]const u8{ search_prefix, "bin", self.fmt("{}{}", name, exe_extension) });
821 const full_path = try fs.path.join(self.allocator, &[_][]const u8{
822 search_prefix,
823 "bin",
824 self.fmt("{}{}", .{ name, exe_extension }),
825 });
822826 return fs.realpathAlloc(self.allocator, full_path) catch continue;
823827 }
824828 }
......@@ -829,7 +833,10 @@ pub const Builder = struct {
829833 }
830834 var it = mem.tokenize(PATH, &[_]u8{fs.path.delimiter});
831835 while (it.next()) |path| {
832 const full_path = try fs.path.join(self.allocator, &[_][]const u8{ path, self.fmt("{}{}", name, exe_extension) });
836 const full_path = try fs.path.join(self.allocator, &[_][]const u8{
837 path,
838 self.fmt("{}{}", .{ name, exe_extension }),
839 });
833840 return fs.realpathAlloc(self.allocator, full_path) catch continue;
834841 }
835842 }
......@@ -839,7 +846,10 @@ pub const Builder = struct {
839846 return name;
840847 }
841848 for (paths) |path| {
842 const full_path = try fs.path.join(self.allocator, &[_][]const u8{ path, self.fmt("{}{}", name, exe_extension) });
849 const full_path = try fs.path.join(self.allocator, &[_][]const u8{
850 path,
851 self.fmt("{}{}", .{ name, exe_extension }),
852 });
843853 return fs.realpathAlloc(self.allocator, full_path) catch continue;
844854 }
845855 }
......@@ -896,17 +906,17 @@ pub const Builder = struct {
896906 var code: u8 = undefined;
897907 return self.execAllowFail(argv, &code, .Inherit) catch |err| switch (err) {
898908 error.FileNotFound => {
899 warn("Unable to spawn the following command: file not found\n");
909 warn("Unable to spawn the following command: file not found\n", .{});
900910 printCmd(null, argv);
901911 std.os.exit(@truncate(u8, code));
902912 },
903913 error.ExitCodeFailure => {
904 warn("The following command exited with error code {}:\n", code);
914 warn("The following command exited with error code {}:\n", .{code});
905915 printCmd(null, argv);
906916 std.os.exit(@truncate(u8, code));
907917 },
908918 error.ProcessTerminated => {
909 warn("The following command terminated unexpectedly:\n");
919 warn("The following command terminated unexpectedly:\n", .{});
910920 printCmd(null, argv);
911921 std.os.exit(@truncate(u8, code));
912922 },
......@@ -1133,7 +1143,7 @@ pub const LibExeObjStep = struct {
11331143
11341144 fn initExtraArgs(builder: *Builder, name: []const u8, root_src: ?[]const u8, kind: Kind, is_dynamic: bool, ver: Version) LibExeObjStep {
11351145 if (mem.indexOf(u8, name, "/") != null or mem.indexOf(u8, name, "\\") != null) {
1136 panic("invalid name: '{}'. It looks like a file path, but it is supposed to be the library or application name.", name);
1146 panic("invalid name: '{}'. It looks like a file path, but it is supposed to be the library or application name.", .{name});
11371147 }
11381148 var self = LibExeObjStep{
11391149 .strip = false,
......@@ -1150,9 +1160,9 @@ pub const LibExeObjStep = struct {
11501160 .step = Step.init(name, builder.allocator, make),
11511161 .version = ver,
11521162 .out_filename = undefined,
1153 .out_h_filename = builder.fmt("{}.h", name),
1163 .out_h_filename = builder.fmt("{}.h", .{name}),
11541164 .out_lib_filename = undefined,
1155 .out_pdb_filename = builder.fmt("{}.pdb", name),
1165 .out_pdb_filename = builder.fmt("{}.pdb", .{name}),
11561166 .major_only_filename = undefined,
11571167 .name_only_filename = undefined,
11581168 .packages = ArrayList(Pkg).init(builder.allocator),
......@@ -1186,36 +1196,48 @@ pub const LibExeObjStep = struct {
11861196 fn computeOutFileNames(self: *LibExeObjStep) void {
11871197 switch (self.kind) {
11881198 .Obj => {
1189 self.out_filename = self.builder.fmt("{}{}", self.name, self.target.oFileExt());
1199 self.out_filename = self.builder.fmt("{}{}", .{ self.name, self.target.oFileExt() });
11901200 },
11911201 .Exe => {
1192 self.out_filename = self.builder.fmt("{}{}", self.name, self.target.exeFileExt());
1202 self.out_filename = self.builder.fmt("{}{}", .{ self.name, self.target.exeFileExt() });
11931203 },
11941204 .Test => {
1195 self.out_filename = self.builder.fmt("test{}", self.target.exeFileExt());
1205 self.out_filename = self.builder.fmt("test{}", .{self.target.exeFileExt()});
11961206 },
11971207 .Lib => {
11981208 if (!self.is_dynamic) {
1199 self.out_filename = self.builder.fmt(
1200 "{}{}{}",
1209 self.out_filename = self.builder.fmt("{}{}{}", .{
12011210 self.target.libPrefix(),
12021211 self.name,
12031212 self.target.staticLibSuffix(),
1204 );
1213 });
12051214 self.out_lib_filename = self.out_filename;
12061215 } else {
12071216 if (self.target.isDarwin()) {
1208 self.out_filename = self.builder.fmt("lib{}.{d}.{d}.{d}.dylib", self.name, self.version.major, self.version.minor, self.version.patch);
1209 self.major_only_filename = self.builder.fmt("lib{}.{d}.dylib", self.name, self.version.major);
1210 self.name_only_filename = self.builder.fmt("lib{}.dylib", self.name);
1217 self.out_filename = self.builder.fmt("lib{}.{d}.{d}.{d}.dylib", .{
1218 self.name,
1219 self.version.major,
1220 self.version.minor,
1221 self.version.patch,
1222 });
1223 self.major_only_filename = self.builder.fmt("lib{}.{d}.dylib", .{
1224 self.name,
1225 self.version.major,
1226 });
1227 self.name_only_filename = self.builder.fmt("lib{}.dylib", .{self.name});
12111228 self.out_lib_filename = self.out_filename;
12121229 } else if (self.target.isWindows()) {
1213 self.out_filename = self.builder.fmt("{}.dll", self.name);
1214 self.out_lib_filename = self.builder.fmt("{}.lib", self.name);
1230 self.out_filename = self.builder.fmt("{}.dll", .{self.name});
1231 self.out_lib_filename = self.builder.fmt("{}.lib", .{self.name});
12151232 } else {
1216 self.out_filename = self.builder.fmt("lib{}.so.{d}.{d}.{d}", self.name, self.version.major, self.version.minor, self.version.patch);
1217 self.major_only_filename = self.builder.fmt("lib{}.so.{d}", self.name, self.version.major);
1218 self.name_only_filename = self.builder.fmt("lib{}.so", self.name);
1233 self.out_filename = self.builder.fmt("lib{}.so.{d}.{d}.{d}", .{
1234 self.name,
1235 self.version.major,
1236 self.version.minor,
1237 self.version.patch,
1238 });
1239 self.major_only_filename = self.builder.fmt("lib{}.so.{d}", .{ self.name, self.version.major });
1240 self.name_only_filename = self.builder.fmt("lib{}.so", .{self.name});
12191241 self.out_lib_filename = self.out_filename;
12201242 }
12211243 }
......@@ -1268,7 +1290,7 @@ pub const LibExeObjStep = struct {
12681290 // It doesn't have to be native. We catch that if you actually try to run it.
12691291 // Consider that this is declarative; the run step may not be run unless a user
12701292 // option is supplied.
1271 const run_step = RunStep.create(exe.builder, exe.builder.fmt("run {}", exe.step.name));
1293 const run_step = RunStep.create(exe.builder, exe.builder.fmt("run {}", .{exe.step.name}));
12721294 run_step.addArtifactArg(exe);
12731295
12741296 if (exe.vcpkg_bin_path) |path| {
......@@ -1420,7 +1442,7 @@ pub const LibExeObjStep = struct {
14201442 } else if (mem.eql(u8, tok, "-pthread")) {
14211443 self.linkLibC();
14221444 } else if (self.builder.verbose) {
1423 warn("Ignoring pkg-config flag '{}'\n", tok);
1445 warn("Ignoring pkg-config flag '{}'\n", .{tok});
14241446 }
14251447 }
14261448 }
......@@ -1653,7 +1675,7 @@ pub const LibExeObjStep = struct {
16531675 const builder = self.builder;
16541676
16551677 if (self.root_src == null and self.link_objects.len == 0) {
1656 warn("{}: linker needs 1 or more objects to link\n", self.step.name);
1678 warn("{}: linker needs 1 or more objects to link\n", .{self.step.name});
16571679 return error.NeedAnObject;
16581680 }
16591681
......@@ -1725,7 +1747,7 @@ pub const LibExeObjStep = struct {
17251747 if (self.build_options_contents.len() > 0) {
17261748 const build_options_file = try fs.path.join(
17271749 builder.allocator,
1728 &[_][]const u8{ builder.cache_root, builder.fmt("{}_build_options.zig", self.name) },
1750 &[_][]const u8{ builder.cache_root, builder.fmt("{}_build_options.zig", .{self.name}) },
17291751 );
17301752 try std.io.writeFile(build_options_file, self.build_options_contents.toSliceConst());
17311753 try zig_args.append("--pkg-begin");
......@@ -1780,13 +1802,13 @@ pub const LibExeObjStep = struct {
17801802
17811803 if (self.kind == Kind.Lib and self.is_dynamic) {
17821804 zig_args.append("--ver-major") catch unreachable;
1783 zig_args.append(builder.fmt("{}", self.version.major)) catch unreachable;
1805 zig_args.append(builder.fmt("{}", .{self.version.major})) catch unreachable;
17841806
17851807 zig_args.append("--ver-minor") catch unreachable;
1786 zig_args.append(builder.fmt("{}", self.version.minor)) catch unreachable;
1808 zig_args.append(builder.fmt("{}", .{self.version.minor})) catch unreachable;
17871809
17881810 zig_args.append("--ver-patch") catch unreachable;
1789 zig_args.append(builder.fmt("{}", self.version.patch)) catch unreachable;
1811 zig_args.append(builder.fmt("{}", .{self.version.patch})) catch unreachable;
17901812 }
17911813 if (self.is_dynamic) {
17921814 try zig_args.append("-dynamic");
......@@ -1811,7 +1833,7 @@ pub const LibExeObjStep = struct {
18111833
18121834 if (self.target_glibc) |ver| {
18131835 try zig_args.append("-target-glibc");
1814 try zig_args.append(builder.fmt("{}.{}.{}", ver.major, ver.minor, ver.patch));
1836 try zig_args.append(builder.fmt("{}.{}.{}", .{ ver.major, ver.minor, ver.patch }));
18151837 }
18161838
18171839 if (self.linker_script) |linker_script| {
......@@ -2079,7 +2101,7 @@ pub const RunStep = struct {
20792101 }
20802102
20812103 if (prev_path) |pp| {
2082 const new_path = self.builder.fmt("{}" ++ [1]u8{fs.path.delimiter} ++ "{}", pp, search_path);
2104 const new_path = self.builder.fmt("{}" ++ [1]u8{fs.path.delimiter} ++ "{}", .{ pp, search_path });
20832105 env_map.set(key, new_path) catch unreachable;
20842106 } else {
20852107 env_map.set(key, search_path) catch unreachable;
......@@ -2153,7 +2175,7 @@ const InstallArtifactStep = struct {
21532175 const self = builder.allocator.create(Self) catch unreachable;
21542176 self.* = Self{
21552177 .builder = builder,
2156 .step = Step.init(builder.fmt("install {}", artifact.step.name), builder.allocator, make),
2178 .step = Step.init(builder.fmt("install {}", .{artifact.step.name}), builder.allocator, make),
21572179 .artifact = artifact,
21582180 .dest_dir = switch (artifact.kind) {
21592181 .Obj => unreachable,
......@@ -2219,7 +2241,7 @@ pub const InstallFileStep = struct {
22192241 builder.pushInstalledFile(dir, dest_rel_path);
22202242 return InstallFileStep{
22212243 .builder = builder,
2222 .step = Step.init(builder.fmt("install {}", src_path), builder.allocator, make),
2244 .step = Step.init(builder.fmt("install {}", .{src_path}), builder.allocator, make),
22232245 .src_path = src_path,
22242246 .dir = dir,
22252247 .dest_rel_path = dest_rel_path,
......@@ -2253,7 +2275,7 @@ pub const InstallDirStep = struct {
22532275 builder.pushInstalledFile(options.install_dir, options.install_subdir);
22542276 return InstallDirStep{
22552277 .builder = builder,
2256 .step = Step.init(builder.fmt("install {}/", options.source_dir), builder.allocator, make),
2278 .step = Step.init(builder.fmt("install {}/", .{options.source_dir}), builder.allocator, make),
22572279 .options = options,
22582280 };
22592281 }
......@@ -2290,7 +2312,7 @@ pub const WriteFileStep = struct {
22902312 pub fn init(builder: *Builder, file_path: []const u8, data: []const u8) WriteFileStep {
22912313 return WriteFileStep{
22922314 .builder = builder,
2293 .step = Step.init(builder.fmt("writefile {}", file_path), builder.allocator, make),
2315 .step = Step.init(builder.fmt("writefile {}", .{file_path}), builder.allocator, make),
22942316 .file_path = file_path,
22952317 .data = data,
22962318 };
......@@ -2301,11 +2323,11 @@ pub const WriteFileStep = struct {
23012323 const full_path = self.builder.pathFromRoot(self.file_path);
23022324 const full_path_dir = fs.path.dirname(full_path) orelse ".";
23032325 fs.makePath(self.builder.allocator, full_path_dir) catch |err| {
2304 warn("unable to make path {}: {}\n", full_path_dir, @errorName(err));
2326 warn("unable to make path {}: {}\n", .{ full_path_dir, @errorName(err) });
23052327 return err;
23062328 };
23072329 io.writeFile(full_path, self.data) catch |err| {
2308 warn("unable to write {}: {}\n", full_path, @errorName(err));
2330 warn("unable to write {}: {}\n", .{ full_path, @errorName(err) });
23092331 return err;
23102332 };
23112333 }
......@@ -2319,14 +2341,14 @@ pub const LogStep = struct {
23192341 pub fn init(builder: *Builder, data: []const u8) LogStep {
23202342 return LogStep{
23212343 .builder = builder,
2322 .step = Step.init(builder.fmt("log {}", data), builder.allocator, make),
2344 .step = Step.init(builder.fmt("log {}", .{data}), builder.allocator, make),
23232345 .data = data,
23242346 };
23252347 }
23262348
23272349 fn make(step: *Step) anyerror!void {
23282350 const self = @fieldParentPtr(LogStep, "step", step);
2329 warn("{}", self.data);
2351 warn("{}", .{self.data});
23302352 }
23312353};
23322354
......@@ -2338,7 +2360,7 @@ pub const RemoveDirStep = struct {
23382360 pub fn init(builder: *Builder, dir_path: []const u8) RemoveDirStep {
23392361 return RemoveDirStep{
23402362 .builder = builder,
2341 .step = Step.init(builder.fmt("RemoveDir {}", dir_path), builder.allocator, make),
2363 .step = Step.init(builder.fmt("RemoveDir {}", .{dir_path}), builder.allocator, make),
23422364 .dir_path = dir_path,
23432365 };
23442366 }
......@@ -2348,7 +2370,7 @@ pub const RemoveDirStep = struct {
23482370
23492371 const full_path = self.builder.pathFromRoot(self.dir_path);
23502372 fs.deleteTree(full_path) catch |err| {
2351 warn("Unable to remove {}: {}\n", full_path, @errorName(err));
2373 warn("Unable to remove {}: {}\n", .{ full_path, @errorName(err) });
23522374 return err;
23532375 };
23542376 }
......@@ -2397,7 +2419,7 @@ fn doAtomicSymLinks(allocator: *Allocator, output_path: []const u8, filename_maj
23972419 &[_][]const u8{ out_dir, filename_major_only },
23982420 ) catch unreachable;
23992421 fs.atomicSymLink(allocator, out_basename, major_only_path) catch |err| {
2400 warn("Unable to symlink {} -> {}\n", major_only_path, out_basename);
2422 warn("Unable to symlink {} -> {}\n", .{ major_only_path, out_basename });
24012423 return err;
24022424 };
24032425 // sym link for libfoo.so to libfoo.so.1
......@@ -2406,7 +2428,7 @@ fn doAtomicSymLinks(allocator: *Allocator, output_path: []const u8, filename_maj
24062428 &[_][]const u8{ out_dir, filename_name_only },
24072429 ) catch unreachable;
24082430 fs.atomicSymLink(allocator, filename_major_only, name_only_path) catch |err| {
2409 warn("Unable to symlink {} -> {}\n", name_only_path, filename_major_only);
2431 warn("Unable to symlink {} -> {}\n", .{ name_only_path, filename_major_only });
24102432 return err;
24112433 };
24122434}
lib/std/builtin.zig+2-2
......@@ -429,7 +429,7 @@ pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace) noreturn
429429 }
430430 },
431431 .wasi => {
432 std.debug.warn("{}", msg);
432 std.debug.warn("{}", .{msg});
433433 _ = std.os.wasi.proc_raise(std.os.wasi.SIGABRT);
434434 unreachable;
435435 },
......@@ -439,7 +439,7 @@ pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace) noreturn
439439 },
440440 else => {
441441 const first_trace_addr = @returnAddress();
442 std.debug.panicExtra(error_return_trace, first_trace_addr, "{}", msg);
442 std.debug.panicExtra(error_return_trace, first_trace_addr, "{}", .{msg});
443443 },
444444 }
445445}
lib/std/crypto/benchmark.zig+1-1
......@@ -114,7 +114,7 @@ fn usage() void {
114114 \\ --seed [int]
115115 \\ --help
116116 \\
117 );
117 , .{});
118118}
119119
120120fn mode(comptime x: comptime_int) comptime_int {
lib/std/debug.zig+56-43
......@@ -46,7 +46,7 @@ var stderr_file_out_stream: File.OutStream = undefined;
4646var stderr_stream: ?*io.OutStream(File.WriteError) = null;
4747var stderr_mutex = std.Mutex.init();
4848
49pub fn warn(comptime fmt: []const u8, args: ...) void {
49pub fn warn(comptime fmt: []const u8, args: var) void {
5050 const held = stderr_mutex.acquire();
5151 defer held.release();
5252 const stderr = getStderrStream();
......@@ -92,15 +92,15 @@ fn wantTtyColor() bool {
9292pub fn dumpCurrentStackTrace(start_addr: ?usize) void {
9393 const stderr = getStderrStream();
9494 if (builtin.strip_debug_info) {
95 stderr.print("Unable to dump stack trace: debug info stripped\n") catch return;
95 stderr.print("Unable to dump stack trace: debug info stripped\n", .{}) catch return;
9696 return;
9797 }
9898 const debug_info = getSelfDebugInfo() catch |err| {
99 stderr.print("Unable to dump stack trace: Unable to open debug info: {}\n", @errorName(err)) catch return;
99 stderr.print("Unable to dump stack trace: Unable to open debug info: {}\n", .{@errorName(err)}) catch return;
100100 return;
101101 };
102102 writeCurrentStackTrace(stderr, debug_info, wantTtyColor(), start_addr) catch |err| {
103 stderr.print("Unable to dump stack trace: {}\n", @errorName(err)) catch return;
103 stderr.print("Unable to dump stack trace: {}\n", .{@errorName(err)}) catch return;
104104 return;
105105 };
106106}
......@@ -111,11 +111,11 @@ pub fn dumpCurrentStackTrace(start_addr: ?usize) void {
111111pub fn dumpStackTraceFromBase(bp: usize, ip: usize) void {
112112 const stderr = getStderrStream();
113113 if (builtin.strip_debug_info) {
114 stderr.print("Unable to dump stack trace: debug info stripped\n") catch return;
114 stderr.print("Unable to dump stack trace: debug info stripped\n", .{}) catch return;
115115 return;
116116 }
117117 const debug_info = getSelfDebugInfo() catch |err| {
118 stderr.print("Unable to dump stack trace: Unable to open debug info: {}\n", @errorName(err)) catch return;
118 stderr.print("Unable to dump stack trace: Unable to open debug info: {}\n", .{@errorName(err)}) catch return;
119119 return;
120120 };
121121 const tty_color = wantTtyColor();
......@@ -184,15 +184,15 @@ pub fn captureStackTrace(first_address: ?usize, stack_trace: *builtin.StackTrace
184184pub fn dumpStackTrace(stack_trace: builtin.StackTrace) void {
185185 const stderr = getStderrStream();
186186 if (builtin.strip_debug_info) {
187 stderr.print("Unable to dump stack trace: debug info stripped\n") catch return;
187 stderr.print("Unable to dump stack trace: debug info stripped\n", .{}) catch return;
188188 return;
189189 }
190190 const debug_info = getSelfDebugInfo() catch |err| {
191 stderr.print("Unable to dump stack trace: Unable to open debug info: {}\n", @errorName(err)) catch return;
191 stderr.print("Unable to dump stack trace: Unable to open debug info: {}\n", .{@errorName(err)}) catch return;
192192 return;
193193 };
194194 writeStackTrace(stack_trace, stderr, getDebugInfoAllocator(), debug_info, wantTtyColor()) catch |err| {
195 stderr.print("Unable to dump stack trace: {}\n", @errorName(err)) catch return;
195 stderr.print("Unable to dump stack trace: {}\n", .{@errorName(err)}) catch return;
196196 return;
197197 };
198198}
......@@ -211,7 +211,7 @@ pub fn assert(ok: bool) void {
211211 if (!ok) unreachable; // assertion failure
212212}
213213
214pub fn panic(comptime format: []const u8, args: ...) noreturn {
214pub fn panic(comptime format: []const u8, args: var) noreturn {
215215 @setCold(true);
216216 // TODO: remove conditional once wasi / LLVM defines __builtin_return_address
217217 const first_trace_addr = if (builtin.os == .wasi) null else @returnAddress();
......@@ -221,7 +221,7 @@ pub fn panic(comptime format: []const u8, args: ...) noreturn {
221221/// TODO multithreaded awareness
222222var panicking: u8 = 0; // TODO make this a bool
223223
224pub fn panicExtra(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, comptime format: []const u8, args: ...) noreturn {
224pub fn panicExtra(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, comptime format: []const u8, args: var) noreturn {
225225 @setCold(true);
226226
227227 if (enable_segfault_handler) {
......@@ -376,13 +376,13 @@ fn printSourceAtAddressWindows(di: *DebugInfo, out_stream: var, relocated_addres
376376 } else {
377377 // we have no information to add to the address
378378 if (tty_color) {
379 try out_stream.print("???:?:?: ");
379 try out_stream.print("???:?:?: ", .{});
380380 setTtyColor(TtyColor.Dim);
381 try out_stream.print("0x{x} in ??? (???)", relocated_address);
381 try out_stream.print("0x{x} in ??? (???)", .{relocated_address});
382382 setTtyColor(TtyColor.Reset);
383 try out_stream.print("\n\n\n");
383 try out_stream.print("\n\n\n", .{});
384384 } else {
385 try out_stream.print("???:?:?: 0x{x} in ??? (???)\n\n\n", relocated_address);
385 try out_stream.print("???:?:?: 0x{x} in ??? (???)\n\n\n", .{relocated_address});
386386 }
387387 return;
388388 };
......@@ -509,18 +509,18 @@ fn printSourceAtAddressWindows(di: *DebugInfo, out_stream: var, relocated_addres
509509 if (tty_color) {
510510 setTtyColor(TtyColor.White);
511511 if (opt_line_info) |li| {
512 try out_stream.print("{}:{}:{}", li.file_name, li.line, li.column);
512 try out_stream.print("{}:{}:{}", .{ li.file_name, li.line, li.column });
513513 } else {
514 try out_stream.print("???:?:?");
514 try out_stream.print("???:?:?", .{});
515515 }
516516 setTtyColor(TtyColor.Reset);
517 try out_stream.print(": ");
517 try out_stream.print(": ", .{});
518518 setTtyColor(TtyColor.Dim);
519 try out_stream.print("0x{x} in {} ({})", relocated_address, symbol_name, obj_basename);
519 try out_stream.print("0x{x} in {} ({})", .{ relocated_address, symbol_name, obj_basename });
520520 setTtyColor(TtyColor.Reset);
521521
522522 if (opt_line_info) |line_info| {
523 try out_stream.print("\n");
523 try out_stream.print("\n", .{});
524524 if (printLineFromFileAnyOs(out_stream, line_info)) {
525525 if (line_info.column == 0) {
526526 try out_stream.write("\n");
......@@ -546,13 +546,24 @@ fn printSourceAtAddressWindows(di: *DebugInfo, out_stream: var, relocated_addres
546546 else => return err,
547547 }
548548 } else {
549 try out_stream.print("\n\n\n");
549 try out_stream.print("\n\n\n", .{});
550550 }
551551 } else {
552552 if (opt_line_info) |li| {
553 try out_stream.print("{}:{}:{}: 0x{x} in {} ({})\n\n\n", li.file_name, li.line, li.column, relocated_address, symbol_name, obj_basename);
553 try out_stream.print("{}:{}:{}: 0x{x} in {} ({})\n\n\n", .{
554 li.file_name,
555 li.line,
556 li.column,
557 relocated_address,
558 symbol_name,
559 obj_basename,
560 });
554561 } else {
555 try out_stream.print("???:?:?: 0x{x} in {} ({})\n\n\n", relocated_address, symbol_name, obj_basename);
562 try out_stream.print("???:?:?: 0x{x} in {} ({})\n\n\n", .{
563 relocated_address,
564 symbol_name,
565 obj_basename,
566 });
556567 }
557568 }
558569}
......@@ -697,9 +708,9 @@ fn printSourceAtAddressMacOs(di: *DebugInfo, out_stream: var, address: usize, tt
697708
698709 const symbol = machoSearchSymbols(di.symbols, adjusted_addr) orelse {
699710 if (tty_color) {
700 try out_stream.print("???:?:?: " ++ DIM ++ "0x{x} in ??? (???)" ++ RESET ++ "\n\n\n", address);
711 try out_stream.print("???:?:?: " ++ DIM ++ "0x{x} in ??? (???)" ++ RESET ++ "\n\n\n", .{address});
701712 } else {
702 try out_stream.print("???:?:?: 0x{x} in ??? (???)\n\n\n", address);
713 try out_stream.print("???:?:?: 0x{x} in ??? (???)\n\n\n", .{address});
703714 }
704715 return;
705716 };
......@@ -723,9 +734,11 @@ fn printSourceAtAddressMacOs(di: *DebugInfo, out_stream: var, address: usize, tt
723734 } else |err| switch (err) {
724735 error.MissingDebugInfo, error.InvalidDebugInfo => {
725736 if (tty_color) {
726 try out_stream.print("???:?:?: " ++ DIM ++ "0x{x} in {} ({})" ++ RESET ++ "\n\n\n", address, symbol_name, compile_unit_name);
737 try out_stream.print("???:?:?: " ++ DIM ++ "0x{x} in {} ({})" ++ RESET ++ "\n\n\n", .{
738 address, symbol_name, compile_unit_name,
739 });
727740 } else {
728 try out_stream.print("???:?:?: 0x{x} in {} ({})\n\n\n", address, symbol_name, compile_unit_name);
741 try out_stream.print("???:?:?: 0x{x} in {} ({})\n\n\n", .{ address, symbol_name, compile_unit_name });
729742 }
730743 },
731744 else => return err,
......@@ -746,15 +759,14 @@ fn printLineInfo(
746759 comptime printLineFromFile: var,
747760) !void {
748761 if (tty_color) {
749 try out_stream.print(
750 WHITE ++ "{}:{}:{}" ++ RESET ++ ": " ++ DIM ++ "0x{x} in {} ({})" ++ RESET ++ "\n",
762 try out_stream.print(WHITE ++ "{}:{}:{}" ++ RESET ++ ": " ++ DIM ++ "0x{x} in {} ({})" ++ RESET ++ "\n", .{
751763 line_info.file_name,
752764 line_info.line,
753765 line_info.column,
754766 address,
755767 symbol_name,
756768 compile_unit_name,
757 );
769 });
758770 if (printLineFromFile(out_stream, line_info)) {
759771 if (line_info.column == 0) {
760772 try out_stream.write("\n");
......@@ -772,15 +784,14 @@ fn printLineInfo(
772784 else => return err,
773785 }
774786 } else {
775 try out_stream.print(
776 "{}:{}:{}: 0x{x} in {} ({})\n",
787 try out_stream.print("{}:{}:{}: 0x{x} in {} ({})\n", .{
777788 line_info.file_name,
778789 line_info.line,
779790 line_info.column,
780791 address,
781792 symbol_name,
782793 compile_unit_name,
783 );
794 });
784795 }
785796}
786797
......@@ -1226,9 +1237,9 @@ pub const DwarfInfo = struct {
12261237 ) !void {
12271238 const compile_unit = self.findCompileUnit(address) catch {
12281239 if (tty_color) {
1229 try out_stream.print("???:?:?: " ++ DIM ++ "0x{x} in ??? (???)" ++ RESET ++ "\n\n\n", address);
1240 try out_stream.print("???:?:?: " ++ DIM ++ "0x{x} in ??? (???)" ++ RESET ++ "\n\n\n", .{address});
12301241 } else {
1231 try out_stream.print("???:?:?: 0x{x} in ??? (???)\n\n\n", address);
1242 try out_stream.print("???:?:?: 0x{x} in ??? (???)\n\n\n", .{address});
12321243 }
12331244 return;
12341245 };
......@@ -1248,9 +1259,11 @@ pub const DwarfInfo = struct {
12481259 } else |err| switch (err) {
12491260 error.MissingDebugInfo, error.InvalidDebugInfo => {
12501261 if (tty_color) {
1251 try out_stream.print("???:?:?: " ++ DIM ++ "0x{x} in ??? ({})" ++ RESET ++ "\n\n\n", address, compile_unit_name);
1262 try out_stream.print("???:?:?: " ++ DIM ++ "0x{x} in ??? ({})" ++ RESET ++ "\n\n\n", .{
1263 address, compile_unit_name,
1264 });
12521265 } else {
1253 try out_stream.print("???:?:?: 0x{x} in ??? ({})\n\n\n", address, compile_unit_name);
1266 try out_stream.print("???:?:?: 0x{x} in ??? ({})\n\n\n", .{ address, compile_unit_name });
12541267 }
12551268 },
12561269 else => return err,
......@@ -2416,7 +2429,7 @@ extern fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: *con
24162429 resetSegfaultHandler();
24172430
24182431 const addr = @ptrToInt(info.fields.sigfault.addr);
2419 std.debug.warn("Segmentation fault at address 0x{x}\n", addr);
2432 std.debug.warn("Segmentation fault at address 0x{x}\n", .{addr});
24202433
24212434 switch (builtin.arch) {
24222435 .i386 => {
......@@ -2456,10 +2469,10 @@ extern fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: *con
24562469stdcallcc fn handleSegfaultWindows(info: *windows.EXCEPTION_POINTERS) c_long {
24572470 const exception_address = @ptrToInt(info.ExceptionRecord.ExceptionAddress);
24582471 switch (info.ExceptionRecord.ExceptionCode) {
2459 windows.EXCEPTION_DATATYPE_MISALIGNMENT => panicExtra(null, exception_address, "Unaligned Memory Access"),
2460 windows.EXCEPTION_ACCESS_VIOLATION => panicExtra(null, exception_address, "Segmentation fault at address 0x{x}", info.ExceptionRecord.ExceptionInformation[1]),
2461 windows.EXCEPTION_ILLEGAL_INSTRUCTION => panicExtra(null, exception_address, "Illegal Instruction"),
2462 windows.EXCEPTION_STACK_OVERFLOW => panicExtra(null, exception_address, "Stack Overflow"),
2472 windows.EXCEPTION_DATATYPE_MISALIGNMENT => panicExtra(null, exception_address, "Unaligned Memory Access", .{}),
2473 windows.EXCEPTION_ACCESS_VIOLATION => panicExtra(null, exception_address, "Segmentation fault at address 0x{x}", .{info.ExceptionRecord.ExceptionInformation[1]}),
2474 windows.EXCEPTION_ILLEGAL_INSTRUCTION => panicExtra(null, exception_address, "Illegal Instruction", .{}),
2475 windows.EXCEPTION_STACK_OVERFLOW => panicExtra(null, exception_address, "Stack Overflow", .{}),
24632476 else => return windows.EXCEPTION_CONTINUE_SEARCH,
24642477 }
24652478}
......@@ -2468,7 +2481,7 @@ pub fn dumpStackPointerAddr(prefix: []const u8) void {
24682481 const sp = asm (""
24692482 : [argc] "={rsp}" (-> usize)
24702483 );
2471 std.debug.warn("{} sp = 0x{x}\n", prefix, sp);
2484 std.debug.warn("{} sp = 0x{x}\n", .{ prefix, sp });
24722485}
24732486
24742487// Reference everything so it gets tested.
lib/std/event/channel.zig+2-2
......@@ -294,14 +294,14 @@ test "std.event.Channel wraparound" {
294294
295295 const channel_size = 2;
296296
297 var buf : [channel_size]i32 = undefined;
297 var buf: [channel_size]i32 = undefined;
298298 var channel: Channel(i32) = undefined;
299299 channel.init(&buf);
300300 defer channel.deinit();
301301
302302 // add items to channel and pull them out until
303303 // the buffer wraps around, make sure it doesn't crash.
304 var result : i32 = undefined;
304 var result: i32 = undefined;
305305 channel.put(5);
306306 testing.expectEqual(@as(i32, 5), channel.get());
307307 channel.put(6);
lib/std/fifo.zig+2-2
......@@ -293,7 +293,7 @@ pub fn LinearFifo(
293293
294294 pub usingnamespace if (T == u8)
295295 struct {
296 pub fn print(self: *Self, comptime format: []const u8, args: ...) !void {
296 pub fn print(self: *Self, comptime format: []const u8, args: var) !void {
297297 return std.fmt.format(self, error{OutOfMemory}, Self.write, format, args);
298298 }
299299 }
......@@ -407,7 +407,7 @@ test "LinearFifo(u8, .Dynamic)" {
407407 fifo.shrink(0);
408408
409409 {
410 try fifo.print("{}, {}!", "Hello", "World");
410 try fifo.print("{}, {}!", .{ "Hello", "World" });
411411 var result: [30]u8 = undefined;
412412 testing.expectEqualSlices(u8, "Hello, World!", result[0..fifo.read(&result)]);
413413 testing.expectEqual(@as(usize, 0), fifo.readableLength());
lib/std/fmt.zig+111-109
......@@ -91,10 +91,12 @@ pub fn format(
9191 comptime Errors: type,
9292 output: fn (@typeOf(context), []const u8) Errors!void,
9393 comptime fmt: []const u8,
94 args: ...,
94 args: var,
9595) Errors!void {
9696 const ArgSetType = @IntType(false, 32);
97 if (args.len > ArgSetType.bit_count) {
97 const args_fields = std.meta.fields(@typeOf(args));
98 const args_len = args_fields.len;
99 if (args_len > ArgSetType.bit_count) {
98100 @compileError("32 arguments max are supported per format call");
99101 }
100102
......@@ -158,14 +160,14 @@ pub fn format(
158160 maybe_pos_arg.? += c - '0';
159161 specifier_start = i + 1;
160162
161 if (maybe_pos_arg.? >= args.len) {
163 if (maybe_pos_arg.? >= args_len) {
162164 @compileError("Positional value refers to non-existent argument");
163165 }
164166 },
165167 '}' => {
166168 const arg_to_print = comptime nextArg(&used_pos_args, maybe_pos_arg, &next_arg);
167169
168 if (arg_to_print >= args.len) {
170 if (arg_to_print >= args_len) {
169171 @compileError("Too few arguments");
170172 }
171173
......@@ -302,7 +304,7 @@ pub fn format(
302304 used_pos_args |= 1 << i;
303305 }
304306
305 if (@popCount(ArgSetType, used_pos_args) != args.len) {
307 if (@popCount(ArgSetType, used_pos_args) != args_len) {
306308 @compileError("Unused arguments");
307309 }
308310 if (state != State.Start) {
......@@ -389,7 +391,7 @@ pub fn formatType(
389391 }
390392 try output(context, " }");
391393 } else {
392 try format(context, Errors, output, "@{x}", @ptrToInt(&value));
394 try format(context, Errors, output, "@{x}", .{@ptrToInt(&value)});
393395 }
394396 },
395397 .Struct => {
......@@ -421,12 +423,12 @@ pub fn formatType(
421423 if (info.child == u8) {
422424 return formatText(value, fmt, options, context, Errors, output);
423425 }
424 return format(context, Errors, output, "{}@{x}", @typeName(T.Child), @ptrToInt(value));
426 return format(context, Errors, output, "{}@{x}", .{ @typeName(T.Child), @ptrToInt(value) });
425427 },
426428 builtin.TypeId.Enum, builtin.TypeId.Union, builtin.TypeId.Struct => {
427429 return formatType(value.*, fmt, options, context, Errors, output, max_depth);
428430 },
429 else => return format(context, Errors, output, "{}@{x}", @typeName(T.Child), @ptrToInt(value)),
431 else => return format(context, Errors, output, "{}@{x}", .{ @typeName(T.Child), @ptrToInt(value) }),
430432 },
431433 .Many => {
432434 if (ptr_info.child == u8) {
......@@ -435,7 +437,7 @@ pub fn formatType(
435437 return formatText(value[0..len], fmt, options, context, Errors, output);
436438 }
437439 }
438 return format(context, Errors, output, "{}@{x}", @typeName(T.Child), @ptrToInt(value));
440 return format(context, Errors, output, "{}@{x}", .{ @typeName(T.Child), @ptrToInt(value) });
439441 },
440442 .Slice => {
441443 if (fmt.len > 0 and ((fmt[0] == 'x') or (fmt[0] == 'X'))) {
......@@ -444,10 +446,10 @@ pub fn formatType(
444446 if (ptr_info.child == u8) {
445447 return formatText(value, fmt, options, context, Errors, output);
446448 }
447 return format(context, Errors, output, "{}@{x}", @typeName(ptr_info.child), @ptrToInt(value.ptr));
449 return format(context, Errors, output, "{}@{x}", .{ @typeName(ptr_info.child), @ptrToInt(value.ptr) });
448450 },
449451 .C => {
450 return format(context, Errors, output, "{}@{x}", @typeName(T.Child), @ptrToInt(value));
452 return format(context, Errors, output, "{}@{x}", .{ @typeName(T.Child), @ptrToInt(value) });
451453 },
452454 },
453455 .Array => |info| {
......@@ -465,7 +467,7 @@ pub fn formatType(
465467 return formatType(@as(Slice, &value), fmt, options, context, Errors, output, max_depth);
466468 },
467469 .Fn => {
468 return format(context, Errors, output, "{}@{x}", @typeName(T), @ptrToInt(value));
470 return format(context, Errors, output, "{}@{x}", .{ @typeName(T), @ptrToInt(value) });
469471 },
470472 else => @compileError("Unable to format type '" ++ @typeName(T) ++ "'"),
471473 }
......@@ -1113,7 +1115,7 @@ pub const BufPrintError = error{
11131115 /// As much as possible was written to the buffer, but it was too small to fit all the printed bytes.
11141116 BufferTooSmall,
11151117};
1116pub fn bufPrint(buf: []u8, comptime fmt: []const u8, args: ...) BufPrintError![]u8 {
1118pub fn bufPrint(buf: []u8, comptime fmt: []const u8, args: var) BufPrintError![]u8 {
11171119 var context = BufPrintContext{ .remaining = buf };
11181120 try format(&context, BufPrintError, bufPrintWrite, fmt, args);
11191121 return buf[0 .. buf.len - context.remaining.len];
......@@ -1121,7 +1123,7 @@ pub fn bufPrint(buf: []u8, comptime fmt: []const u8, args: ...) BufPrintError![]
11211123
11221124pub const AllocPrintError = error{OutOfMemory};
11231125
1124pub fn allocPrint(allocator: *mem.Allocator, comptime fmt: []const u8, args: ...) AllocPrintError![]u8 {
1126pub fn allocPrint(allocator: *mem.Allocator, comptime fmt: []const u8, args: var) AllocPrintError![]u8 {
11251127 var size: usize = 0;
11261128 format(&size, error{}, countSize, fmt, args) catch |err| switch (err) {};
11271129 const buf = try allocator.alloc(u8, size);
......@@ -1173,46 +1175,46 @@ test "parse unsigned comptime" {
11731175test "optional" {
11741176 {
11751177 const value: ?i32 = 1234;
1176 try testFmt("optional: 1234\n", "optional: {}\n", value);
1178 try testFmt("optional: 1234\n", "optional: {}\n", .{value});
11771179 }
11781180 {
11791181 const value: ?i32 = null;
1180 try testFmt("optional: null\n", "optional: {}\n", value);
1182 try testFmt("optional: null\n", "optional: {}\n", .{value});
11811183 }
11821184}
11831185
11841186test "error" {
11851187 {
11861188 const value: anyerror!i32 = 1234;
1187 try testFmt("error union: 1234\n", "error union: {}\n", value);
1189 try testFmt("error union: 1234\n", "error union: {}\n", .{value});
11881190 }
11891191 {
11901192 const value: anyerror!i32 = error.InvalidChar;
1191 try testFmt("error union: error.InvalidChar\n", "error union: {}\n", value);
1193 try testFmt("error union: error.InvalidChar\n", "error union: {}\n", .{value});
11921194 }
11931195}
11941196
11951197test "int.small" {
11961198 {
11971199 const value: u3 = 0b101;
1198 try testFmt("u3: 5\n", "u3: {}\n", value);
1200 try testFmt("u3: 5\n", "u3: {}\n", .{value});
11991201 }
12001202}
12011203
12021204test "int.specifier" {
12031205 {
12041206 const value: u8 = 'a';
1205 try testFmt("u8: a\n", "u8: {c}\n", value);
1207 try testFmt("u8: a\n", "u8: {c}\n", .{value});
12061208 }
12071209 {
12081210 const value: u8 = 0b1100;
1209 try testFmt("u8: 0b1100\n", "u8: 0b{b}\n", value);
1211 try testFmt("u8: 0b1100\n", "u8: 0b{b}\n", .{value});
12101212 }
12111213}
12121214
12131215test "int.padded" {
1214 try testFmt("u8: ' 1'", "u8: '{:4}'", @as(u8, 1));
1215 try testFmt("u8: 'xxx1'", "u8: '{:x<4}'", @as(u8, 1));
1216 try testFmt("u8: ' 1'", "u8: '{:4}'", .{@as(u8, 1)});
1217 try testFmt("u8: 'xxx1'", "u8: '{:x<4}'", .{@as(u8, 1)});
12161218}
12171219
12181220test "buffer" {
......@@ -1238,14 +1240,14 @@ test "buffer" {
12381240test "array" {
12391241 {
12401242 const value: [3]u8 = "abc".*;
1241 try testFmt("array: abc\n", "array: {}\n", value);
1242 try testFmt("array: abc\n", "array: {}\n", &value);
1243 try testFmt("array: abc\n", "array: {}\n", .{value});
1244 try testFmt("array: abc\n", "array: {}\n", .{&value});
12431245
12441246 var buf: [100]u8 = undefined;
12451247 try testFmt(
1246 try bufPrint(buf[0..], "array: [3]u8@{x}\n", @ptrToInt(&value)),
1248 try bufPrint(buf[0..], "array: [3]u8@{x}\n", .{@ptrToInt(&value)}),
12471249 "array: {*}\n",
1248 &value,
1250 .{&value},
12491251 );
12501252 }
12511253}
......@@ -1253,36 +1255,36 @@ test "array" {
12531255test "slice" {
12541256 {
12551257 const value: []const u8 = "abc";
1256 try testFmt("slice: abc\n", "slice: {}\n", value);
1258 try testFmt("slice: abc\n", "slice: {}\n", .{value});
12571259 }
12581260 {
12591261 const value = @intToPtr([*]const []const u8, 0xdeadbeef)[0..0];
1260 try testFmt("slice: []const u8@deadbeef\n", "slice: {}\n", value);
1262 try testFmt("slice: []const u8@deadbeef\n", "slice: {}\n", .{value});
12611263 }
12621264
1263 try testFmt("buf: Test \n", "buf: {s:5}\n", "Test");
1264 try testFmt("buf: Test\n Other text", "buf: {s}\n Other text", "Test");
1265 try testFmt("buf: Test \n", "buf: {s:5}\n", .{"Test"});
1266 try testFmt("buf: Test\n Other text", "buf: {s}\n Other text", .{"Test"});
12651267}
12661268
12671269test "pointer" {
12681270 {
12691271 const value = @intToPtr(*i32, 0xdeadbeef);
1270 try testFmt("pointer: i32@deadbeef\n", "pointer: {}\n", value);
1271 try testFmt("pointer: i32@deadbeef\n", "pointer: {*}\n", value);
1272 try testFmt("pointer: i32@deadbeef\n", "pointer: {}\n", .{value});
1273 try testFmt("pointer: i32@deadbeef\n", "pointer: {*}\n", .{value});
12721274 }
12731275 {
12741276 const value = @intToPtr(fn () void, 0xdeadbeef);
1275 try testFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", value);
1277 try testFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", .{value});
12761278 }
12771279 {
12781280 const value = @intToPtr(fn () void, 0xdeadbeef);
1279 try testFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", value);
1281 try testFmt("pointer: fn() void@deadbeef\n", "pointer: {}\n", .{value});
12801282 }
12811283}
12821284
12831285test "cstr" {
1284 try testFmt("cstr: Test C\n", "cstr: {s}\n", "Test C");
1285 try testFmt("cstr: Test C \n", "cstr: {s:10}\n", "Test C");
1286 try testFmt("cstr: Test C\n", "cstr: {s}\n", .{"Test C"});
1287 try testFmt("cstr: Test C \n", "cstr: {s:10}\n", .{"Test C"});
12861288}
12871289
12881290test "filesize" {
......@@ -1290,8 +1292,8 @@ test "filesize" {
12901292 // TODO https://github.com/ziglang/zig/issues/3289
12911293 return error.SkipZigTest;
12921294 }
1293 try testFmt("file size: 63MiB\n", "file size: {Bi}\n", @as(usize, 63 * 1024 * 1024));
1294 try testFmt("file size: 66.06MB\n", "file size: {B:.2}\n", @as(usize, 63 * 1024 * 1024));
1295 try testFmt("file size: 63MiB\n", "file size: {Bi}\n", .{@as(usize, 63 * 1024 * 1024)});
1296 try testFmt("file size: 66.06MB\n", "file size: {B:.2}\n", .{@as(usize, 63 * 1024 * 1024)});
12951297}
12961298
12971299test "struct" {
......@@ -1300,8 +1302,8 @@ test "struct" {
13001302 field: u8,
13011303 };
13021304 const value = Struct{ .field = 42 };
1303 try testFmt("struct: Struct{ .field = 42 }\n", "struct: {}\n", value);
1304 try testFmt("struct: Struct{ .field = 42 }\n", "struct: {}\n", &value);
1305 try testFmt("struct: Struct{ .field = 42 }\n", "struct: {}\n", .{value});
1306 try testFmt("struct: Struct{ .field = 42 }\n", "struct: {}\n", .{&value});
13051307 }
13061308 {
13071309 const Struct = struct {
......@@ -1309,7 +1311,7 @@ test "struct" {
13091311 b: u1,
13101312 };
13111313 const value = Struct{ .a = 0, .b = 1 };
1312 try testFmt("struct: Struct{ .a = 0, .b = 1 }\n", "struct: {}\n", value);
1314 try testFmt("struct: Struct{ .a = 0, .b = 1 }\n", "struct: {}\n", .{value});
13131315 }
13141316}
13151317
......@@ -1319,8 +1321,8 @@ test "enum" {
13191321 Two,
13201322 };
13211323 const value = Enum.Two;
1322 try testFmt("enum: Enum.Two\n", "enum: {}\n", value);
1323 try testFmt("enum: Enum.Two\n", "enum: {}\n", &value);
1324 try testFmt("enum: Enum.Two\n", "enum: {}\n", .{value});
1325 try testFmt("enum: Enum.Two\n", "enum: {}\n", .{&value});
13241326}
13251327
13261328test "float.scientific" {
......@@ -1328,10 +1330,10 @@ test "float.scientific" {
13281330 // TODO https://github.com/ziglang/zig/issues/3289
13291331 return error.SkipZigTest;
13301332 }
1331 try testFmt("f32: 1.34000003e+00", "f32: {e}", @as(f32, 1.34));
1332 try testFmt("f32: 1.23400001e+01", "f32: {e}", @as(f32, 12.34));
1333 try testFmt("f64: -1.234e+11", "f64: {e}", @as(f64, -12.34e10));
1334 try testFmt("f64: 9.99996e-40", "f64: {e}", @as(f64, 9.999960e-40));
1333 try testFmt("f32: 1.34000003e+00", "f32: {e}", .{@as(f32, 1.34)});
1334 try testFmt("f32: 1.23400001e+01", "f32: {e}", .{@as(f32, 12.34)});
1335 try testFmt("f64: -1.234e+11", "f64: {e}", .{@as(f64, -12.34e10)});
1336 try testFmt("f64: 9.99996e-40", "f64: {e}", .{@as(f64, 9.999960e-40)});
13351337}
13361338
13371339test "float.scientific.precision" {
......@@ -1339,12 +1341,12 @@ test "float.scientific.precision" {
13391341 // TODO https://github.com/ziglang/zig/issues/3289
13401342 return error.SkipZigTest;
13411343 }
1342 try testFmt("f64: 1.40971e-42", "f64: {e:.5}", @as(f64, 1.409706e-42));
1343 try testFmt("f64: 1.00000e-09", "f64: {e:.5}", @as(f64, @bitCast(f32, @as(u32, 814313563))));
1344 try testFmt("f64: 7.81250e-03", "f64: {e:.5}", @as(f64, @bitCast(f32, @as(u32, 1006632960))));
1344 try testFmt("f64: 1.40971e-42", "f64: {e:.5}", .{@as(f64, 1.409706e-42)});
1345 try testFmt("f64: 1.00000e-09", "f64: {e:.5}", .{@as(f64, @bitCast(f32, @as(u32, 814313563)))});
1346 try testFmt("f64: 7.81250e-03", "f64: {e:.5}", .{@as(f64, @bitCast(f32, @as(u32, 1006632960)))});
13451347 // libc rounds 1.000005e+05 to 1.00000e+05 but zig does 1.00001e+05.
13461348 // In fact, libc doesn't round a lot of 5 cases up when one past the precision point.
1347 try testFmt("f64: 1.00001e+05", "f64: {e:.5}", @as(f64, @bitCast(f32, @as(u32, 1203982400))));
1349 try testFmt("f64: 1.00001e+05", "f64: {e:.5}", .{@as(f64, @bitCast(f32, @as(u32, 1203982400)))});
13481350}
13491351
13501352test "float.special" {
......@@ -1352,14 +1354,14 @@ test "float.special" {
13521354 // TODO https://github.com/ziglang/zig/issues/3289
13531355 return error.SkipZigTest;
13541356 }
1355 try testFmt("f64: nan", "f64: {}", math.nan_f64);
1357 try testFmt("f64: nan", "f64: {}", .{math.nan_f64});
13561358 // negative nan is not defined by IEE 754,
13571359 // and ARM thus normalizes it to positive nan
13581360 if (builtin.arch != builtin.Arch.arm) {
1359 try testFmt("f64: -nan", "f64: {}", -math.nan_f64);
1361 try testFmt("f64: -nan", "f64: {}", .{-math.nan_f64});
13601362 }
1361 try testFmt("f64: inf", "f64: {}", math.inf_f64);
1362 try testFmt("f64: -inf", "f64: {}", -math.inf_f64);
1363 try testFmt("f64: inf", "f64: {}", .{math.inf_f64});
1364 try testFmt("f64: -inf", "f64: {}", .{-math.inf_f64});
13631365}
13641366
13651367test "float.decimal" {
......@@ -1367,21 +1369,21 @@ test "float.decimal" {
13671369 // TODO https://github.com/ziglang/zig/issues/3289
13681370 return error.SkipZigTest;
13691371 }
1370 try testFmt("f64: 152314000000000000000000000000", "f64: {d}", @as(f64, 1.52314e+29));
1371 try testFmt("f32: 1.1", "f32: {d:.1}", @as(f32, 1.1234));
1372 try testFmt("f32: 1234.57", "f32: {d:.2}", @as(f32, 1234.567));
1372 try testFmt("f64: 152314000000000000000000000000", "f64: {d}", .{@as(f64, 1.52314e+29)});
1373 try testFmt("f32: 1.1", "f32: {d:.1}", .{@as(f32, 1.1234)});
1374 try testFmt("f32: 1234.57", "f32: {d:.2}", .{@as(f32, 1234.567)});
13731375 // -11.1234 is converted to f64 -11.12339... internally (errol3() function takes f64).
13741376 // -11.12339... is rounded back up to -11.1234
1375 try testFmt("f32: -11.1234", "f32: {d:.4}", @as(f32, -11.1234));
1376 try testFmt("f32: 91.12345", "f32: {d:.5}", @as(f32, 91.12345));
1377 try testFmt("f64: 91.1234567890", "f64: {d:.10}", @as(f64, 91.12345678901235));
1378 try testFmt("f64: 0.00000", "f64: {d:.5}", @as(f64, 0.0));
1379 try testFmt("f64: 6", "f64: {d:.0}", @as(f64, 5.700));
1380 try testFmt("f64: 10.0", "f64: {d:.1}", @as(f64, 9.999));
1381 try testFmt("f64: 1.000", "f64: {d:.3}", @as(f64, 1.0));
1382 try testFmt("f64: 0.00030000", "f64: {d:.8}", @as(f64, 0.0003));
1383 try testFmt("f64: 0.00000", "f64: {d:.5}", @as(f64, 1.40130e-45));
1384 try testFmt("f64: 0.00000", "f64: {d:.5}", @as(f64, 9.999960e-40));
1377 try testFmt("f32: -11.1234", "f32: {d:.4}", .{@as(f32, -11.1234)});
1378 try testFmt("f32: 91.12345", "f32: {d:.5}", .{@as(f32, 91.12345)});
1379 try testFmt("f64: 91.1234567890", "f64: {d:.10}", .{@as(f64, 91.12345678901235)});
1380 try testFmt("f64: 0.00000", "f64: {d:.5}", .{@as(f64, 0.0)});
1381 try testFmt("f64: 6", "f64: {d:.0}", .{@as(f64, 5.700)});
1382 try testFmt("f64: 10.0", "f64: {d:.1}", .{@as(f64, 9.999)});
1383 try testFmt("f64: 1.000", "f64: {d:.3}", .{@as(f64, 1.0)});
1384 try testFmt("f64: 0.00030000", "f64: {d:.8}", .{@as(f64, 0.0003)});
1385 try testFmt("f64: 0.00000", "f64: {d:.5}", .{@as(f64, 1.40130e-45)});
1386 try testFmt("f64: 0.00000", "f64: {d:.5}", .{@as(f64, 9.999960e-40)});
13851387}
13861388
13871389test "float.libc.sanity" {
......@@ -1389,22 +1391,22 @@ test "float.libc.sanity" {
13891391 // TODO https://github.com/ziglang/zig/issues/3289
13901392 return error.SkipZigTest;
13911393 }
1392 try testFmt("f64: 0.00001", "f64: {d:.5}", @as(f64, @bitCast(f32, @as(u32, 916964781))));
1393 try testFmt("f64: 0.00001", "f64: {d:.5}", @as(f64, @bitCast(f32, @as(u32, 925353389))));
1394 try testFmt("f64: 0.10000", "f64: {d:.5}", @as(f64, @bitCast(f32, @as(u32, 1036831278))));
1395 try testFmt("f64: 1.00000", "f64: {d:.5}", @as(f64, @bitCast(f32, @as(u32, 1065353133))));
1396 try testFmt("f64: 10.00000", "f64: {d:.5}", @as(f64, @bitCast(f32, @as(u32, 1092616192))));
1394 try testFmt("f64: 0.00001", "f64: {d:.5}", .{@as(f64, @bitCast(f32, @as(u32, 916964781)))});
1395 try testFmt("f64: 0.00001", "f64: {d:.5}", .{@as(f64, @bitCast(f32, @as(u32, 925353389)))});
1396 try testFmt("f64: 0.10000", "f64: {d:.5}", .{@as(f64, @bitCast(f32, @as(u32, 1036831278)))});
1397 try testFmt("f64: 1.00000", "f64: {d:.5}", .{@as(f64, @bitCast(f32, @as(u32, 1065353133)))});
1398 try testFmt("f64: 10.00000", "f64: {d:.5}", .{@as(f64, @bitCast(f32, @as(u32, 1092616192)))});
13971399
13981400 // libc differences
13991401 //
14001402 // This is 0.015625 exactly according to gdb. We thus round down,
14011403 // however glibc rounds up for some reason. This occurs for all
14021404 // floats of the form x.yyyy25 on a precision point.
1403 try testFmt("f64: 0.01563", "f64: {d:.5}", @as(f64, @bitCast(f32, @as(u32, 1015021568))));
1405 try testFmt("f64: 0.01563", "f64: {d:.5}", .{@as(f64, @bitCast(f32, @as(u32, 1015021568)))});
14041406 // errol3 rounds to ... 630 but libc rounds to ...632. Grisu3
14051407 // also rounds to 630 so I'm inclined to believe libc is not
14061408 // optimal here.
1407 try testFmt("f64: 18014400656965630.00000", "f64: {d:.5}", @as(f64, @bitCast(f32, @as(u32, 1518338049))));
1409 try testFmt("f64: 18014400656965630.00000", "f64: {d:.5}", .{@as(f64, @bitCast(f32, @as(u32, 1518338049)))});
14081410}
14091411
14101412test "custom" {
......@@ -1422,9 +1424,9 @@ test "custom" {
14221424 output: fn (@typeOf(context), []const u8) Errors!void,
14231425 ) Errors!void {
14241426 if (fmt.len == 0 or comptime std.mem.eql(u8, fmt, "p")) {
1425 return std.fmt.format(context, Errors, output, "({d:.3},{d:.3})", self.x, self.y);
1427 return std.fmt.format(context, Errors, output, "({d:.3},{d:.3})", .{ self.x, self.y });
14261428 } else if (comptime std.mem.eql(u8, fmt, "d")) {
1427 return std.fmt.format(context, Errors, output, "{d:.3}x{d:.3}", self.x, self.y);
1429 return std.fmt.format(context, Errors, output, "{d:.3}x{d:.3}", .{ self.x, self.y });
14281430 } else {
14291431 @compileError("Unknown format character: '" ++ fmt ++ "'");
14301432 }
......@@ -1436,12 +1438,12 @@ test "custom" {
14361438 .x = 10.2,
14371439 .y = 2.22,
14381440 };
1439 try testFmt("point: (10.200,2.220)\n", "point: {}\n", &value);
1440 try testFmt("dim: 10.200x2.220\n", "dim: {d}\n", &value);
1441 try testFmt("point: (10.200,2.220)\n", "point: {}\n", .{&value});
1442 try testFmt("dim: 10.200x2.220\n", "dim: {d}\n", .{&value});
14411443
14421444 // same thing but not passing a pointer
1443 try testFmt("point: (10.200,2.220)\n", "point: {}\n", value);
1444 try testFmt("dim: 10.200x2.220\n", "dim: {d}\n", value);
1445 try testFmt("point: (10.200,2.220)\n", "point: {}\n", .{value});
1446 try testFmt("dim: 10.200x2.220\n", "dim: {d}\n", .{value});
14451447}
14461448
14471449test "struct" {
......@@ -1455,7 +1457,7 @@ test "struct" {
14551457 .b = error.Unused,
14561458 };
14571459
1458 try testFmt("S{ .a = 456, .b = error.Unused }", "{}", inst);
1460 try testFmt("S{ .a = 456, .b = error.Unused }", "{}", .{inst});
14591461}
14601462
14611463test "union" {
......@@ -1478,13 +1480,13 @@ test "union" {
14781480 const uu_inst = UU{ .int = 456 };
14791481 const eu_inst = EU{ .float = 321.123 };
14801482
1481 try testFmt("TU{ .int = 123 }", "{}", tu_inst);
1483 try testFmt("TU{ .int = 123 }", "{}", .{tu_inst});
14821484
14831485 var buf: [100]u8 = undefined;
1484 const uu_result = try bufPrint(buf[0..], "{}", uu_inst);
1486 const uu_result = try bufPrint(buf[0..], "{}", .{uu_inst});
14851487 std.testing.expect(mem.eql(u8, uu_result[0..3], "UU@"));
14861488
1487 const eu_result = try bufPrint(buf[0..], "{}", eu_inst);
1489 const eu_result = try bufPrint(buf[0..], "{}", .{eu_inst});
14881490 std.testing.expect(mem.eql(u8, uu_result[0..3], "EU@"));
14891491}
14901492
......@@ -1497,7 +1499,7 @@ test "enum" {
14971499
14981500 const inst = E.Two;
14991501
1500 try testFmt("E.Two", "{}", inst);
1502 try testFmt("E.Two", "{}", .{inst});
15011503}
15021504
15031505test "struct.self-referential" {
......@@ -1511,7 +1513,7 @@ test "struct.self-referential" {
15111513 };
15121514 inst.a = &inst;
15131515
1514 try testFmt("S{ .a = S{ .a = S{ .a = S{ ... } } } }", "{}", inst);
1516 try testFmt("S{ .a = S{ .a = S{ .a = S{ ... } } } }", "{}", .{inst});
15151517}
15161518
15171519test "struct.zero-size" {
......@@ -1526,30 +1528,30 @@ test "struct.zero-size" {
15261528 const a = A{};
15271529 const b = B{ .a = a, .c = 0 };
15281530
1529 try testFmt("B{ .a = A{ }, .c = 0 }", "{}", b);
1531 try testFmt("B{ .a = A{ }, .c = 0 }", "{}", .{b});
15301532}
15311533
15321534test "bytes.hex" {
15331535 const some_bytes = "\xCA\xFE\xBA\xBE";
1534 try testFmt("lowercase: cafebabe\n", "lowercase: {x}\n", some_bytes);
1535 try testFmt("uppercase: CAFEBABE\n", "uppercase: {X}\n", some_bytes);
1536 try testFmt("lowercase: cafebabe\n", "lowercase: {x}\n", .{some_bytes});
1537 try testFmt("uppercase: CAFEBABE\n", "uppercase: {X}\n", .{some_bytes});
15361538 //Test Slices
1537 try testFmt("uppercase: CAFE\n", "uppercase: {X}\n", some_bytes[0..2]);
1538 try testFmt("lowercase: babe\n", "lowercase: {x}\n", some_bytes[2..]);
1539 try testFmt("uppercase: CAFE\n", "uppercase: {X}\n", .{some_bytes[0..2]});
1540 try testFmt("lowercase: babe\n", "lowercase: {x}\n", .{some_bytes[2..]});
15391541 const bytes_with_zeros = "\x00\x0E\xBA\xBE";
1540 try testFmt("lowercase: 000ebabe\n", "lowercase: {x}\n", bytes_with_zeros);
1542 try testFmt("lowercase: 000ebabe\n", "lowercase: {x}\n", .{bytes_with_zeros});
15411543}
15421544
1543fn testFmt(expected: []const u8, comptime template: []const u8, args: ...) !void {
1545fn testFmt(expected: []const u8, comptime template: []const u8, args: var) !void {
15441546 var buf: [100]u8 = undefined;
15451547 const result = try bufPrint(buf[0..], template, args);
15461548 if (mem.eql(u8, result, expected)) return;
15471549
1548 std.debug.warn("\n====== expected this output: =========\n");
1549 std.debug.warn("{}", expected);
1550 std.debug.warn("\n======== instead found this: =========\n");
1551 std.debug.warn("{}", result);
1552 std.debug.warn("\n======================================\n");
1550 std.debug.warn("\n====== expected this output: =========\n", .{});
1551 std.debug.warn("{}", .{expected});
1552 std.debug.warn("\n======== instead found this: =========\n", .{});
1553 std.debug.warn("{}", .{result});
1554 std.debug.warn("\n======================================\n", .{});
15531555 return error.TestFailed;
15541556}
15551557
......@@ -1602,7 +1604,7 @@ test "hexToBytes" {
16021604 const test_hex_str = "909A312BB12ED1F819B3521AC4C1E896F2160507FFC1C8381E3B07BB16BD1706";
16031605 var pb: [32]u8 = undefined;
16041606 try hexToBytes(pb[0..], test_hex_str);
1605 try testFmt(test_hex_str, "{X}", pb);
1607 try testFmt(test_hex_str, "{X}", .{pb});
16061608}
16071609
16081610test "formatIntValue with comptime_int" {
......@@ -1628,7 +1630,7 @@ test "formatType max_depth" {
16281630 output: fn (@typeOf(context), []const u8) Errors!void,
16291631 ) Errors!void {
16301632 if (fmt.len == 0) {
1631 return std.fmt.format(context, Errors, output, "({d:.3},{d:.3})", self.x, self.y);
1633 return std.fmt.format(context, Errors, output, "({d:.3},{d:.3})", .{ self.x, self.y });
16321634 } else {
16331635 @compileError("Unknown format string: '" ++ fmt ++ "'");
16341636 }
......@@ -1680,17 +1682,17 @@ test "formatType max_depth" {
16801682}
16811683
16821684test "positional" {
1683 try testFmt("2 1 0", "{2} {1} {0}", @as(usize, 0), @as(usize, 1), @as(usize, 2));
1684 try testFmt("2 1 0", "{2} {1} {}", @as(usize, 0), @as(usize, 1), @as(usize, 2));
1685 try testFmt("0 0", "{0} {0}", @as(usize, 0));
1686 try testFmt("0 1", "{} {1}", @as(usize, 0), @as(usize, 1));
1687 try testFmt("1 0 0 1", "{1} {} {0} {}", @as(usize, 0), @as(usize, 1));
1685 try testFmt("2 1 0", "{2} {1} {0}", .{ @as(usize, 0), @as(usize, 1), @as(usize, 2) });
1686 try testFmt("2 1 0", "{2} {1} {}", .{ @as(usize, 0), @as(usize, 1), @as(usize, 2) });
1687 try testFmt("0 0", "{0} {0}", .{@as(usize, 0)});
1688 try testFmt("0 1", "{} {1}", .{ @as(usize, 0), @as(usize, 1) });
1689 try testFmt("1 0 0 1", "{1} {} {0} {}", .{ @as(usize, 0), @as(usize, 1) });
16881690}
16891691
16901692test "positional with specifier" {
1691 try testFmt("10.0", "{0d:.1}", @as(f64, 9.999));
1693 try testFmt("10.0", "{0d:.1}", .{@as(f64, 9.999)});
16921694}
16931695
16941696test "positional/alignment/width/precision" {
1695 try testFmt("10.0", "{0d: >3.1}", @as(f64, 9.999));
1697 try testFmt("10.0", "{0d: >3.1}", .{@as(f64, 9.999)});
16961698}
lib/std/hash/benchmark.zig+1-1
......@@ -164,7 +164,7 @@ fn usage() void {
164164 \\ --iterative-only
165165 \\ --help
166166 \\
167 );
167 , .{});
168168}
169169
170170fn mode(comptime x: comptime_int) comptime_int {
lib/std/http/headers.zig+1-1
......@@ -610,5 +610,5 @@ test "Headers.format" {
610610 \\foo: bar
611611 \\cookie: somevalue
612612 \\
613 , try std.fmt.bufPrint(buf[0..], "{}", h));
613 , try std.fmt.bufPrint(buf[0..], "{}", .{h}));
614614}
lib/std/io.zig+1-1
......@@ -492,7 +492,7 @@ test "io.SliceOutStream" {
492492 var slice_stream = SliceOutStream.init(buf[0..]);
493493 const stream = &slice_stream.stream;
494494
495 try stream.print("{}{}!", "Hello", "World");
495 try stream.print("{}{}!", .{ "Hello", "World" });
496496 testing.expectEqualSlices(u8, "HelloWorld!", slice_stream.getWritten());
497497}
498498
lib/std/io/out_stream.zig+1-1
......@@ -35,7 +35,7 @@ pub fn OutStream(comptime WriteError: type) type {
3535 }
3636 }
3737
38 pub fn print(self: *Self, comptime format: []const u8, args: ...) Error!void {
38 pub fn print(self: *Self, comptime format: []const u8, args: var) Error!void {
3939 return std.fmt.format(self, Error, self.writeFn, format, args);
4040 }
4141
lib/std/io/test.zig+4-4
......@@ -27,9 +27,9 @@ test "write a file, read it, then delete it" {
2727 var file_out_stream = file.outStream();
2828 var buf_stream = io.BufferedOutStream(File.WriteError).init(&file_out_stream.stream);
2929 const st = &buf_stream.stream;
30 try st.print("begin");
30 try st.print("begin", .{});
3131 try st.write(data[0..]);
32 try st.print("end");
32 try st.print("end", .{});
3333 try buf_stream.flush();
3434 }
3535
......@@ -72,7 +72,7 @@ test "BufferOutStream" {
7272
7373 const x: i32 = 42;
7474 const y: i32 = 1234;
75 try buf_stream.print("x: {}\ny: {}\n", x, y);
75 try buf_stream.print("x: {}\ny: {}\n", .{ x, y });
7676
7777 expect(mem.eql(u8, buffer.toSlice(), "x: 42\ny: 1234\n"));
7878}
......@@ -605,7 +605,7 @@ test "c out stream" {
605605 }
606606
607607 const out_stream = &io.COutStream.init(out_file).stream;
608 try out_stream.print("hi: {}\n", @as(i32, 123));
608 try out_stream.print("hi: {}\n", .{@as(i32, 123)});
609609}
610610
611611test "File seek ops" {
lib/std/json/write_stream.zig+4-4
......@@ -158,24 +158,24 @@ pub fn WriteStream(comptime OutStream: type, comptime max_depth: usize) type {
158158 switch (@typeInfo(@typeOf(value))) {
159159 .Int => |info| {
160160 if (info.bits < 53) {
161 try self.stream.print("{}", value);
161 try self.stream.print("{}", .{value});
162162 self.popState();
163163 return;
164164 }
165165 if (value < 4503599627370496 and (!info.is_signed or value > -4503599627370496)) {
166 try self.stream.print("{}", value);
166 try self.stream.print("{}", .{value});
167167 self.popState();
168168 return;
169169 }
170170 },
171171 .Float => if (@floatCast(f64, value) == value) {
172 try self.stream.print("{}", value);
172 try self.stream.print("{}", .{value});
173173 self.popState();
174174 return;
175175 },
176176 else => {},
177177 }
178 try self.stream.print("\"{}\"", value);
178 try self.stream.print("\"{}\"", .{value});
179179 self.popState();
180180 }
181181
lib/std/math/big/int.zig+2-2
......@@ -180,9 +180,9 @@ pub const Int = struct {
180180
181181 pub fn dump(self: Int) void {
182182 for (self.limbs) |limb| {
183 debug.warn("{x} ", limb);
183 debug.warn("{x} ", .{limb});
184184 }
185 debug.warn("\n");
185 debug.warn("\n", .{});
186186 }
187187
188188 /// Negate the sign of an Int.
lib/std/net.zig+8-16
......@@ -277,32 +277,24 @@ pub const Address = extern union {
277277 os.AF_INET => {
278278 const port = mem.bigToNative(u16, self.in.port);
279279 const bytes = @ptrCast(*const [4]u8, &self.in.addr);
280 try std.fmt.format(
281 context,
282 Errors,
283 output,
284 "{}.{}.{}.{}:{}",
280 try std.fmt.format(context, Errors, output, "{}.{}.{}.{}:{}", .{
285281 bytes[0],
286282 bytes[1],
287283 bytes[2],
288284 bytes[3],
289285 port,
290 );
286 });
291287 },
292288 os.AF_INET6 => {
293289 const port = mem.bigToNative(u16, self.in6.port);
294290 if (mem.eql(u8, self.in6.addr[0..12], &[_]u8{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff })) {
295 try std.fmt.format(
296 context,
297 Errors,
298 output,
299 "[::ffff:{}.{}.{}.{}]:{}",
291 try std.fmt.format(context, Errors, output, "[::ffff:{}.{}.{}.{}]:{}", .{
300292 self.in6.addr[12],
301293 self.in6.addr[13],
302294 self.in6.addr[14],
303295 self.in6.addr[15],
304296 port,
305 );
297 });
306298 return;
307299 }
308300 const big_endian_parts = @ptrCast(*align(1) const [8]u16, &self.in6.addr);
......@@ -327,19 +319,19 @@ pub const Address = extern union {
327319 }
328320 continue;
329321 }
330 try std.fmt.format(context, Errors, output, "{x}", native_endian_parts[i]);
322 try std.fmt.format(context, Errors, output, "{x}", .{native_endian_parts[i]});
331323 if (i != native_endian_parts.len - 1) {
332324 try output(context, ":");
333325 }
334326 }
335 try std.fmt.format(context, Errors, output, "]:{}", port);
327 try std.fmt.format(context, Errors, output, "]:{}", .{port});
336328 },
337329 os.AF_UNIX => {
338330 if (!has_unix_sockets) {
339331 unreachable;
340332 }
341333
342 try std.fmt.format(context, Errors, output, "{}", &self.un.path);
334 try std.fmt.format(context, Errors, output, "{}", .{&self.un.path});
343335 },
344336 else => unreachable,
345337 }
......@@ -445,7 +437,7 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !*
445437 const name_c = try std.cstr.addNullByte(allocator, name);
446438 defer allocator.free(name_c);
447439
448 const port_c = try std.fmt.allocPrint(allocator, "{}\x00", port);
440 const port_c = try std.fmt.allocPrint(allocator, "{}\x00", .{port});
449441 defer allocator.free(port_c);
450442
451443 const hints = os.addrinfo{
lib/std/net/test.zig+3-3
......@@ -29,7 +29,7 @@ test "parse and render IPv6 addresses" {
2929 };
3030 for (ips) |ip, i| {
3131 var addr = net.Address.parseIp6(ip, 0) catch unreachable;
32 var newIp = std.fmt.bufPrint(buffer[0..], "{}", addr) catch unreachable;
32 var newIp = std.fmt.bufPrint(buffer[0..], "{}", .{addr}) catch unreachable;
3333 std.testing.expect(std.mem.eql(u8, printed[i], newIp[1 .. newIp.len - 3]));
3434 }
3535
......@@ -51,7 +51,7 @@ test "parse and render IPv4 addresses" {
5151 "127.0.0.1",
5252 }) |ip| {
5353 var addr = net.Address.parseIp4(ip, 0) catch unreachable;
54 var newIp = std.fmt.bufPrint(buffer[0..], "{}", addr) catch unreachable;
54 var newIp = std.fmt.bufPrint(buffer[0..], "{}", .{addr}) catch unreachable;
5555 std.testing.expect(std.mem.eql(u8, ip, newIp[0 .. newIp.len - 2]));
5656 }
5757
......@@ -118,5 +118,5 @@ fn testServer(server: *net.StreamServer) anyerror!void {
118118 var client = try server.accept();
119119
120120 const stream = &client.file.outStream().stream;
121 try stream.print("hello from server\n");
121 try stream.print("hello from server\n", .{});
122122}
lib/std/os.zig+2-2
......@@ -2603,7 +2603,7 @@ pub fn realpathC(pathname: [*:0]const u8, out_buffer: *[MAX_PATH_BYTES]u8) RealP
26032603 defer close(fd);
26042604
26052605 var procfs_buf: ["/proc/self/fd/-2147483648".len:0]u8 = undefined;
2606 const proc_path = std.fmt.bufPrint(procfs_buf[0..], "/proc/self/fd/{}\x00", fd) catch unreachable;
2606 const proc_path = std.fmt.bufPrint(procfs_buf[0..], "/proc/self/fd/{}\x00", .{fd}) catch unreachable;
26072607
26082608 return readlinkC(@ptrCast([*:0]const u8, proc_path.ptr), out_buffer);
26092609 }
......@@ -2832,7 +2832,7 @@ pub const UnexpectedError = error{
28322832/// and you get an unexpected error.
28332833pub fn unexpectedErrno(err: usize) UnexpectedError {
28342834 if (unexpected_error_tracing) {
2835 std.debug.warn("unexpected errno: {}\n", err);
2835 std.debug.warn("unexpected errno: {}\n", .{err});
28362836 std.debug.dumpCurrentStackTrace(null);
28372837 }
28382838 return error.Unexpected;
lib/std/os/windows.zig+3-3
......@@ -323,7 +323,7 @@ pub fn GetQueuedCompletionStatus(
323323 ERROR.HANDLE_EOF => return GetQueuedCompletionStatusResult.EOF,
324324 else => |err| {
325325 if (std.debug.runtime_safety) {
326 std.debug.panic("unexpected error: {}\n", err);
326 std.debug.panic("unexpected error: {}\n", .{err});
327327 }
328328 },
329329 }
......@@ -1039,7 +1039,7 @@ pub fn unexpectedError(err: DWORD) std.os.UnexpectedError {
10391039 var buf_u8: [614]u8 = undefined;
10401040 var len = kernel32.FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, null, err, MAKELANGID(LANG.NEUTRAL, SUBLANG.DEFAULT), buf_u16[0..].ptr, buf_u16.len / @sizeOf(TCHAR), null);
10411041 _ = std.unicode.utf16leToUtf8(&buf_u8, buf_u16[0..len]) catch unreachable;
1042 std.debug.warn("error.Unexpected: GetLastError({}): {}\n", err, buf_u8[0..len]);
1042 std.debug.warn("error.Unexpected: GetLastError({}): {}\n", .{ err, buf_u8[0..len] });
10431043 std.debug.dumpCurrentStackTrace(null);
10441044 }
10451045 return error.Unexpected;
......@@ -1053,7 +1053,7 @@ pub fn unexpectedWSAError(err: c_int) std.os.UnexpectedError {
10531053/// and you get an unexpected status.
10541054pub fn unexpectedStatus(status: NTSTATUS) std.os.UnexpectedError {
10551055 if (std.os.unexpected_error_tracing) {
1056 std.debug.warn("error.Unexpected NTSTATUS=0x{x}\n", status);
1056 std.debug.warn("error.Unexpected NTSTATUS=0x{x}\n", .{status});
10571057 std.debug.dumpCurrentStackTrace(null);
10581058 }
10591059 return error.Unexpected;
lib/std/os/zen.zig deleted-260
......@@ -1,260 +0,0 @@
1const std = @import("../std.zig");
2const assert = std.debug.assert;
3
4//////////////////////////
5//// IPC structures ////
6//////////////////////////
7
8pub const Message = struct {
9 sender: MailboxId,
10 receiver: MailboxId,
11 code: usize,
12 args: [5]usize,
13 payload: ?[]const u8,
14
15 pub fn from(mailbox_id: MailboxId) Message {
16 return Message{
17 .sender = MailboxId.Undefined,
18 .receiver = mailbox_id,
19 .code = undefined,
20 .args = undefined,
21 .payload = null,
22 };
23 }
24
25 pub fn to(mailbox_id: MailboxId, msg_code: usize, args: ...) Message {
26 var message = Message{
27 .sender = MailboxId.This,
28 .receiver = mailbox_id,
29 .code = msg_code,
30 .args = undefined,
31 .payload = null,
32 };
33
34 assert(args.len <= message.args.len);
35 comptime var i = 0;
36 inline while (i < args.len) : (i += 1) {
37 message.args[i] = args[i];
38 }
39
40 return message;
41 }
42
43 pub fn as(self: Message, sender: MailboxId) Message {
44 var message = self;
45 message.sender = sender;
46 return message;
47 }
48
49 pub fn withPayload(self: Message, payload: []const u8) Message {
50 var message = self;
51 message.payload = payload;
52 return message;
53 }
54};
55
56pub const MailboxId = union(enum) {
57 Undefined,
58 This,
59 Kernel,
60 Port: u16,
61 Thread: u16,
62};
63
64//////////////////////////////////////
65//// Ports reserved for servers ////
66//////////////////////////////////////
67
68pub const Server = struct {
69 pub const Keyboard = MailboxId{ .Port = 0 };
70 pub const Terminal = MailboxId{ .Port = 1 };
71};
72
73////////////////////////
74//// POSIX things ////
75////////////////////////
76
77// Standard streams.
78pub const STDIN_FILENO = 0;
79pub const STDOUT_FILENO = 1;
80pub const STDERR_FILENO = 2;
81
82// FIXME: let's borrow Linux's error numbers for now.
83usingnamespace @import("bits/linux/errno-generic.zig");
84// Get the errno from a syscall return value, or 0 for no error.
85pub fn getErrno(r: usize) usize {
86 const signed_r = @bitCast(isize, r);
87 return if (signed_r > -4096 and signed_r < 0) @intCast(usize, -signed_r) else 0;
88}
89
90// TODO: implement this correctly.
91pub fn read(fd: i32, buf: [*]u8, count: usize) usize {
92 switch (fd) {
93 STDIN_FILENO => {
94 var i: usize = 0;
95 while (i < count) : (i += 1) {
96 send(&Message.to(Server.Keyboard, 0));
97
98 // FIXME: we should be certain that we are receiving from Keyboard.
99 var message = Message.from(MailboxId.This);
100 receive(&message);
101
102 buf[i] = @intCast(u8, message.args[0]);
103 }
104 },
105 else => unreachable,
106 }
107 return count;
108}
109
110// TODO: implement this correctly.
111pub fn write(fd: i32, buf: [*]const u8, count: usize) usize {
112 switch (fd) {
113 STDOUT_FILENO, STDERR_FILENO => {
114 send(&Message.to(Server.Terminal, 1).withPayload(buf[0..count]));
115 },
116 else => unreachable,
117 }
118 return count;
119}
120
121///////////////////////////
122//// Syscall numbers ////
123///////////////////////////
124
125pub const Syscall = enum(usize) {
126 exit = 0,
127 send = 1,
128 receive = 2,
129 subscribeIRQ = 3,
130 inb = 4,
131 outb = 5,
132 map = 6,
133 createThread = 7,
134};
135
136////////////////////
137//// Syscalls ////
138////////////////////
139
140pub fn exit(status: i32) noreturn {
141 _ = syscall1(Syscall.exit, @bitCast(usize, @as(isize, status)));
142 unreachable;
143}
144
145pub fn send(message: *const Message) void {
146 _ = syscall1(Syscall.send, @ptrToInt(message));
147}
148
149pub fn receive(destination: *Message) void {
150 _ = syscall1(Syscall.receive, @ptrToInt(destination));
151}
152
153pub fn subscribeIRQ(irq: u8, mailbox_id: *const MailboxId) void {
154 _ = syscall2(Syscall.subscribeIRQ, irq, @ptrToInt(mailbox_id));
155}
156
157pub fn inb(port: u16) u8 {
158 return @intCast(u8, syscall1(Syscall.inb, port));
159}
160
161pub fn outb(port: u16, value: u8) void {
162 _ = syscall2(Syscall.outb, port, value);
163}
164
165pub fn map(v_addr: usize, p_addr: usize, size: usize, writable: bool) bool {
166 return syscall4(Syscall.map, v_addr, p_addr, size, @boolToInt(writable)) != 0;
167}
168
169pub fn createThread(function: fn () void) u16 {
170 return @as(u16, syscall1(Syscall.createThread, @ptrToInt(function)));
171}
172
173/////////////////////////
174//// Syscall stubs ////
175/////////////////////////
176
177inline fn syscall0(number: Syscall) usize {
178 return asm volatile ("int $0x80"
179 : [ret] "={eax}" (-> usize)
180 : [number] "{eax}" (number)
181 );
182}
183
184inline fn syscall1(number: Syscall, arg1: usize) usize {
185 return asm volatile ("int $0x80"
186 : [ret] "={eax}" (-> usize)
187 : [number] "{eax}" (number),
188 [arg1] "{ecx}" (arg1)
189 );
190}
191
192inline fn syscall2(number: Syscall, arg1: usize, arg2: usize) usize {
193 return asm volatile ("int $0x80"
194 : [ret] "={eax}" (-> usize)
195 : [number] "{eax}" (number),
196 [arg1] "{ecx}" (arg1),
197 [arg2] "{edx}" (arg2)
198 );
199}
200
201inline fn syscall3(number: Syscall, arg1: usize, arg2: usize, arg3: usize) usize {
202 return asm volatile ("int $0x80"
203 : [ret] "={eax}" (-> usize)
204 : [number] "{eax}" (number),
205 [arg1] "{ecx}" (arg1),
206 [arg2] "{edx}" (arg2),
207 [arg3] "{ebx}" (arg3)
208 );
209}
210
211inline fn syscall4(number: Syscall, arg1: usize, arg2: usize, arg3: usize, arg4: usize) usize {
212 return asm volatile ("int $0x80"
213 : [ret] "={eax}" (-> usize)
214 : [number] "{eax}" (number),
215 [arg1] "{ecx}" (arg1),
216 [arg2] "{edx}" (arg2),
217 [arg3] "{ebx}" (arg3),
218 [arg4] "{esi}" (arg4)
219 );
220}
221
222inline fn syscall5(
223 number: Syscall,
224 arg1: usize,
225 arg2: usize,
226 arg3: usize,
227 arg4: usize,
228 arg5: usize,
229) usize {
230 return asm volatile ("int $0x80"
231 : [ret] "={eax}" (-> usize)
232 : [number] "{eax}" (number),
233 [arg1] "{ecx}" (arg1),
234 [arg2] "{edx}" (arg2),
235 [arg3] "{ebx}" (arg3),
236 [arg4] "{esi}" (arg4),
237 [arg5] "{edi}" (arg5)
238 );
239}
240
241inline fn syscall6(
242 number: Syscall,
243 arg1: usize,
244 arg2: usize,
245 arg3: usize,
246 arg4: usize,
247 arg5: usize,
248 arg6: usize,
249) usize {
250 return asm volatile ("int $0x80"
251 : [ret] "={eax}" (-> usize)
252 : [number] "{eax}" (number),
253 [arg1] "{ecx}" (arg1),
254 [arg2] "{edx}" (arg2),
255 [arg3] "{ebx}" (arg3),
256 [arg4] "{esi}" (arg4),
257 [arg5] "{edi}" (arg5),
258 [arg6] "{ebp}" (arg6)
259 );
260}
lib/std/priority_queue.zig+8-8
......@@ -199,19 +199,19 @@ pub fn PriorityQueue(comptime T: type) type {
199199 }
200200
201201 fn dump(self: *Self) void {
202 warn("{{ ");
203 warn("items: ");
202 warn("{{ ", .{});
203 warn("items: ", .{});
204204 for (self.items) |e, i| {
205205 if (i >= self.len) break;
206 warn("{}, ", e);
206 warn("{}, ", .{e});
207207 }
208 warn("array: ");
208 warn("array: ", .{});
209209 for (self.items) |e, i| {
210 warn("{}, ", e);
210 warn("{}, ", .{e});
211211 }
212 warn("len: {} ", self.len);
213 warn("capacity: {}", self.capacity());
214 warn(" }}\n");
212 warn("len: {} ", .{self.len});
213 warn("capacity: {}", .{self.capacity()});
214 warn(" }}\n", .{});
215215 }
216216 };
217217}
lib/std/progress.zig+11-11
......@@ -130,11 +130,11 @@ pub const Progress = struct {
130130 var end: usize = 0;
131131 if (self.columns_written > 0) {
132132 // restore cursor position
133 end += (std.fmt.bufPrint(self.output_buffer[end..], "\x1b[{}D", self.columns_written) catch unreachable).len;
133 end += (std.fmt.bufPrint(self.output_buffer[end..], "\x1b[{}D", .{self.columns_written}) catch unreachable).len;
134134 self.columns_written = 0;
135135
136136 // clear rest of line
137 end += (std.fmt.bufPrint(self.output_buffer[end..], "\x1b[0K") catch unreachable).len;
137 end += (std.fmt.bufPrint(self.output_buffer[end..], "\x1b[0K", .{}) catch unreachable).len;
138138 }
139139
140140 if (!self.done) {
......@@ -142,28 +142,28 @@ pub const Progress = struct {
142142 var maybe_node: ?*Node = &self.root;
143143 while (maybe_node) |node| {
144144 if (need_ellipse) {
145 self.bufWrite(&end, "...");
145 self.bufWrite(&end, "...", .{});
146146 }
147147 need_ellipse = false;
148148 if (node.name.len != 0 or node.estimated_total_items != null) {
149149 if (node.name.len != 0) {
150 self.bufWrite(&end, "{}", node.name);
150 self.bufWrite(&end, "{}", .{node.name});
151151 need_ellipse = true;
152152 }
153153 if (node.estimated_total_items) |total| {
154 if (need_ellipse) self.bufWrite(&end, " ");
155 self.bufWrite(&end, "[{}/{}] ", node.completed_items + 1, total);
154 if (need_ellipse) self.bufWrite(&end, " ", .{});
155 self.bufWrite(&end, "[{}/{}] ", .{ node.completed_items + 1, total });
156156 need_ellipse = false;
157157 } else if (node.completed_items != 0) {
158 if (need_ellipse) self.bufWrite(&end, " ");
159 self.bufWrite(&end, "[{}] ", node.completed_items + 1);
158 if (need_ellipse) self.bufWrite(&end, " ", .{});
159 self.bufWrite(&end, "[{}] ", .{node.completed_items + 1});
160160 need_ellipse = false;
161161 }
162162 }
163163 maybe_node = node.recently_updated_child;
164164 }
165165 if (need_ellipse) {
166 self.bufWrite(&end, "...");
166 self.bufWrite(&end, "...", .{});
167167 }
168168 }
169169
......@@ -174,7 +174,7 @@ pub const Progress = struct {
174174 self.prev_refresh_timestamp = self.timer.read();
175175 }
176176
177 pub fn log(self: *Progress, comptime format: []const u8, args: ...) void {
177 pub fn log(self: *Progress, comptime format: []const u8, args: var) void {
178178 const file = self.terminal orelse return;
179179 self.refresh();
180180 file.outStream().stream.print(format, args) catch {
......@@ -184,7 +184,7 @@ pub const Progress = struct {
184184 self.columns_written = 0;
185185 }
186186
187 fn bufWrite(self: *Progress, end: *usize, comptime format: []const u8, args: ...) void {
187 fn bufWrite(self: *Progress, end: *usize, comptime format: []const u8, args: var) void {
188188 if (std.fmt.bufPrint(self.output_buffer[end.*..], format, args)) |written| {
189189 const amt = written.len;
190190 end.* += amt;
lib/std/special/build_runner.zig+18-15
......@@ -26,15 +26,15 @@ pub fn main() !void {
2626 _ = arg_it.skip();
2727
2828 const zig_exe = try unwrapArg(arg_it.next(allocator) orelse {
29 warn("Expected first argument to be path to zig compiler\n");
29 warn("Expected first argument to be path to zig compiler\n", .{});
3030 return error.InvalidArgs;
3131 });
3232 const build_root = try unwrapArg(arg_it.next(allocator) orelse {
33 warn("Expected second argument to be build root directory path\n");
33 warn("Expected second argument to be build root directory path\n", .{});
3434 return error.InvalidArgs;
3535 });
3636 const cache_root = try unwrapArg(arg_it.next(allocator) orelse {
37 warn("Expected third argument to be cache root directory path\n");
37 warn("Expected third argument to be cache root directory path\n", .{});
3838 return error.InvalidArgs;
3939 });
4040
......@@ -51,7 +51,7 @@ pub fn main() !void {
5151 if (mem.startsWith(u8, arg, "-D")) {
5252 const option_contents = arg[2..];
5353 if (option_contents.len == 0) {
54 warn("Expected option name after '-D'\n\n");
54 warn("Expected option name after '-D'\n\n", .{});
5555 return usageAndErr(builder, false, stderr_stream);
5656 }
5757 if (mem.indexOfScalar(u8, option_contents, '=')) |name_end| {
......@@ -70,18 +70,18 @@ pub fn main() !void {
7070 return usage(builder, false, stdout_stream);
7171 } else if (mem.eql(u8, arg, "--prefix")) {
7272 builder.install_prefix = try unwrapArg(arg_it.next(allocator) orelse {
73 warn("Expected argument after --prefix\n\n");
73 warn("Expected argument after --prefix\n\n", .{});
7474 return usageAndErr(builder, false, stderr_stream);
7575 });
7676 } else if (mem.eql(u8, arg, "--search-prefix")) {
7777 const search_prefix = try unwrapArg(arg_it.next(allocator) orelse {
78 warn("Expected argument after --search-prefix\n\n");
78 warn("Expected argument after --search-prefix\n\n", .{});
7979 return usageAndErr(builder, false, stderr_stream);
8080 });
8181 builder.addSearchPrefix(search_prefix);
8282 } else if (mem.eql(u8, arg, "--override-lib-dir")) {
8383 builder.override_lib_dir = try unwrapArg(arg_it.next(allocator) orelse {
84 warn("Expected argument after --override-lib-dir\n\n");
84 warn("Expected argument after --override-lib-dir\n\n", .{});
8585 return usageAndErr(builder, false, stderr_stream);
8686 });
8787 } else if (mem.eql(u8, arg, "--verbose-tokenize")) {
......@@ -99,7 +99,7 @@ pub fn main() !void {
9999 } else if (mem.eql(u8, arg, "--verbose-cc")) {
100100 builder.verbose_cc = true;
101101 } else {
102 warn("Unrecognized argument: {}\n\n", arg);
102 warn("Unrecognized argument: {}\n\n", .{arg});
103103 return usageAndErr(builder, false, stderr_stream);
104104 }
105105 } else {
......@@ -145,15 +145,15 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {
145145 \\
146146 \\Steps:
147147 \\
148 , builder.zig_exe);
148 , .{builder.zig_exe});
149149
150150 const allocator = builder.allocator;
151151 for (builder.top_level_steps.toSliceConst()) |top_level_step| {
152152 const name = if (&top_level_step.step == builder.default_step)
153 try fmt.allocPrint(allocator, "{} (default)", top_level_step.step.name)
153 try fmt.allocPrint(allocator, "{} (default)", .{top_level_step.step.name})
154154 else
155155 top_level_step.step.name;
156 try out_stream.print(" {s:22} {}\n", name, top_level_step.description);
156 try out_stream.print(" {s:22} {}\n", .{ name, top_level_step.description });
157157 }
158158
159159 try out_stream.write(
......@@ -169,12 +169,15 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void {
169169 );
170170
171171 if (builder.available_options_list.len == 0) {
172 try out_stream.print(" (none)\n");
172 try out_stream.print(" (none)\n", .{});
173173 } else {
174174 for (builder.available_options_list.toSliceConst()) |option| {
175 const name = try fmt.allocPrint(allocator, " -D{}=[{}]", option.name, Builder.typeIdName(option.type_id));
175 const name = try fmt.allocPrint(allocator, " -D{}=[{}]", .{
176 option.name,
177 Builder.typeIdName(option.type_id),
178 });
176179 defer allocator.free(name);
177 try out_stream.print("{s:24} {}\n", name, option.description);
180 try out_stream.print("{s:24} {}\n", .{ name, option.description });
178181 }
179182 }
180183
......@@ -204,7 +207,7 @@ const UnwrapArgError = error{OutOfMemory};
204207
205208fn unwrapArg(arg: UnwrapArgError![]u8) UnwrapArgError![]u8 {
206209 return arg catch |err| {
207 warn("Unable to parse command line: {}\n", err);
210 warn("Unable to parse command line: {}\n", .{err});
208211 return err;
209212 };
210213}
lib/std/special/compiler_rt/truncXfYf2_test.zig+1-1
......@@ -217,7 +217,7 @@ fn test__truncdfsf2(a: f64, expected: u32) void {
217217 }
218218 }
219219
220 @import("std").debug.warn("got 0x{x} wanted 0x{x}\n", rep, expected);
220 @import("std").debug.warn("got 0x{x} wanted 0x{x}\n", .{ rep, expected });
221221
222222 @panic("__trunctfsf2 test failure");
223223}
lib/std/special/init-exe/src/main.zig+1-1
......@@ -1,5 +1,5 @@
11const std = @import("std");
22
33pub fn main() anyerror!void {
4 std.debug.warn("All your base are belong to us.\n");
4 std.debug.warn("All your base are belong to us.\n", .{});
55}
lib/std/special/start.zig+2-2
......@@ -217,7 +217,7 @@ inline fn initEventLoopAndCallMain() u8 {
217217 if (std.event.Loop.instance) |loop| {
218218 if (!@hasDecl(root, "event_loop")) {
219219 loop.init() catch |err| {
220 std.debug.warn("error: {}\n", @errorName(err));
220 std.debug.warn("error: {}\n", .{@errorName(err)});
221221 if (@errorReturnTrace()) |trace| {
222222 std.debug.dumpStackTrace(trace.*);
223223 }
......@@ -264,7 +264,7 @@ fn callMain() u8 {
264264 },
265265 .ErrorUnion => {
266266 const result = root.main() catch |err| {
267 std.debug.warn("error: {}\n", @errorName(err));
267 std.debug.warn("error: {}\n", .{@errorName(err)});
268268 if (@errorReturnTrace()) |trace| {
269269 std.debug.dumpStackTrace(trace.*);
270270 }
lib/std/special/test_runner.zig+7-7
......@@ -16,28 +16,28 @@ pub fn main() anyerror!void {
1616 var test_node = root_node.start(test_fn.name, null);
1717 test_node.activate();
1818 progress.refresh();
19 if (progress.terminal == null) std.debug.warn("{}/{} {}...", i + 1, test_fn_list.len, test_fn.name);
19 if (progress.terminal == null) std.debug.warn("{}/{} {}...", .{ i + 1, test_fn_list.len, test_fn.name });
2020 if (test_fn.func()) |_| {
2121 ok_count += 1;
2222 test_node.end();
23 if (progress.terminal == null) std.debug.warn("OK\n");
23 if (progress.terminal == null) std.debug.warn("OK\n", .{});
2424 } else |err| switch (err) {
2525 error.SkipZigTest => {
2626 skip_count += 1;
2727 test_node.end();
28 progress.log("{}...SKIP\n", test_fn.name);
29 if (progress.terminal == null) std.debug.warn("SKIP\n");
28 progress.log("{}...SKIP\n", .{test_fn.name});
29 if (progress.terminal == null) std.debug.warn("SKIP\n", .{});
3030 },
3131 else => {
32 progress.log("");
32 progress.log("", .{});
3333 return err;
3434 },
3535 }
3636 }
3737 root_node.end();
3838 if (ok_count == test_fn_list.len) {
39 std.debug.warn("All {} tests passed.\n", ok_count);
39 std.debug.warn("All {} tests passed.\n", .{ok_count});
4040 } else {
41 std.debug.warn("{} passed; {} skipped.\n", ok_count, skip_count);
41 std.debug.warn("{} passed; {} skipped.\n", .{ ok_count, skip_count });
4242 }
4343}
lib/std/target.zig+6-12
......@@ -321,14 +321,12 @@ pub const Target = union(enum) {
321321 pub const stack_align = 16;
322322
323323 pub fn zigTriple(self: Target, allocator: *mem.Allocator) ![]u8 {
324 return std.fmt.allocPrint(
325 allocator,
326 "{}{}-{}-{}",
324 return std.fmt.allocPrint(allocator, "{}{}-{}-{}", .{
327325 @tagName(self.getArch()),
328326 Target.archSubArchName(self.getArch()),
329327 @tagName(self.getOs()),
330328 @tagName(self.getAbi()),
331 );
329 });
332330 }
333331
334332 /// Returned slice must be freed by the caller.
......@@ -372,23 +370,19 @@ pub const Target = union(enum) {
372370 }
373371
374372 pub fn zigTripleNoSubArch(self: Target, allocator: *mem.Allocator) ![]u8 {
375 return std.fmt.allocPrint(
376 allocator,
377 "{}-{}-{}",
373 return std.fmt.allocPrint(allocator, "{}-{}-{}", .{
378374 @tagName(self.getArch()),
379375 @tagName(self.getOs()),
380376 @tagName(self.getAbi()),
381 );
377 });
382378 }
383379
384380 pub fn linuxTriple(self: Target, allocator: *mem.Allocator) ![]u8 {
385 return std.fmt.allocPrint(
386 allocator,
387 "{}-{}-{}",
381 return std.fmt.allocPrint(allocator, "{}-{}-{}", .{
388382 @tagName(self.getArch()),
389383 @tagName(self.getOs()),
390384 @tagName(self.getAbi()),
391 );
385 });
392386 }
393387
394388 pub fn parse(text: []const u8) !Target {
lib/std/testing.zig+23-18
......@@ -8,13 +8,19 @@ pub fn expectError(expected_error: anyerror, actual_error_union: var) void {
88 if (actual_error_union) |actual_payload| {
99 // TODO remove workaround here for https://github.com/ziglang/zig/issues/557
1010 if (@sizeOf(@typeOf(actual_payload)) == 0) {
11 std.debug.panic("expected error.{}, found {} value", @errorName(expected_error), @typeName(@typeOf(actual_payload)));
11 std.debug.panic("expected error.{}, found {} value", .{
12 @errorName(expected_error),
13 @typeName(@typeOf(actual_payload)),
14 });
1215 } else {
13 std.debug.panic("expected error.{}, found {}", @errorName(expected_error), actual_payload);
16 std.debug.panic("expected error.{}, found {}", .{ @errorName(expected_error), actual_payload });
1417 }
1518 } else |actual_error| {
1619 if (expected_error != actual_error) {
17 std.debug.panic("expected error.{}, found error.{}", @errorName(expected_error), @errorName(actual_error));
20 std.debug.panic("expected error.{}, found error.{}", .{
21 @errorName(expected_error),
22 @errorName(actual_error),
23 });
1824 }
1925 }
2026}
......@@ -51,7 +57,7 @@ pub fn expectEqual(expected: var, actual: @typeOf(expected)) void {
5157 .ErrorSet,
5258 => {
5359 if (actual != expected) {
54 std.debug.panic("expected {}, found {}", expected, actual);
60 std.debug.panic("expected {}, found {}", .{ expected, actual });
5561 }
5662 },
5763
......@@ -62,16 +68,16 @@ pub fn expectEqual(expected: var, actual: @typeOf(expected)) void {
6268 builtin.TypeInfo.Pointer.Size.C,
6369 => {
6470 if (actual != expected) {
65 std.debug.panic("expected {*}, found {*}", expected, actual);
71 std.debug.panic("expected {*}, found {*}", .{ expected, actual });
6672 }
6773 },
6874
6975 builtin.TypeInfo.Pointer.Size.Slice => {
7076 if (actual.ptr != expected.ptr) {
71 std.debug.panic("expected slice ptr {}, found {}", expected.ptr, actual.ptr);
77 std.debug.panic("expected slice ptr {}, found {}", .{ expected.ptr, actual.ptr });
7278 }
7379 if (actual.len != expected.len) {
74 std.debug.panic("expected slice len {}, found {}", expected.len, actual.len);
80 std.debug.panic("expected slice len {}, found {}", .{ expected.len, actual.len });
7581 }
7682 },
7783 }
......@@ -106,7 +112,7 @@ pub fn expectEqual(expected: var, actual: @typeOf(expected)) void {
106112 }
107113
108114 // we iterate over *all* union fields
109 // => we should never get here as the loop above is
115 // => we should never get here as the loop above is
110116 // including all possible values.
111117 unreachable;
112118 },
......@@ -116,11 +122,11 @@ pub fn expectEqual(expected: var, actual: @typeOf(expected)) void {
116122 if (actual) |actual_payload| {
117123 expectEqual(expected_payload, actual_payload);
118124 } else {
119 std.debug.panic("expected {}, found null", expected_payload);
125 std.debug.panic("expected {}, found null", .{expected_payload});
120126 }
121127 } else {
122128 if (actual) |actual_payload| {
123 std.debug.panic("expected null, found {}", actual_payload);
129 std.debug.panic("expected null, found {}", .{actual_payload});
124130 }
125131 }
126132 },
......@@ -130,11 +136,11 @@ pub fn expectEqual(expected: var, actual: @typeOf(expected)) void {
130136 if (actual) |actual_payload| {
131137 expectEqual(expected_payload, actual_payload);
132138 } else |actual_err| {
133 std.debug.panic("expected {}, found {}", expected_payload, actual_err);
139 std.debug.panic("expected {}, found {}", .{ expected_payload, actual_err });
134140 }
135141 } else |expected_err| {
136142 if (actual) |actual_payload| {
137 std.debug.panic("expected {}, found {}", expected_err, actual_payload);
143 std.debug.panic("expected {}, found {}", .{ expected_err, actual_payload });
138144 } else |actual_err| {
139145 expectEqual(expected_err, actual_err);
140146 }
......@@ -143,15 +149,14 @@ pub fn expectEqual(expected: var, actual: @typeOf(expected)) void {
143149 }
144150}
145151
146test "expectEqual.union(enum)"
147{
152test "expectEqual.union(enum)" {
148153 const T = union(enum) {
149154 a: i32,
150155 b: f32,
151156 };
152157
153 const a10 = T { .a = 10 };
154 const a20 = T { .a = 20 };
158 const a10 = T{ .a = 10 };
159 const a20 = T{ .a = 20 };
155160
156161 expectEqual(a10, a10);
157162}
......@@ -165,12 +170,12 @@ pub fn expectEqualSlices(comptime T: type, expected: []const T, actual: []const
165170 // If the child type is u8 and no weird bytes, we could print it as strings
166171 // Even for the length difference, it would be useful to see the values of the slices probably.
167172 if (expected.len != actual.len) {
168 std.debug.panic("slice lengths differ. expected {}, found {}", expected.len, actual.len);
173 std.debug.panic("slice lengths differ. expected {}, found {}", .{ expected.len, actual.len });
169174 }
170175 var i: usize = 0;
171176 while (i < expected.len) : (i += 1) {
172177 if (expected[i] != actual[i]) {
173 std.debug.panic("index {} incorrect. expected {}, found {}", i, expected[i], actual[i]);
178 std.debug.panic("index {} incorrect. expected {}, found {}", .{ i, expected[i], actual[i] });
174179 }
175180 }
176181}
lib/std/unicode.zig+1-1
......@@ -170,7 +170,7 @@ pub fn utf8ValidateSlice(s: []const u8) bool {
170170/// ```
171171/// var utf8 = (try std.unicode.Utf8View.init("hi there")).iterator();
172172/// while (utf8.nextCodepointSlice()) |codepoint| {
173/// std.debug.warn("got codepoint {}\n", codepoint);
173/// std.debug.warn("got codepoint {}\n", .{codepoint});
174174/// }
175175/// ```
176176pub const Utf8View = struct {
lib/std/unicode/throughput_test.zig+6-2
......@@ -24,8 +24,12 @@ pub fn main() !void {
2424 const elapsed_ns_better = timer.lap();
2525 @fence(.SeqCst);
2626
27 std.debug.warn("original utf8ToUtf16Le: elapsed: {} ns ({} ms)\n", elapsed_ns_orig, elapsed_ns_orig / 1000000);
28 std.debug.warn("new utf8ToUtf16Le: elapsed: {} ns ({} ms)\n", elapsed_ns_better, elapsed_ns_better / 1000000);
27 std.debug.warn("original utf8ToUtf16Le: elapsed: {} ns ({} ms)\n", .{
28 elapsed_ns_orig, elapsed_ns_orig / 1000000,
29 });
30 std.debug.warn("new utf8ToUtf16Le: elapsed: {} ns ({} ms)\n", .{
31 elapsed_ns_better, elapsed_ns_better / 1000000,
32 });
2933 asm volatile ("nop"
3034 :
3135 : [a] "r" (&buffer1),
lib/std/valgrind.zig-14
......@@ -114,20 +114,6 @@ pub fn innerThreads(qzz: [*]u8) void {
114114 doClientRequestStmt(.InnerThreads, qzz, 0, 0, 0, 0);
115115}
116116
117//pub fn printf(format: [*]const u8, args: ...) usize {
118// return doClientRequestExpr(0,
119// .PrintfValistByRef,
120// @ptrToInt(format), @ptrToInt(args),
121// 0, 0, 0);
122//}
123
124//pub fn printfBacktrace(format: [*]const u8, args: ...) usize {
125// return doClientRequestExpr(0,
126// .PrintfBacktraceValistByRef,
127// @ptrToInt(format), @ptrToInt(args),
128// 0, 0, 0);
129//}
130
131117pub fn nonSIMDCall0(func: fn (usize) usize) usize {
132118 return doClientRequestExpr(0, .ClientCall0, @ptrToInt(func), 0, 0, 0, 0);
133119}
lib/std/zig/ast.zig+15-9
......@@ -301,7 +301,9 @@ pub const Error = union(enum) {
301301 node: *Node,
302302
303303 pub fn render(self: *const ExpectedCall, tokens: *Tree.TokenList, stream: var) !void {
304 return stream.print("expected " ++ @tagName(@TagType(Node.SuffixOp.Op).Call) ++ ", found {}", @tagName(self.node.id));
304 return stream.print("expected " ++ @tagName(@TagType(Node.SuffixOp.Op).Call) ++ ", found {}", .{
305 @tagName(self.node.id),
306 });
305307 }
306308 };
307309
......@@ -309,7 +311,8 @@ pub const Error = union(enum) {
309311 node: *Node,
310312
311313 pub fn render(self: *const ExpectedCallOrFnProto, tokens: *Tree.TokenList, stream: var) !void {
312 return stream.print("expected " ++ @tagName(@TagType(Node.SuffixOp.Op).Call) ++ " or " ++ @tagName(Node.Id.FnProto) ++ ", found {}", @tagName(self.node.id));
314 return stream.print("expected " ++ @tagName(@TagType(Node.SuffixOp.Op).Call) ++ " or " ++
315 @tagName(Node.Id.FnProto) ++ ", found {}", .{@tagName(self.node.id)});
313316 }
314317 };
315318
......@@ -321,14 +324,14 @@ pub const Error = union(enum) {
321324 const found_token = tokens.at(self.token);
322325 switch (found_token.id) {
323326 .Invalid_ampersands => {
324 return stream.print("`&&` is invalid. Note that `and` is boolean AND.");
327 return stream.print("`&&` is invalid. Note that `and` is boolean AND.", .{});
325328 },
326329 .Invalid => {
327 return stream.print("expected '{}', found invalid bytes", self.expected_id.symbol());
330 return stream.print("expected '{}', found invalid bytes", .{self.expected_id.symbol()});
328331 },
329332 else => {
330333 const token_name = found_token.id.symbol();
331 return stream.print("expected '{}', found '{}'", self.expected_id.symbol(), token_name);
334 return stream.print("expected '{}', found '{}'", .{ self.expected_id.symbol(), token_name });
332335 },
333336 }
334337 }
......@@ -340,7 +343,10 @@ pub const Error = union(enum) {
340343
341344 pub fn render(self: *const ExpectedCommaOrEnd, tokens: *Tree.TokenList, stream: var) !void {
342345 const actual_token = tokens.at(self.token);
343 return stream.print("expected ',' or '{}', found '{}'", self.end_id.symbol(), actual_token.id.symbol());
346 return stream.print("expected ',' or '{}', found '{}'", .{
347 self.end_id.symbol(),
348 actual_token.id.symbol(),
349 });
344350 }
345351 };
346352
......@@ -352,7 +358,7 @@ pub const Error = union(enum) {
352358
353359 pub fn render(self: *const ThisError, tokens: *Tree.TokenList, stream: var) !void {
354360 const actual_token = tokens.at(self.token);
355 return stream.print(msg, actual_token.id.symbol());
361 return stream.print(msg, .{actual_token.id.symbol()});
356362 }
357363 };
358364 }
......@@ -563,10 +569,10 @@ pub const Node = struct {
563569 {
564570 var i: usize = 0;
565571 while (i < indent) : (i += 1) {
566 std.debug.warn(" ");
572 std.debug.warn(" ", .{});
567573 }
568574 }
569 std.debug.warn("{}\n", @tagName(self.id));
575 std.debug.warn("{}\n", .{@tagName(self.id)});
570576
571577 var child_i: usize = 0;
572578 while (self.iterate(child_i)) |child| : (child_i += 1) {
lib/std/zig/parser_test.zig+16-30
......@@ -642,15 +642,6 @@ test "zig fmt: fn decl with trailing comma" {
642642 );
643643}
644644
645test "zig fmt: var_args with trailing comma" {
646 try testCanonical(
647 \\pub fn add(
648 \\ a: ...,
649 \\) void {}
650 \\
651 );
652}
653
654645test "zig fmt: enum decl with no trailing comma" {
655646 try testTransform(
656647 \\const StrLitKind = enum {Normal, C};
......@@ -1750,13 +1741,6 @@ test "zig fmt: call expression" {
17501741 );
17511742}
17521743
1753test "zig fmt: var args" {
1754 try testCanonical(
1755 \\fn print(args: ...) void {}
1756 \\
1757 );
1758}
1759
17601744test "zig fmt: var type" {
17611745 try testCanonical(
17621746 \\fn print(args: var) var {}
......@@ -2705,9 +2689,9 @@ fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *b
27052689 while (error_it.next()) |parse_error| {
27062690 const token = tree.tokens.at(parse_error.loc());
27072691 const loc = tree.tokenLocation(0, parse_error.loc());
2708 try stderr.print("(memory buffer):{}:{}: error: ", loc.line + 1, loc.column + 1);
2692 try stderr.print("(memory buffer):{}:{}: error: ", .{ loc.line + 1, loc.column + 1 });
27092693 try tree.renderError(parse_error, stderr);
2710 try stderr.print("\n{}\n", source[loc.line_start..loc.line_end]);
2694 try stderr.print("\n{}\n", .{source[loc.line_start..loc.line_end]});
27112695 {
27122696 var i: usize = 0;
27132697 while (i < loc.column) : (i += 1) {
......@@ -2743,16 +2727,16 @@ fn testTransform(source: []const u8, expected_source: []const u8) !void {
27432727 var anything_changed: bool = undefined;
27442728 const result_source = try testParse(source, &failing_allocator.allocator, &anything_changed);
27452729 if (!mem.eql(u8, result_source, expected_source)) {
2746 warn("\n====== expected this output: =========\n");
2747 warn("{}", expected_source);
2748 warn("\n======== instead found this: =========\n");
2749 warn("{}", result_source);
2750 warn("\n======================================\n");
2730 warn("\n====== expected this output: =========\n", .{});
2731 warn("{}", .{expected_source});
2732 warn("\n======== instead found this: =========\n", .{});
2733 warn("{}", .{result_source});
2734 warn("\n======================================\n", .{});
27512735 return error.TestFailed;
27522736 }
27532737 const changes_expected = source.ptr != expected_source.ptr;
27542738 if (anything_changed != changes_expected) {
2755 warn("std.zig.render returned {} instead of {}\n", anything_changed, changes_expected);
2739 warn("std.zig.render returned {} instead of {}\n", .{ anything_changed, changes_expected });
27562740 return error.TestFailed;
27572741 }
27582742 std.testing.expect(anything_changed == changes_expected);
......@@ -2772,12 +2756,14 @@ fn testTransform(source: []const u8, expected_source: []const u8) !void {
27722756 if (failing_allocator.allocated_bytes != failing_allocator.freed_bytes) {
27732757 warn(
27742758 "\nfail_index: {}/{}\nallocated bytes: {}\nfreed bytes: {}\nallocations: {}\ndeallocations: {}\n",
2775 fail_index,
2776 needed_alloc_count,
2777 failing_allocator.allocated_bytes,
2778 failing_allocator.freed_bytes,
2779 failing_allocator.allocations,
2780 failing_allocator.deallocations,
2759 .{
2760 fail_index,
2761 needed_alloc_count,
2762 failing_allocator.allocated_bytes,
2763 failing_allocator.freed_bytes,
2764 failing_allocator.allocations,
2765 failing_allocator.deallocations,
2766 },
27812767 );
27822768 return error.MemoryLeakDetected;
27832769 }
lib/std/zig/render.zig+3-3
......@@ -76,7 +76,7 @@ fn renderRoot(
7676 // render all the line comments at the beginning of the file
7777 while (tok_it.next()) |token| {
7878 if (token.id != .LineComment) break;
79 try stream.print("{}\n", mem.trimRight(u8, tree.tokenSlicePtr(token), " "));
79 try stream.print("{}\n", .{mem.trimRight(u8, tree.tokenSlicePtr(token), " ")});
8080 if (tok_it.peek()) |next_token| {
8181 const loc = tree.tokenLocationPtr(token.end, next_token);
8282 if (loc.line >= 2) {
......@@ -1226,7 +1226,7 @@ fn renderExpression(
12261226
12271227 var skip_first_indent = true;
12281228 if (tree.tokens.at(multiline_str_literal.firstToken() - 1).id != .LineComment) {
1229 try stream.print("\n");
1229 try stream.print("\n", .{});
12301230 skip_first_indent = false;
12311231 }
12321232
......@@ -2129,7 +2129,7 @@ fn renderTokenOffset(
21292129
21302130 var loc = tree.tokenLocationPtr(token.end, next_token);
21312131 if (loc.line == 0) {
2132 try stream.print(" {}", mem.trimRight(u8, tree.tokenSlicePtr(next_token), " "));
2132 try stream.print(" {}", .{mem.trimRight(u8, tree.tokenSlicePtr(next_token), " ")});
21332133 offset = 2;
21342134 token = next_token;
21352135 next_token = tree.tokens.at(token_index + offset);
lib/std/zig/tokenizer.zig+2-2
......@@ -330,7 +330,7 @@ pub const Tokenizer = struct {
330330
331331 /// For debugging purposes
332332 pub fn dump(self: *Tokenizer, token: *const Token) void {
333 std.debug.warn("{} \"{}\"\n", @tagName(token.id), self.buffer[token.start..token.end]);
333 std.debug.warn("{} \"{}\"\n", .{ @tagName(token.id), self.buffer[token.start..token.end] });
334334 }
335335
336336 pub fn init(buffer: []const u8) Tokenizer {
......@@ -1576,7 +1576,7 @@ fn testTokenize(source: []const u8, expected_tokens: []const Token.Id) void {
15761576 for (expected_tokens) |expected_token_id| {
15771577 const token = tokenizer.next();
15781578 if (token.id != expected_token_id) {
1579 std.debug.panic("expected {}, found {}\n", @tagName(expected_token_id), @tagName(token.id));
1579 std.debug.panic("expected {}, found {}\n", .{ @tagName(expected_token_id), @tagName(token.id) });
15801580 }
15811581 }
15821582 const last_token = tokenizer.next();
src-self-hosted/arg.zig+6-6
......@@ -98,15 +98,15 @@ pub const Args = struct {
9898 const flag_args = readFlagArguments(allocator, args, flag.required, flag.allowed_set, &i) catch |err| {
9999 switch (err) {
100100 error.ArgumentNotInAllowedSet => {
101 std.debug.warn("argument '{}' is invalid for flag '{}'\n", args[i], arg);
102 std.debug.warn("allowed options are ");
101 std.debug.warn("argument '{}' is invalid for flag '{}'\n", .{ args[i], arg });
102 std.debug.warn("allowed options are ", .{});
103103 for (flag.allowed_set.?) |possible| {
104 std.debug.warn("'{}' ", possible);
104 std.debug.warn("'{}' ", .{possible});
105105 }
106 std.debug.warn("\n");
106 std.debug.warn("\n", .{});
107107 },
108108 error.MissingFlagArguments => {
109 std.debug.warn("missing argument for flag: {}\n", arg);
109 std.debug.warn("missing argument for flag: {}\n", .{arg});
110110 },
111111 else => {},
112112 }
......@@ -134,7 +134,7 @@ pub const Args = struct {
134134 }
135135
136136 // TODO: Better errors with context, global error state and return is sufficient.
137 std.debug.warn("could not match flag: {}\n", arg);
137 std.debug.warn("could not match flag: {}\n", .{arg});
138138 return error.UnknownFlag;
139139 } else {
140140 try parsed.positionals.append(arg);
src-self-hosted/codegen.zig+6-8
......@@ -45,13 +45,11 @@ pub async fn renderToLlvm(comp: *Compilation, fn_val: *Value.Fn, code: *ir.Code)
4545
4646 // Don't use ZIG_VERSION_STRING here. LLVM misparses it when it includes
4747 // the git revision.
48 const producer = try std.Buffer.allocPrint(
49 &code.arena.allocator,
50 "zig {}.{}.{}",
48 const producer = try std.Buffer.allocPrint(&code.arena.allocator, "zig {}.{}.{}", .{
5149 @as(u32, c.ZIG_VERSION_MAJOR),
5250 @as(u32, c.ZIG_VERSION_MINOR),
5351 @as(u32, c.ZIG_VERSION_PATCH),
54 );
52 });
5553 const flags = "";
5654 const runtime_version = 0;
5755 const compile_unit_file = llvm.CreateFile(
......@@ -93,7 +91,7 @@ pub async fn renderToLlvm(comp: *Compilation, fn_val: *Value.Fn, code: *ir.Code)
9391 llvm.DIBuilderFinalize(dibuilder);
9492
9593 if (comp.verbose_llvm_ir) {
96 std.debug.warn("raw module:\n");
94 std.debug.warn("raw module:\n", .{});
9795 llvm.DumpModule(ofile.module);
9896 }
9997
......@@ -120,18 +118,18 @@ pub async fn renderToLlvm(comp: *Compilation, fn_val: *Value.Fn, code: *ir.Code)
120118 is_small,
121119 )) {
122120 if (std.debug.runtime_safety) {
123 std.debug.panic("unable to write object file {}: {s}\n", output_path.toSliceConst(), err_msg);
121 std.debug.panic("unable to write object file {}: {s}\n", .{ output_path.toSliceConst(), err_msg });
124122 }
125123 return error.WritingObjectFileFailed;
126124 }
127125 //validate_inline_fns(g); TODO
128126 fn_val.containing_object = output_path;
129127 if (comp.verbose_llvm_ir) {
130 std.debug.warn("optimized module:\n");
128 std.debug.warn("optimized module:\n", .{});
131129 llvm.DumpModule(ofile.module);
132130 }
133131 if (comp.verbose_link) {
134 std.debug.warn("created {}\n", output_path.toSliceConst());
132 std.debug.warn("created {}\n", .{output_path.toSliceConst()});
135133 }
136134}
137135
src-self-hosted/compilation.zig+12-15
......@@ -807,7 +807,7 @@ pub const Compilation = struct {
807807 root_scope.realpath,
808808 max_src_size,
809809 ) catch |err| {
810 try self.addCompileErrorCli(root_scope.realpath, "unable to open: {}", @errorName(err));
810 try self.addCompileErrorCli(root_scope.realpath, "unable to open: {}", .{@errorName(err)});
811811 return;
812812 };
813813 errdefer self.gpa().free(source_code);
......@@ -878,7 +878,7 @@ pub const Compilation = struct {
878878 try self.addCompileError(tree_scope, Span{
879879 .first = fn_proto.fn_token,
880880 .last = fn_proto.fn_token + 1,
881 }, "missing function name");
881 }, "missing function name", .{});
882882 continue;
883883 };
884884
......@@ -942,7 +942,7 @@ pub const Compilation = struct {
942942 const root_scope = blk: {
943943 // TODO async/await std.fs.realpath
944944 const root_src_real_path = std.fs.realpathAlloc(self.gpa(), root_src_path) catch |err| {
945 try self.addCompileErrorCli(root_src_path, "unable to open: {}", @errorName(err));
945 try self.addCompileErrorCli(root_src_path, "unable to open: {}", .{@errorName(err)});
946946 return;
947947 };
948948 errdefer self.gpa().free(root_src_real_path);
......@@ -991,7 +991,7 @@ pub const Compilation = struct {
991991 defer unanalyzed_code.destroy(comp.gpa());
992992
993993 if (comp.verbose_ir) {
994 std.debug.warn("unanalyzed:\n");
994 std.debug.warn("unanalyzed:\n", .{});
995995 unanalyzed_code.dump();
996996 }
997997
......@@ -1003,7 +1003,7 @@ pub const Compilation = struct {
10031003 errdefer analyzed_code.destroy(comp.gpa());
10041004
10051005 if (comp.verbose_ir) {
1006 std.debug.warn("analyzed:\n");
1006 std.debug.warn("analyzed:\n", .{});
10071007 analyzed_code.dump();
10081008 }
10091009
......@@ -1048,14 +1048,14 @@ pub const Compilation = struct {
10481048
10491049 const gop = try locked_table.getOrPut(decl.name);
10501050 if (gop.found_existing) {
1051 try self.addCompileError(decl.tree_scope, decl.getSpan(), "redefinition of '{}'", decl.name);
1051 try self.addCompileError(decl.tree_scope, decl.getSpan(), "redefinition of '{}'", .{decl.name});
10521052 // TODO note: other definition here
10531053 } else {
10541054 gop.kv.value = decl;
10551055 }
10561056 }
10571057
1058 fn addCompileError(self: *Compilation, tree_scope: *Scope.AstTree, span: Span, comptime fmt: []const u8, args: ...) !void {
1058 fn addCompileError(self: *Compilation, tree_scope: *Scope.AstTree, span: Span, comptime fmt: []const u8, args: var) !void {
10591059 const text = try std.fmt.allocPrint(self.gpa(), fmt, args);
10601060 errdefer self.gpa().free(text);
10611061
......@@ -1065,7 +1065,7 @@ pub const Compilation = struct {
10651065 try self.prelink_group.call(addCompileErrorAsync, self, msg);
10661066 }
10671067
1068 fn addCompileErrorCli(self: *Compilation, realpath: []const u8, comptime fmt: []const u8, args: ...) !void {
1068 fn addCompileErrorCli(self: *Compilation, realpath: []const u8, comptime fmt: []const u8, args: var) !void {
10691069 const text = try std.fmt.allocPrint(self.gpa(), fmt, args);
10701070 errdefer self.gpa().free(text);
10711071
......@@ -1092,12 +1092,9 @@ pub const Compilation = struct {
10921092 defer exported_symbol_names.release();
10931093
10941094 if (try exported_symbol_names.value.put(decl.name, decl)) |other_decl| {
1095 try self.addCompileError(
1096 decl.tree_scope,
1097 decl.getSpan(),
1098 "exported symbol collision: '{}'",
1095 try self.addCompileError(decl.tree_scope, decl.getSpan(), "exported symbol collision: '{}'", .{
10991096 decl.name,
1100 );
1097 });
11011098 // TODO add error note showing location of other symbol
11021099 }
11031100 }
......@@ -1162,7 +1159,7 @@ pub const Compilation = struct {
11621159 const tmp_dir = try self.getTmpDir();
11631160 const file_prefix = self.getRandomFileName();
11641161
1165 const file_name = try std.fmt.allocPrint(self.gpa(), "{}{}", file_prefix[0..], suffix);
1162 const file_name = try std.fmt.allocPrint(self.gpa(), "{}{}", .{ file_prefix[0..], suffix });
11661163 defer self.gpa().free(file_name);
11671164
11681165 const full_path = try std.fs.path.join(self.gpa(), &[_][]const u8{ tmp_dir, file_name[0..] });
......@@ -1303,7 +1300,7 @@ fn generateDeclFn(comp: *Compilation, fn_decl: *Decl.Fn) !void {
13031300 try comp.addCompileError(tree_scope, Span{
13041301 .first = param_decl.firstToken(),
13051302 .last = param_decl.type_node.firstToken(),
1306 }, "missing parameter name");
1303 }, "missing parameter name", .{});
13071304 return error.SemanticAnalysisFailed;
13081305 };
13091306 const param_name = tree_scope.tree.tokenSlice(name_token);
src-self-hosted/dep_tokenizer.zig+15-15
......@@ -38,7 +38,7 @@ pub const Tokenizer = struct {
3838 },
3939 .target => |*target| switch (char) {
4040 '\t', '\n', '\r', ' ' => {
41 return self.errorIllegalChar(self.index, char, "invalid target");
41 return self.errorIllegalChar(self.index, char, "invalid target", .{});
4242 },
4343 '$' => {
4444 self.state = State{ .target_dollar_sign = target.* };
......@@ -59,7 +59,7 @@ pub const Tokenizer = struct {
5959 },
6060 .target_reverse_solidus => |*target| switch (char) {
6161 '\t', '\n', '\r' => {
62 return self.errorIllegalChar(self.index, char, "bad target escape");
62 return self.errorIllegalChar(self.index, char, "bad target escape", .{});
6363 },
6464 ' ', '#', '\\' => {
6565 try target.appendByte(char);
......@@ -84,7 +84,7 @@ pub const Tokenizer = struct {
8484 break; // advance
8585 },
8686 else => {
87 return self.errorIllegalChar(self.index, char, "expecting '$'");
87 return self.errorIllegalChar(self.index, char, "expecting '$'", .{});
8888 },
8989 },
9090 .target_colon => |*target| switch (char) {
......@@ -161,7 +161,7 @@ pub const Tokenizer = struct {
161161 break; // advance
162162 },
163163 else => {
164 return self.errorIllegalChar(self.index, char, "continuation expecting end-of-line");
164 return self.errorIllegalChar(self.index, char, "continuation expecting end-of-line", .{});
165165 },
166166 },
167167 .rhs_continuation_linefeed => switch (char) {
......@@ -170,7 +170,7 @@ pub const Tokenizer = struct {
170170 break; // advance
171171 },
172172 else => {
173 return self.errorIllegalChar(self.index, char, "continuation expecting end-of-line");
173 return self.errorIllegalChar(self.index, char, "continuation expecting end-of-line", .{});
174174 },
175175 },
176176 .prereq_quote => |*prereq| switch (char) {
......@@ -231,7 +231,7 @@ pub const Tokenizer = struct {
231231 return Token{ .id = .prereq, .bytes = bytes };
232232 },
233233 else => {
234 return self.errorIllegalChar(self.index, char, "continuation expecting end-of-line");
234 return self.errorIllegalChar(self.index, char, "continuation expecting end-of-line", .{});
235235 },
236236 },
237237 }
......@@ -249,13 +249,13 @@ pub const Tokenizer = struct {
249249 .rhs_continuation_linefeed,
250250 => {},
251251 .target => |target| {
252 return self.errorPosition(idx, target.toSlice(), "incomplete target");
252 return self.errorPosition(idx, target.toSlice(), "incomplete target", .{});
253253 },
254254 .target_reverse_solidus,
255255 .target_dollar_sign,
256256 => {
257257 const index = self.index - 1;
258 return self.errorIllegalChar(idx, self.bytes[idx], "incomplete escape");
258 return self.errorIllegalChar(idx, self.bytes[idx], "incomplete escape", .{});
259259 },
260260 .target_colon => |target| {
261261 const bytes = target.toSlice();
......@@ -278,7 +278,7 @@ pub const Tokenizer = struct {
278278 self.state = State{ .lhs = {} };
279279 },
280280 .prereq_quote => |prereq| {
281 return self.errorPosition(idx, prereq.toSlice(), "incomplete quoted prerequisite");
281 return self.errorPosition(idx, prereq.toSlice(), "incomplete quoted prerequisite", .{});
282282 },
283283 .prereq => |prereq| {
284284 const bytes = prereq.toSlice();
......@@ -299,29 +299,29 @@ pub const Tokenizer = struct {
299299 return null;
300300 }
301301
302 fn errorf(self: *Tokenizer, comptime fmt: []const u8, args: ...) Error {
302 fn errorf(self: *Tokenizer, comptime fmt: []const u8, args: var) Error {
303303 self.error_text = (try std.Buffer.allocPrint(&self.arena.allocator, fmt, args)).toSlice();
304304 return Error.InvalidInput;
305305 }
306306
307 fn errorPosition(self: *Tokenizer, position: usize, bytes: []const u8, comptime fmt: []const u8, args: ...) Error {
307 fn errorPosition(self: *Tokenizer, position: usize, bytes: []const u8, comptime fmt: []const u8, args: var) Error {
308308 var buffer = try std.Buffer.initSize(&self.arena.allocator, 0);
309309 std.fmt.format(&buffer, anyerror, std.Buffer.append, fmt, args) catch {};
310310 try buffer.append(" '");
311311 var out = makeOutput(std.Buffer.append, &buffer);
312312 try printCharValues(&out, bytes);
313313 try buffer.append("'");
314 std.fmt.format(&buffer, anyerror, std.Buffer.append, " at position {}", position - (bytes.len - 1)) catch {};
314 std.fmt.format(&buffer, anyerror, std.Buffer.append, " at position {}", .{position - (bytes.len - 1)}) catch {};
315315 self.error_text = buffer.toSlice();
316316 return Error.InvalidInput;
317317 }
318318
319 fn errorIllegalChar(self: *Tokenizer, position: usize, char: u8, comptime fmt: []const u8, args: ...) Error {
319 fn errorIllegalChar(self: *Tokenizer, position: usize, char: u8, comptime fmt: []const u8, args: var) Error {
320320 var buffer = try std.Buffer.initSize(&self.arena.allocator, 0);
321321 try buffer.append("illegal char ");
322322 var out = makeOutput(std.Buffer.append, &buffer);
323323 try printUnderstandableChar(&out, char);
324 std.fmt.format(&buffer, anyerror, std.Buffer.append, " at position {}", position) catch {};
324 std.fmt.format(&buffer, anyerror, std.Buffer.append, " at position {}", .{position}) catch {};
325325 if (fmt.len != 0) std.fmt.format(&buffer, anyerror, std.Buffer.append, ": " ++ fmt, args) catch {};
326326 self.error_text = buffer.toSlice();
327327 return Error.InvalidInput;
......@@ -998,7 +998,7 @@ fn printCharValues(out: var, bytes: []const u8) !void {
998998
999999fn printUnderstandableChar(out: var, char: u8) !void {
10001000 if (!std.ascii.isPrint(char) or char == ' ') {
1001 std.fmt.format(out.context, anyerror, out.output, "\\x{X:2}", char) catch {};
1001 std.fmt.format(out.context, anyerror, out.output, "\\x{X:2}", .{char}) catch {};
10021002 } else {
10031003 try out.write("'");
10041004 try out.write(&[_]u8{printable_char_tab[char]});
src-self-hosted/errmsg.zig+5-7
......@@ -231,7 +231,7 @@ pub const Msg = struct {
231231 pub fn printToStream(msg: *const Msg, stream: var, color_on: bool) !void {
232232 switch (msg.data) {
233233 .Cli => {
234 try stream.print("{}:-:-: error: {}\n", msg.realpath, msg.text);
234 try stream.print("{}:-:-: error: {}\n", .{ msg.realpath, msg.text });
235235 return;
236236 },
237237 else => {},
......@@ -254,24 +254,22 @@ pub const Msg = struct {
254254 const start_loc = tree.tokenLocationPtr(0, first_token);
255255 const end_loc = tree.tokenLocationPtr(first_token.end, last_token);
256256 if (!color_on) {
257 try stream.print(
258 "{}:{}:{}: error: {}\n",
257 try stream.print("{}:{}:{}: error: {}\n", .{
259258 path,
260259 start_loc.line + 1,
261260 start_loc.column + 1,
262261 msg.text,
263 );
262 });
264263 return;
265264 }
266265
267 try stream.print(
268 "{}:{}:{}: error: {}\n{}\n",
266 try stream.print("{}:{}:{}: error: {}\n{}\n", .{
269267 path,
270268 start_loc.line + 1,
271269 start_loc.column + 1,
272270 msg.text,
273271 tree.source[start_loc.line_start..start_loc.line_end],
274 );
272 });
275273 try stream.writeByteNTimes(' ', start_loc.column);
276274 try stream.writeByteNTimes('~', last_token.end - first_token.start);
277275 try stream.write("\n");
src-self-hosted/introspect.zig+1-1
......@@ -48,7 +48,7 @@ pub fn resolveZigLibDir(allocator: *mem.Allocator) ![]u8 {
4848 \\Unable to find zig lib directory: {}.
4949 \\Reinstall Zig or use --zig-install-prefix.
5050 \\
51 , @errorName(err));
51 , .{@errorName(err)});
5252
5353 return error.ZigLibDirNotFound;
5454 };
src-self-hosted/ir.zig+38-40
......@@ -32,16 +32,16 @@ pub const IrVal = union(enum) {
3232
3333 pub fn dump(self: IrVal) void {
3434 switch (self) {
35 .Unknown => std.debug.warn("Unknown"),
35 .Unknown => std.debug.warn("Unknown", .{}),
3636 .KnownType => |typ| {
37 std.debug.warn("KnownType(");
37 std.debug.warn("KnownType(", .{});
3838 typ.dump();
39 std.debug.warn(")");
39 std.debug.warn(")", .{});
4040 },
4141 .KnownValue => |value| {
42 std.debug.warn("KnownValue(");
42 std.debug.warn("KnownValue(", .{});
4343 value.dump();
44 std.debug.warn(")");
44 std.debug.warn(")", .{});
4545 },
4646 }
4747 }
......@@ -90,9 +90,9 @@ pub const Inst = struct {
9090 inline while (i < @memberCount(Id)) : (i += 1) {
9191 if (base.id == @field(Id, @memberName(Id, i))) {
9292 const T = @field(Inst, @memberName(Id, i));
93 std.debug.warn("#{} = {}(", base.debug_id, @tagName(base.id));
93 std.debug.warn("#{} = {}(", .{ base.debug_id, @tagName(base.id) });
9494 @fieldParentPtr(T, "base", base).dump();
95 std.debug.warn(")");
95 std.debug.warn(")", .{});
9696 return;
9797 }
9898 }
......@@ -173,7 +173,7 @@ pub const Inst = struct {
173173 if (self.isCompTime()) {
174174 return self.val.KnownValue;
175175 } else {
176 try ira.addCompileError(self.span, "unable to evaluate constant expression");
176 try ira.addCompileError(self.span, "unable to evaluate constant expression", .{});
177177 return error.SemanticAnalysisFailed;
178178 }
179179 }
......@@ -269,11 +269,11 @@ pub const Inst = struct {
269269 const ir_val_init = IrVal.Init.Unknown;
270270
271271 pub fn dump(self: *const Call) void {
272 std.debug.warn("#{}(", self.params.fn_ref.debug_id);
272 std.debug.warn("#{}(", .{self.params.fn_ref.debug_id});
273273 for (self.params.args) |arg| {
274 std.debug.warn("#{},", arg.debug_id);
274 std.debug.warn("#{},", .{arg.debug_id});
275275 }
276 std.debug.warn(")");
276 std.debug.warn(")", .{});
277277 }
278278
279279 pub fn hasSideEffects(self: *const Call) bool {
......@@ -284,19 +284,17 @@ pub const Inst = struct {
284284 const fn_ref = try self.params.fn_ref.getAsParam();
285285 const fn_ref_type = fn_ref.getKnownType();
286286 const fn_type = fn_ref_type.cast(Type.Fn) orelse {
287 try ira.addCompileError(fn_ref.span, "type '{}' not a function", fn_ref_type.name);
287 try ira.addCompileError(fn_ref.span, "type '{}' not a function", .{fn_ref_type.name});
288288 return error.SemanticAnalysisFailed;
289289 };
290290
291291 const fn_type_param_count = fn_type.paramCount();
292292
293293 if (fn_type_param_count != self.params.args.len) {
294 try ira.addCompileError(
295 self.base.span,
296 "expected {} arguments, found {}",
294 try ira.addCompileError(self.base.span, "expected {} arguments, found {}", .{
297295 fn_type_param_count,
298296 self.params.args.len,
299 );
297 });
300298 return error.SemanticAnalysisFailed;
301299 }
302300
......@@ -375,7 +373,7 @@ pub const Inst = struct {
375373 const ir_val_init = IrVal.Init.NoReturn;
376374
377375 pub fn dump(self: *const Return) void {
378 std.debug.warn("#{}", self.params.return_value.debug_id);
376 std.debug.warn("#{}", .{self.params.return_value.debug_id});
379377 }
380378
381379 pub fn hasSideEffects(self: *const Return) bool {
......@@ -509,7 +507,7 @@ pub const Inst = struct {
509507 const ir_val_init = IrVal.Init.Unknown;
510508
511509 pub fn dump(inst: *const VarPtr) void {
512 std.debug.warn("{}", inst.params.var_scope.name);
510 std.debug.warn("{}", .{inst.params.var_scope.name});
513511 }
514512
515513 pub fn hasSideEffects(inst: *const VarPtr) bool {
......@@ -567,7 +565,7 @@ pub const Inst = struct {
567565 const target = try self.params.target.getAsParam();
568566 const target_type = target.getKnownType();
569567 if (target_type.id != .Pointer) {
570 try ira.addCompileError(self.base.span, "dereference of non pointer type '{}'", target_type.name);
568 try ira.addCompileError(self.base.span, "dereference of non pointer type '{}'", .{target_type.name});
571569 return error.SemanticAnalysisFailed;
572570 }
573571 const ptr_type = @fieldParentPtr(Type.Pointer, "base", target_type);
......@@ -705,7 +703,7 @@ pub const Inst = struct {
705703 const ir_val_init = IrVal.Init.Unknown;
706704
707705 pub fn dump(self: *const CheckVoidStmt) void {
708 std.debug.warn("#{}", self.params.target.debug_id);
706 std.debug.warn("#{}", .{self.params.target.debug_id});
709707 }
710708
711709 pub fn hasSideEffects(inst: *const CheckVoidStmt) bool {
......@@ -715,7 +713,7 @@ pub const Inst = struct {
715713 pub fn analyze(self: *const CheckVoidStmt, ira: *Analyze) !*Inst {
716714 const target = try self.params.target.getAsParam();
717715 if (target.getKnownType().id != .Void) {
718 try ira.addCompileError(self.base.span, "expression value is ignored");
716 try ira.addCompileError(self.base.span, "expression value is ignored", .{});
719717 return error.SemanticAnalysisFailed;
720718 }
721719 return ira.irb.buildConstVoid(self.base.scope, self.base.span, true);
......@@ -801,7 +799,7 @@ pub const Inst = struct {
801799 const ir_val_init = IrVal.Init.Unknown;
802800
803801 pub fn dump(inst: *const AddImplicitReturnType) void {
804 std.debug.warn("#{}", inst.params.target.debug_id);
802 std.debug.warn("#{}", .{inst.params.target.debug_id});
805803 }
806804
807805 pub fn hasSideEffects(inst: *const AddImplicitReturnType) bool {
......@@ -826,7 +824,7 @@ pub const Inst = struct {
826824 const ir_val_init = IrVal.Init.Unknown;
827825
828826 pub fn dump(inst: *const TestErr) void {
829 std.debug.warn("#{}", inst.params.target.debug_id);
827 std.debug.warn("#{}", .{inst.params.target.debug_id});
830828 }
831829
832830 pub fn hasSideEffects(inst: *const TestErr) bool {
......@@ -888,7 +886,7 @@ pub const Inst = struct {
888886 const ir_val_init = IrVal.Init.Unknown;
889887
890888 pub fn dump(inst: *const TestCompTime) void {
891 std.debug.warn("#{}", inst.params.target.debug_id);
889 std.debug.warn("#{}", .{inst.params.target.debug_id});
892890 }
893891
894892 pub fn hasSideEffects(inst: *const TestCompTime) bool {
......@@ -971,11 +969,11 @@ pub const Code = struct {
971969 pub fn dump(self: *Code) void {
972970 var bb_i: usize = 0;
973971 for (self.basic_block_list.toSliceConst()) |bb| {
974 std.debug.warn("{s}_{}:\n", bb.name_hint, bb.debug_id);
972 std.debug.warn("{s}_{}:\n", .{ bb.name_hint, bb.debug_id });
975973 for (bb.instruction_list.toSliceConst()) |instr| {
976 std.debug.warn(" ");
974 std.debug.warn(" ", .{});
977975 instr.dump();
978 std.debug.warn("\n");
976 std.debug.warn("\n", .{});
979977 }
980978 }
981979 }
......@@ -993,6 +991,7 @@ pub const Code = struct {
993991 self.tree_scope,
994992 ret_value.span,
995993 "unable to evaluate constant expression",
994 .{},
996995 );
997996 return error.SemanticAnalysisFailed;
998997 } else if (inst.hasSideEffects()) {
......@@ -1000,6 +999,7 @@ pub const Code = struct {
1000999 self.tree_scope,
10011000 inst.span,
10021001 "unable to evaluate constant expression",
1002 .{},
10031003 );
10041004 return error.SemanticAnalysisFailed;
10051005 }
......@@ -1359,7 +1359,7 @@ pub const Builder = struct {
13591359 irb.code.tree_scope,
13601360 src_span,
13611361 "invalid character in string literal: '{c}'",
1362 str_token[bad_index],
1362 .{str_token[bad_index]},
13631363 );
13641364 return error.SemanticAnalysisFailed;
13651365 },
......@@ -1523,6 +1523,7 @@ pub const Builder = struct {
15231523 irb.code.tree_scope,
15241524 src_span,
15251525 "return expression outside function definition",
1526 .{},
15261527 );
15271528 return error.SemanticAnalysisFailed;
15281529 }
......@@ -1533,6 +1534,7 @@ pub const Builder = struct {
15331534 irb.code.tree_scope,
15341535 src_span,
15351536 "cannot return from defer expression",
1537 .{},
15361538 );
15371539 scope_defer_expr.reported_err = true;
15381540 }
......@@ -1629,7 +1631,7 @@ pub const Builder = struct {
16291631 }
16301632 } else |err| switch (err) {
16311633 error.Overflow => {
1632 try irb.comp.addCompileError(irb.code.tree_scope, src_span, "integer too large");
1634 try irb.comp.addCompileError(irb.code.tree_scope, src_span, "integer too large", .{});
16331635 return error.SemanticAnalysisFailed;
16341636 },
16351637 error.OutOfMemory => return error.OutOfMemory,
......@@ -1663,7 +1665,7 @@ pub const Builder = struct {
16631665 // TODO put a variable of same name with invalid type in global scope
16641666 // so that future references to this same name will find a variable with an invalid type
16651667
1666 try irb.comp.addCompileError(irb.code.tree_scope, src_span, "unknown identifier '{}'", name);
1668 try irb.comp.addCompileError(irb.code.tree_scope, src_span, "unknown identifier '{}'", .{name});
16671669 return error.SemanticAnalysisFailed;
16681670 }
16691671
......@@ -2008,7 +2010,7 @@ const Analyze = struct {
20082010 const next_instruction = ira.parent_basic_block.instruction_list.at(ira.instruction_index);
20092011
20102012 if (!next_instruction.is_generated) {
2011 try ira.addCompileError(next_instruction.span, "unreachable code");
2013 try ira.addCompileError(next_instruction.span, "unreachable code", .{});
20122014 break;
20132015 }
20142016 ira.instruction_index += 1;
......@@ -2041,7 +2043,7 @@ const Analyze = struct {
20412043 }
20422044 }
20432045
2044 fn addCompileError(self: *Analyze, span: Span, comptime fmt: []const u8, args: ...) !void {
2046 fn addCompileError(self: *Analyze, span: Span, comptime fmt: []const u8, args: var) !void {
20452047 return self.irb.comp.addCompileError(self.irb.code.tree_scope, span, fmt, args);
20462048 }
20472049
......@@ -2330,12 +2332,10 @@ const Analyze = struct {
23302332 break :cast;
23312333 };
23322334 if (!fits) {
2333 try ira.addCompileError(
2334 source_instr.span,
2335 "integer value '{}' cannot be stored in type '{}'",
2335 try ira.addCompileError(source_instr.span, "integer value '{}' cannot be stored in type '{}'", .{
23362336 from_int,
23372337 dest_type.name,
2338 );
2338 });
23392339 return error.SemanticAnalysisFailed;
23402340 }
23412341
......@@ -2498,12 +2498,10 @@ const Analyze = struct {
24982498 // }
24992499 //}
25002500
2501 try ira.addCompileError(
2502 source_instr.span,
2503 "expected type '{}', found '{}'",
2501 try ira.addCompileError(source_instr.span, "expected type '{}', found '{}'", .{
25042502 dest_type.name,
25052503 from_type.name,
2506 );
2504 });
25072505 //ErrorMsg *parent_msg = ir_add_error_node(ira, source_instr->source_node,
25082506 // buf_sprintf("expected type '%s', found '%s'",
25092507 // buf_ptr(&wanted_type->name),
src-self-hosted/libc_installation.zig+13-15
......@@ -65,7 +65,7 @@ pub const LibCInstallation = struct {
6565 if (line.len == 0 or line[0] == '#') continue;
6666 var line_it = std.mem.separate(line, "=");
6767 const name = line_it.next() orelse {
68 try stderr.print("missing equal sign after field name\n");
68 try stderr.print("missing equal sign after field name\n", .{});
6969 return error.ParseError;
7070 };
7171 const value = line_it.rest();
......@@ -83,7 +83,7 @@ pub const LibCInstallation = struct {
8383 },
8484 else => {
8585 if (value.len == 0) {
86 try stderr.print("field cannot be empty: {}\n", key);
86 try stderr.print("field cannot be empty: {}\n", .{key});
8787 return error.ParseError;
8888 }
8989 const dupe = try std.mem.dupe(allocator, u8, value);
......@@ -97,7 +97,7 @@ pub const LibCInstallation = struct {
9797 }
9898 for (found_keys) |found_key, i| {
9999 if (!found_key.found) {
100 try stderr.print("missing field: {}\n", keys[i]);
100 try stderr.print("missing field: {}\n", .{keys[i]});
101101 return error.ParseError;
102102 }
103103 }
......@@ -105,6 +105,11 @@ pub const LibCInstallation = struct {
105105
106106 pub fn render(self: *const LibCInstallation, out: *std.io.OutStream(fs.File.WriteError)) !void {
107107 @setEvalBranchQuota(4000);
108 const lib_dir = self.lib_dir orelse "";
109 const static_lib_dir = self.static_lib_dir orelse "";
110 const msvc_lib_dir = self.msvc_lib_dir orelse "";
111 const kernel32_lib_dir = self.kernel32_lib_dir orelse "";
112 const dynamic_linker_path = self.dynamic_linker_path orelse util.getDynamicLinkerPath(Target{ .Native = {} });
108113 try out.print(
109114 \\# The directory that contains `stdlib.h`.
110115 \\# On Linux, can be found with: `cc -E -Wp,-v -xc /dev/null`
......@@ -132,14 +137,7 @@ pub const LibCInstallation = struct {
132137 \\# Only needed when targeting Linux.
133138 \\dynamic_linker_path={}
134139 \\
135 ,
136 self.include_dir,
137 self.lib_dir orelse "",
138 self.static_lib_dir orelse "",
139 self.msvc_lib_dir orelse "",
140 self.kernel32_lib_dir orelse "",
141 self.dynamic_linker_path orelse util.getDynamicLinkerPath(Target{ .Native = {} }),
142 );
140 , .{ self.include_dir, lib_dir, static_lib_dir, msvc_lib_dir, kernel32_lib_dir, dynamic_linker_path });
143141 }
144142
145143 /// Finds the default, native libc.
......@@ -255,7 +253,7 @@ pub const LibCInstallation = struct {
255253 for (searches) |search| {
256254 result_buf.shrink(0);
257255 const stream = &std.io.BufferOutStream.init(&result_buf).stream;
258 try stream.print("{}\\Include\\{}\\ucrt", search.path, search.version);
256 try stream.print("{}\\Include\\{}\\ucrt", .{ search.path, search.version });
259257
260258 const stdlib_path = try fs.path.join(
261259 allocator,
......@@ -282,7 +280,7 @@ pub const LibCInstallation = struct {
282280 for (searches) |search| {
283281 result_buf.shrink(0);
284282 const stream = &std.io.BufferOutStream.init(&result_buf).stream;
285 try stream.print("{}\\Lib\\{}\\ucrt\\", search.path, search.version);
283 try stream.print("{}\\Lib\\{}\\ucrt\\", .{ search.path, search.version });
286284 switch (builtin.arch) {
287285 .i386 => try stream.write("x86"),
288286 .x86_64 => try stream.write("x64"),
......@@ -360,7 +358,7 @@ pub const LibCInstallation = struct {
360358 for (searches) |search| {
361359 result_buf.shrink(0);
362360 const stream = &std.io.BufferOutStream.init(&result_buf).stream;
363 try stream.print("{}\\Lib\\{}\\um\\", search.path, search.version);
361 try stream.print("{}\\Lib\\{}\\um\\", .{ search.path, search.version });
364362 switch (builtin.arch) {
365363 .i386 => try stream.write("x86\\"),
366364 .x86_64 => try stream.write("x64\\"),
......@@ -395,7 +393,7 @@ pub const LibCInstallation = struct {
395393/// caller owns returned memory
396394fn ccPrintFileName(allocator: *Allocator, o_file: []const u8, want_dirname: bool) ![]u8 {
397395 const cc_exe = std.os.getenv("CC") orelse "cc";
398 const arg1 = try std.fmt.allocPrint(allocator, "-print-file-name={}", o_file);
396 const arg1 = try std.fmt.allocPrint(allocator, "-print-file-name={}", .{o_file});
399397 defer allocator.free(arg1);
400398 const argv = [_][]const u8{ cc_exe, arg1 };
401399
src-self-hosted/link.zig+20-13
......@@ -75,9 +75,9 @@ pub fn link(comp: *Compilation) !void {
7575 if (comp.verbose_link) {
7676 for (ctx.args.toSliceConst()) |arg, i| {
7777 const space = if (i == 0) "" else " ";
78 std.debug.warn("{}{s}", space, arg);
78 std.debug.warn("{}{s}", .{ space, arg });
7979 }
80 std.debug.warn("\n");
80 std.debug.warn("\n", .{});
8181 }
8282
8383 const extern_ofmt = toExternObjectFormatType(util.getObjectFormat(comp.target));
......@@ -94,7 +94,7 @@ pub fn link(comp: *Compilation) !void {
9494 // TODO capture these messages and pass them through the system, reporting them through the
9595 // event system instead of printing them directly here.
9696 // perhaps try to parse and understand them.
97 std.debug.warn("{}\n", ctx.link_msg.toSliceConst());
97 std.debug.warn("{}\n", .{ctx.link_msg.toSliceConst()});
9898 }
9999 return error.LinkFailed;
100100 }
......@@ -334,13 +334,13 @@ fn constructLinkerArgsCoff(ctx: *Context) !void {
334334
335335 const is_library = ctx.comp.kind == .Lib;
336336
337 const out_arg = try std.fmt.allocPrint(&ctx.arena.allocator, "-OUT:{}\x00", ctx.out_file_path.toSliceConst());
337 const out_arg = try std.fmt.allocPrint(&ctx.arena.allocator, "-OUT:{}\x00", .{ctx.out_file_path.toSliceConst()});
338338 try ctx.args.append(@ptrCast([*:0]const u8, out_arg.ptr));
339339
340340 if (ctx.comp.haveLibC()) {
341 try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmt.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", ctx.libc.msvc_lib_dir.?)).ptr));
342 try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmt.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", ctx.libc.kernel32_lib_dir.?)).ptr));
343 try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmt.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", ctx.libc.lib_dir.?)).ptr));
341 try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmt.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", .{ctx.libc.msvc_lib_dir.?})).ptr));
342 try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmt.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", .{ctx.libc.kernel32_lib_dir.?})).ptr));
343 try ctx.args.append(@ptrCast([*:0]const u8, (try std.fmt.allocPrint(&ctx.arena.allocator, "-LIBPATH:{}\x00", .{ctx.libc.lib_dir.?})).ptr));
344344 }
345345
346346 if (ctx.link_in_crt) {
......@@ -348,17 +348,20 @@ fn constructLinkerArgsCoff(ctx: *Context) !void {
348348 const d_str = if (ctx.comp.build_mode == .Debug) "d" else "";
349349
350350 if (ctx.comp.is_static) {
351 const cmt_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "libcmt{}.lib\x00", d_str);
351 const cmt_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "libcmt{}.lib\x00", .{d_str});
352352 try ctx.args.append(@ptrCast([*:0]const u8, cmt_lib_name.ptr));
353353 } else {
354 const msvcrt_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "msvcrt{}.lib\x00", d_str);
354 const msvcrt_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "msvcrt{}.lib\x00", .{d_str});
355355 try ctx.args.append(@ptrCast([*:0]const u8, msvcrt_lib_name.ptr));
356356 }
357357
358 const vcruntime_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "{}vcruntime{}.lib\x00", lib_str, d_str);
358 const vcruntime_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "{}vcruntime{}.lib\x00", .{
359 lib_str,
360 d_str,
361 });
359362 try ctx.args.append(@ptrCast([*:0]const u8, vcruntime_lib_name.ptr));
360363
361 const crt_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "{}ucrt{}.lib\x00", lib_str, d_str);
364 const crt_lib_name = try std.fmt.allocPrint(&ctx.arena.allocator, "{}ucrt{}.lib\x00", .{ lib_str, d_str });
362365 try ctx.args.append(@ptrCast([*:0]const u8, crt_lib_name.ptr));
363366
364367 // Visual C++ 2015 Conformance Changes
......@@ -508,7 +511,11 @@ fn constructLinkerArgsMachO(ctx: *Context) !void {
508511 .IPhoneOS => try ctx.args.append("-iphoneos_version_min"),
509512 .IPhoneOSSimulator => try ctx.args.append("-ios_simulator_version_min"),
510513 }
511 const ver_str = try std.fmt.allocPrint(&ctx.arena.allocator, "{}.{}.{}\x00", platform.major, platform.minor, platform.micro);
514 const ver_str = try std.fmt.allocPrint(&ctx.arena.allocator, "{}.{}.{}\x00", .{
515 platform.major,
516 platform.minor,
517 platform.micro,
518 });
512519 try ctx.args.append(@ptrCast([*:0]const u8, ver_str.ptr));
513520
514521 if (ctx.comp.kind == .Exe) {
......@@ -584,7 +591,7 @@ fn constructLinkerArgsMachO(ctx: *Context) !void {
584591 try ctx.args.append("-lSystem");
585592 } else {
586593 if (mem.indexOfScalar(u8, lib.name, '/') == null) {
587 const arg = try std.fmt.allocPrint(&ctx.arena.allocator, "-l{}\x00", lib.name);
594 const arg = try std.fmt.allocPrint(&ctx.arena.allocator, "-l{}\x00", .{lib.name});
588595 try ctx.args.append(@ptrCast([*:0]const u8, arg.ptr));
589596 } else {
590597 const arg = try std.cstr.addNullByte(&ctx.arena.allocator, lib.name);
src-self-hosted/main.zig+24-25
......@@ -128,7 +128,7 @@ pub fn main() !void {
128128 }
129129 }
130130
131 try stderr.print("unknown command: {}\n\n", args[1]);
131 try stderr.print("unknown command: {}\n\n", .{args[1]});
132132 try stderr.write(usage);
133133 process.argsFree(allocator, args);
134134 process.exit(1);
......@@ -329,14 +329,14 @@ fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Co
329329 if (cur_pkg.parent) |parent| {
330330 cur_pkg = parent;
331331 } else {
332 try stderr.print("encountered --pkg-end with no matching --pkg-begin\n");
332 try stderr.print("encountered --pkg-end with no matching --pkg-begin\n", .{});
333333 process.exit(1);
334334 }
335335 }
336336 }
337337
338338 if (cur_pkg.parent != null) {
339 try stderr.print("unmatched --pkg-begin\n");
339 try stderr.print("unmatched --pkg-begin\n", .{});
340340 process.exit(1);
341341 }
342342
......@@ -345,7 +345,7 @@ fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Co
345345 0 => null,
346346 1 => flags.positionals.at(0),
347347 else => {
348 try stderr.print("unexpected extra parameter: {}\n", flags.positionals.at(1));
348 try stderr.print("unexpected extra parameter: {}\n", .{flags.positionals.at(1)});
349349 process.exit(1);
350350 },
351351 };
......@@ -477,13 +477,13 @@ fn processBuildEvents(comp: *Compilation, color: errmsg.Color) void {
477477
478478 switch (build_event) {
479479 .Ok => {
480 stderr.print("Build {} succeeded\n", count) catch process.exit(1);
480 stderr.print("Build {} succeeded\n", .{count}) catch process.exit(1);
481481 },
482482 .Error => |err| {
483 stderr.print("Build {} failed: {}\n", count, @errorName(err)) catch process.exit(1);
483 stderr.print("Build {} failed: {}\n", .{ count, @errorName(err) }) catch process.exit(1);
484484 },
485485 .Fail => |msgs| {
486 stderr.print("Build {} compile errors:\n", count) catch process.exit(1);
486 stderr.print("Build {} compile errors:\n", .{count}) catch process.exit(1);
487487 for (msgs) |msg| {
488488 defer msg.destroy();
489489 msg.printToFile(stderr_file, color) catch process.exit(1);
......@@ -544,12 +544,11 @@ const Fmt = struct {
544544
545545fn parseLibcPaths(allocator: *Allocator, libc: *LibCInstallation, libc_paths_file: []const u8) void {
546546 libc.parse(allocator, libc_paths_file, stderr) catch |err| {
547 stderr.print(
548 "Unable to parse libc path file '{}': {}.\n" ++
549 "Try running `zig libc` to see an example for the native target.\n",
547 stderr.print("Unable to parse libc path file '{}': {}.\n" ++
548 "Try running `zig libc` to see an example for the native target.\n", .{
550549 libc_paths_file,
551550 @errorName(err),
552 ) catch {};
551 }) catch {};
553552 process.exit(1);
554553 };
555554}
......@@ -563,7 +562,7 @@ fn cmdLibC(allocator: *Allocator, args: []const []const u8) !void {
563562 return;
564563 },
565564 else => {
566 try stderr.print("unexpected extra parameter: {}\n", args[1]);
565 try stderr.print("unexpected extra parameter: {}\n", .{args[1]});
567566 process.exit(1);
568567 },
569568 }
......@@ -572,7 +571,7 @@ fn cmdLibC(allocator: *Allocator, args: []const []const u8) !void {
572571 defer zig_compiler.deinit();
573572
574573 const libc = zig_compiler.getNativeLibC() catch |err| {
575 stderr.print("unable to find libc: {}\n", @errorName(err)) catch {};
574 stderr.print("unable to find libc: {}\n", .{@errorName(err)}) catch {};
576575 process.exit(1);
577576 };
578577 libc.render(stdout) catch process.exit(1);
......@@ -614,7 +613,7 @@ fn cmdFmt(allocator: *Allocator, args: []const []const u8) !void {
614613 defer allocator.free(source_code);
615614
616615 const tree = std.zig.parse(allocator, source_code) catch |err| {
617 try stderr.print("error parsing stdin: {}\n", err);
616 try stderr.print("error parsing stdin: {}\n", .{err});
618617 process.exit(1);
619618 };
620619 defer tree.deinit();
......@@ -718,7 +717,7 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtErro
718717 },
719718 else => {
720719 // TODO lock stderr printing
721 try stderr.print("unable to open '{}': {}\n", file_path, err);
720 try stderr.print("unable to open '{}': {}\n", .{ file_path, err });
722721 fmt.any_error = true;
723722 return;
724723 },
......@@ -726,7 +725,7 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtErro
726725 defer fmt.allocator.free(source_code);
727726
728727 const tree = std.zig.parse(fmt.allocator, source_code) catch |err| {
729 try stderr.print("error parsing file '{}': {}\n", file_path, err);
728 try stderr.print("error parsing file '{}': {}\n", .{ file_path, err });
730729 fmt.any_error = true;
731730 return;
732731 };
......@@ -747,7 +746,7 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtErro
747746 if (check_mode) {
748747 const anything_changed = try std.zig.render(fmt.allocator, io.null_out_stream, tree);
749748 if (anything_changed) {
750 try stderr.print("{}\n", file_path);
749 try stderr.print("{}\n", .{file_path});
751750 fmt.any_error = true;
752751 }
753752 } else {
......@@ -757,7 +756,7 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtErro
757756
758757 const anything_changed = try std.zig.render(fmt.allocator, baf.stream(), tree);
759758 if (anything_changed) {
760 try stderr.print("{}\n", file_path);
759 try stderr.print("{}\n", .{file_path});
761760 try baf.finish();
762761 }
763762 }
......@@ -774,7 +773,7 @@ fn cmdTargets(allocator: *Allocator, args: []const []const u8) !void {
774773 // NOTE: Cannot use empty string, see #918.
775774 comptime const native_str = if (comptime mem.eql(u8, arch_tag, @tagName(builtin.arch))) " (native)\n" else "\n";
776775
777 try stdout.print(" {}{}", arch_tag, native_str);
776 try stdout.print(" {}{}", .{ arch_tag, native_str });
778777 }
779778 }
780779 try stdout.write("\n");
......@@ -787,7 +786,7 @@ fn cmdTargets(allocator: *Allocator, args: []const []const u8) !void {
787786 // NOTE: Cannot use empty string, see #918.
788787 comptime const native_str = if (comptime mem.eql(u8, os_tag, @tagName(builtin.os))) " (native)\n" else "\n";
789788
790 try stdout.print(" {}{}", os_tag, native_str);
789 try stdout.print(" {}{}", .{ os_tag, native_str });
791790 }
792791 }
793792 try stdout.write("\n");
......@@ -800,13 +799,13 @@ fn cmdTargets(allocator: *Allocator, args: []const []const u8) !void {
800799 // NOTE: Cannot use empty string, see #918.
801800 comptime const native_str = if (comptime mem.eql(u8, abi_tag, @tagName(builtin.abi))) " (native)\n" else "\n";
802801
803 try stdout.print(" {}{}", abi_tag, native_str);
802 try stdout.print(" {}{}", .{ abi_tag, native_str });
804803 }
805804 }
806805}
807806
808807fn cmdVersion(allocator: *Allocator, args: []const []const u8) !void {
809 try stdout.print("{}\n", std.mem.toSliceConst(u8, c.ZIG_VERSION_STRING));
808 try stdout.print("{}\n", .{std.mem.toSliceConst(u8, c.ZIG_VERSION_STRING)});
810809}
811810
812811const args_test_spec = [_]Flag{Flag.Bool("--help")};
......@@ -865,7 +864,7 @@ fn cmdInternal(allocator: *Allocator, args: []const []const u8) !void {
865864 }
866865 }
867866
868 try stderr.print("unknown sub command: {}\n\n", args[0]);
867 try stderr.print("unknown sub command: {}\n\n", .{args[0]});
869868 try stderr.write(usage_internal);
870869}
871870
......@@ -878,14 +877,14 @@ fn cmdInternalBuildInfo(allocator: *Allocator, args: []const []const u8) !void {
878877 \\ZIG_LLVM_CONFIG_EXE {}
879878 \\ZIG_DIA_GUIDS_LIB {}
880879 \\
881 ,
880 , .{
882881 std.mem.toSliceConst(u8, c.ZIG_CMAKE_BINARY_DIR),
883882 std.mem.toSliceConst(u8, c.ZIG_CXX_COMPILER),
884883 std.mem.toSliceConst(u8, c.ZIG_LLD_INCLUDE_PATH),
885884 std.mem.toSliceConst(u8, c.ZIG_LLD_LIBRARIES),
886885 std.mem.toSliceConst(u8, c.ZIG_LLVM_CONFIG_EXE),
887886 std.mem.toSliceConst(u8, c.ZIG_DIA_GUIDS_LIB),
888 );
887 });
889888}
890889
891890const CliPkg = struct {
src-self-hosted/stage1.zig+7-7
......@@ -149,7 +149,7 @@ export fn stage2_fmt(argc: c_int, argv: [*]const [*:0]const u8) c_int {
149149 fmtMain(argc, argv) catch unreachable;
150150 } else {
151151 fmtMain(argc, argv) catch |e| {
152 std.debug.warn("{}\n", @errorName(e));
152 std.debug.warn("{}\n", .{@errorName(e)});
153153 return -1;
154154 };
155155 }
......@@ -205,7 +205,7 @@ fn fmtMain(argc: c_int, argv: [*]const [*:0]const u8) !void {
205205 defer allocator.free(source_code);
206206
207207 const tree = std.zig.parse(allocator, source_code) catch |err| {
208 try stderr.print("error parsing stdin: {}\n", err);
208 try stderr.print("error parsing stdin: {}\n", .{err});
209209 process.exit(1);
210210 };
211211 defer tree.deinit();
......@@ -294,7 +294,7 @@ fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtError!void
294294 },
295295 else => {
296296 // TODO lock stderr printing
297 try stderr.print("unable to open '{}': {}\n", file_path, err);
297 try stderr.print("unable to open '{}': {}\n", .{ file_path, err });
298298 fmt.any_error = true;
299299 return;
300300 },
......@@ -302,7 +302,7 @@ fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtError!void
302302 defer fmt.allocator.free(source_code);
303303
304304 const tree = std.zig.parse(fmt.allocator, source_code) catch |err| {
305 try stderr.print("error parsing file '{}': {}\n", file_path, err);
305 try stderr.print("error parsing file '{}': {}\n", .{ file_path, err });
306306 fmt.any_error = true;
307307 return;
308308 };
......@@ -320,7 +320,7 @@ fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtError!void
320320 if (check_mode) {
321321 const anything_changed = try std.zig.render(fmt.allocator, io.null_out_stream, tree);
322322 if (anything_changed) {
323 try stderr.print("{}\n", file_path);
323 try stderr.print("{}\n", .{file_path});
324324 fmt.any_error = true;
325325 }
326326 } else {
......@@ -329,7 +329,7 @@ fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtError!void
329329
330330 const anything_changed = try std.zig.render(fmt.allocator, baf.stream(), tree);
331331 if (anything_changed) {
332 try stderr.print("{}\n", file_path);
332 try stderr.print("{}\n", .{file_path});
333333 try baf.finish();
334334 }
335335 }
......@@ -374,7 +374,7 @@ fn printErrMsgToFile(
374374 const text = text_buf.toOwnedSlice();
375375
376376 const stream = &file.outStream().stream;
377 try stream.print("{}:{}:{}: error: {}\n", path, start_loc.line + 1, start_loc.column + 1, text);
377 try stream.print("{}:{}:{}: error: {}\n", .{ path, start_loc.line + 1, start_loc.column + 1, text });
378378
379379 if (!color_on) return;
380380
src-self-hosted/translate_c.zig+49-30
......@@ -125,7 +125,7 @@ const Context = struct {
125125
126126 const line = ZigClangSourceManager_getSpellingLineNumber(c.source_manager, spelling_loc);
127127 const column = ZigClangSourceManager_getSpellingColumnNumber(c.source_manager, spelling_loc);
128 return std.fmt.allocPrint(c.a(), "{}:{}:{}", filename, line, column);
128 return std.fmt.allocPrint(c.a(), "{}:{}:{}", .{ filename, line, column });
129129 }
130130};
131131
......@@ -228,20 +228,20 @@ fn declVisitor(c: *Context, decl: *const ZigClangDecl) Error!void {
228228 return visitFnDecl(c, @ptrCast(*const ZigClangFunctionDecl, decl));
229229 },
230230 .Typedef => {
231 try emitWarning(c, ZigClangDecl_getLocation(decl), "TODO implement translate-c for typedefs");
231 try emitWarning(c, ZigClangDecl_getLocation(decl), "TODO implement translate-c for typedefs", .{});
232232 },
233233 .Enum => {
234 try emitWarning(c, ZigClangDecl_getLocation(decl), "TODO implement translate-c for enums");
234 try emitWarning(c, ZigClangDecl_getLocation(decl), "TODO implement translate-c for enums", .{});
235235 },
236236 .Record => {
237 try emitWarning(c, ZigClangDecl_getLocation(decl), "TODO implement translate-c for structs");
237 try emitWarning(c, ZigClangDecl_getLocation(decl), "TODO implement translate-c for structs", .{});
238238 },
239239 .Var => {
240 try emitWarning(c, ZigClangDecl_getLocation(decl), "TODO implement translate-c for variables");
240 try emitWarning(c, ZigClangDecl_getLocation(decl), "TODO implement translate-c for variables", .{});
241241 },
242242 else => {
243243 const decl_name = try c.str(ZigClangDecl_getDeclKindName(decl));
244 try emitWarning(c, ZigClangDecl_getLocation(decl), "ignoring {} declaration", decl_name);
244 try emitWarning(c, ZigClangDecl_getLocation(decl), "ignoring {} declaration", .{decl_name});
245245 },
246246 }
247247}
......@@ -264,7 +264,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void {
264264 .is_export = switch (storage_class) {
265265 .None => has_body and c.mode != .import,
266266 .Extern, .Static => false,
267 .PrivateExtern => return failDecl(c, fn_decl_loc, fn_name, "unsupported storage class: private extern"),
267 .PrivateExtern => return failDecl(c, fn_decl_loc, fn_name, "unsupported storage class: private extern", .{}),
268268 .Auto => unreachable, // Not legal on functions
269269 .Register => unreachable, // Not legal on functions
270270 },
......@@ -274,7 +274,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void {
274274 const fn_proto_type = @ptrCast(*const ZigClangFunctionProtoType, fn_type);
275275 break :blk transFnProto(rp, fn_proto_type, fn_decl_loc, decl_ctx, true) catch |err| switch (err) {
276276 error.UnsupportedType => {
277 return failDecl(c, fn_decl_loc, fn_name, "unable to resolve prototype of function");
277 return failDecl(c, fn_decl_loc, fn_name, "unable to resolve prototype of function", .{});
278278 },
279279 error.OutOfMemory => |e| return e,
280280 };
......@@ -283,7 +283,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void {
283283 const fn_no_proto_type = @ptrCast(*const ZigClangFunctionType, fn_type);
284284 break :blk transFnNoProto(rp, fn_no_proto_type, fn_decl_loc, decl_ctx, true) catch |err| switch (err) {
285285 error.UnsupportedType => {
286 return failDecl(c, fn_decl_loc, fn_name, "unable to resolve prototype of function");
286 return failDecl(c, fn_decl_loc, fn_name, "unable to resolve prototype of function", .{});
287287 },
288288 error.OutOfMemory => |e| return e,
289289 };
......@@ -302,7 +302,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void {
302302 error.OutOfMemory => |e| return e,
303303 error.UnsupportedTranslation,
304304 error.UnsupportedType,
305 => return failDecl(c, fn_decl_loc, fn_name, "unable to translate function"),
305 => return failDecl(c, fn_decl_loc, fn_name, "unable to translate function", .{}),
306306 };
307307 assert(result.node.id == ast.Node.Id.Block);
308308 proto_node.body_node = result.node;
......@@ -344,7 +344,7 @@ fn transStmt(
344344 error.UnsupportedTranslation,
345345 ZigClangStmt_getBeginLoc(stmt),
346346 "TODO implement translation of stmt class {}",
347 @tagName(sc),
347 .{@tagName(sc)},
348348 );
349349 },
350350 }
......@@ -364,7 +364,7 @@ fn transBinaryOperator(
364364 error.UnsupportedTranslation,
365365 ZigClangBinaryOperator_getBeginLoc(stmt),
366366 "TODO: handle more C binary operators: {}",
367 op,
367 .{op},
368368 ),
369369 .Assign => return TransResult{
370370 .node = &(try transCreateNodeAssign(rp, scope, result_used, ZigClangBinaryOperator_getLHS(stmt), ZigClangBinaryOperator_getRHS(stmt))).base,
......@@ -415,7 +415,7 @@ fn transBinaryOperator(
415415 error.UnsupportedTranslation,
416416 ZigClangBinaryOperator_getBeginLoc(stmt),
417417 "TODO: handle more C binary operators: {}",
418 op,
418 .{op},
419419 ),
420420 .MulAssign,
421421 .DivAssign,
......@@ -567,7 +567,7 @@ fn transDeclStmt(rp: RestorePoint, parent_scope: *Scope, stmt: *const ZigClangDe
567567 error.UnsupportedTranslation,
568568 ZigClangStmt_getBeginLoc(@ptrCast(*const ZigClangStmt, stmt)),
569569 "TODO implement translation of DeclStmt kind {}",
570 @tagName(kind),
570 .{@tagName(kind)},
571571 ),
572572 }
573573 }
......@@ -636,7 +636,7 @@ fn transImplicitCastExpr(
636636 error.UnsupportedTranslation,
637637 ZigClangStmt_getBeginLoc(@ptrCast(*const ZigClangStmt, expr)),
638638 "TODO implement translation of CastKind {}",
639 @tagName(kind),
639 .{@tagName(kind)},
640640 ),
641641 }
642642}
......@@ -650,7 +650,7 @@ fn transIntegerLiteral(
650650 var eval_result: ZigClangExprEvalResult = undefined;
651651 if (!ZigClangIntegerLiteral_EvaluateAsInt(expr, &eval_result, rp.c.clang_context)) {
652652 const loc = ZigClangIntegerLiteral_getBeginLoc(expr);
653 return revertAndWarn(rp, error.UnsupportedTranslation, loc, "invalid integer literal");
653 return revertAndWarn(rp, error.UnsupportedTranslation, loc, "invalid integer literal", .{});
654654 }
655655 const node = try transCreateNodeAPInt(rp.c, ZigClangAPValue_getInt(&eval_result.Val));
656656 const res = TransResult{
......@@ -719,7 +719,7 @@ fn transStringLiteral(
719719 error.UnsupportedTranslation,
720720 ZigClangStmt_getBeginLoc(@ptrCast(*const ZigClangStmt, stmt)),
721721 "TODO: support string literal kind {}",
722 kind,
722 .{kind},
723723 ),
724724 }
725725}
......@@ -751,7 +751,7 @@ fn escapeChar(c: u8, char_buf: *[4]u8) []const u8 {
751751 '\n' => return "\\n"[0..],
752752 '\r' => return "\\r"[0..],
753753 '\t' => return "\\t"[0..],
754 else => return std.fmt.bufPrint(char_buf[0..], "\\x{x:2}", c) catch unreachable,
754 else => return std.fmt.bufPrint(char_buf[0..], "\\x{x:2}", .{c}) catch unreachable,
755755 };
756756 std.mem.copy(u8, char_buf, escaped);
757757 return char_buf[0..escaped.len];
......@@ -1016,7 +1016,13 @@ fn transCreateNodeAssign(
10161016 // zig: lhs = _tmp;
10171017 // zig: break :x _tmp
10181018 // zig: })
1019 return revertAndWarn(rp, error.UnsupportedTranslation, ZigClangExpr_getBeginLoc(lhs), "TODO: worst case assign op expr");
1019 return revertAndWarn(
1020 rp,
1021 error.UnsupportedTranslation,
1022 ZigClangExpr_getBeginLoc(lhs),
1023 "TODO: worst case assign op expr",
1024 .{},
1025 );
10201026}
10211027
10221028fn transCreateNodeBuiltinFnCall(c: *Context, name: []const u8) !*ast.Node.BuiltinCall {
......@@ -1211,7 +1217,7 @@ fn transType(rp: RestorePoint, ty: *const ZigClangType, source_loc: ZigClangSour
12111217 .Float128 => return appendIdentifier(rp.c, "f128"),
12121218 .Float16 => return appendIdentifier(rp.c, "f16"),
12131219 .LongDouble => return appendIdentifier(rp.c, "c_longdouble"),
1214 else => return revertAndWarn(rp, error.UnsupportedType, source_loc, "unsupported builtin type"),
1220 else => return revertAndWarn(rp, error.UnsupportedType, source_loc, "unsupported builtin type", .{}),
12151221 }
12161222 },
12171223 .FunctionProto => {
......@@ -1253,7 +1259,7 @@ fn transType(rp: RestorePoint, ty: *const ZigClangType, source_loc: ZigClangSour
12531259 },
12541260 else => {
12551261 const type_name = rp.c.str(ZigClangType_getTypeClassName(ty));
1256 return revertAndWarn(rp, error.UnsupportedType, source_loc, "unsupported type: '{}'", type_name);
1262 return revertAndWarn(rp, error.UnsupportedType, source_loc, "unsupported type: '{}'", .{type_name});
12571263 },
12581264 }
12591265}
......@@ -1275,7 +1281,13 @@ fn transCC(
12751281 switch (clang_cc) {
12761282 .C => return CallingConvention.C,
12771283 .X86StdCall => return CallingConvention.Stdcall,
1278 else => return revertAndWarn(rp, error.UnsupportedType, source_loc, "unsupported calling convention: {}", @tagName(clang_cc)),
1284 else => return revertAndWarn(
1285 rp,
1286 error.UnsupportedType,
1287 source_loc,
1288 "unsupported calling convention: {}",
1289 .{@tagName(clang_cc)},
1290 ),
12791291 }
12801292}
12811293
......@@ -1292,7 +1304,13 @@ fn transFnProto(
12921304 const param_count: usize = ZigClangFunctionProtoType_getNumParams(fn_proto_ty);
12931305 var i: usize = 0;
12941306 while (i < param_count) : (i += 1) {
1295 return revertAndWarn(rp, error.UnsupportedType, source_loc, "TODO: implement parameters for FunctionProto in transType");
1307 return revertAndWarn(
1308 rp,
1309 error.UnsupportedType,
1310 source_loc,
1311 "TODO: implement parameters for FunctionProto in transType",
1312 .{},
1313 );
12961314 }
12971315
12981316 return finishTransFnProto(rp, fn_ty, source_loc, fn_decl_context, is_var_args, cc, is_pub);
......@@ -1350,7 +1368,7 @@ fn finishTransFnProto(
13501368 } else {
13511369 break :blk transQualType(rp, return_qt, source_loc) catch |err| switch (err) {
13521370 error.UnsupportedType => {
1353 try emitWarning(rp.c, source_loc, "unsupported function proto return type");
1371 try emitWarning(rp.c, source_loc, "unsupported function proto return type", .{});
13541372 return err;
13551373 },
13561374 error.OutOfMemory => |e| return e,
......@@ -1397,18 +1415,19 @@ fn revertAndWarn(
13971415 err: var,
13981416 source_loc: ZigClangSourceLocation,
13991417 comptime format: []const u8,
1400 args: ...,
1418 args: var,
14011419) (@typeOf(err) || error{OutOfMemory}) {
14021420 rp.activate();
14031421 try emitWarning(rp.c, source_loc, format, args);
14041422 return err;
14051423}
14061424
1407fn emitWarning(c: *Context, loc: ZigClangSourceLocation, comptime format: []const u8, args: ...) !void {
1408 _ = try appendTokenFmt(c, .LineComment, "// {}: warning: " ++ format, c.locStr(loc), args);
1425fn emitWarning(c: *Context, loc: ZigClangSourceLocation, comptime format: []const u8, args: var) !void {
1426 const args_prefix = .{c.locStr(loc)};
1427 _ = try appendTokenFmt(c, .LineComment, "// {}: warning: " ++ format, args_prefix ++ args);
14091428}
14101429
1411fn failDecl(c: *Context, loc: ZigClangSourceLocation, name: []const u8, comptime format: []const u8, args: ...) !void {
1430fn failDecl(c: *Context, loc: ZigClangSourceLocation, name: []const u8, comptime format: []const u8, args: var) !void {
14121431 // const name = @compileError(msg);
14131432 const const_tok = try appendToken(c, .Keyword_const, "const");
14141433 const name_tok = try appendToken(c, .Identifier, name);
......@@ -1456,10 +1475,10 @@ fn failDecl(c: *Context, loc: ZigClangSourceLocation, name: []const u8, comptime
14561475}
14571476
14581477fn appendToken(c: *Context, token_id: Token.Id, bytes: []const u8) !ast.TokenIndex {
1459 return appendTokenFmt(c, token_id, "{}", bytes);
1478 return appendTokenFmt(c, token_id, "{}", .{bytes});
14601479}
14611480
1462fn appendTokenFmt(c: *Context, token_id: Token.Id, comptime format: []const u8, args: ...) !ast.TokenIndex {
1481fn appendTokenFmt(c: *Context, token_id: Token.Id, comptime format: []const u8, args: var) !ast.TokenIndex {
14631482 const S = struct {
14641483 fn callback(context: *Context, bytes: []const u8) error{OutOfMemory}!void {
14651484 return context.source_buffer.append(bytes);
src-self-hosted/type.zig+11-15
......@@ -399,7 +399,7 @@ pub const Type = struct {
399399 .Generic => |generic| {
400400 self.non_key = NonKey{ .Generic = {} };
401401 const cc_str = ccFnTypeStr(generic.cc);
402 try name_stream.print("{}fn(", cc_str);
402 try name_stream.print("{}fn(", .{cc_str});
403403 var param_i: usize = 0;
404404 while (param_i < generic.param_count) : (param_i += 1) {
405405 const arg = if (param_i == 0) "var" else ", var";
......@@ -407,7 +407,7 @@ pub const Type = struct {
407407 }
408408 try name_stream.write(")");
409409 if (key.alignment) |alignment| {
410 try name_stream.print(" align({})", alignment);
410 try name_stream.print(" align({})", .{alignment});
411411 }
412412 try name_stream.write(" var");
413413 },
......@@ -416,7 +416,7 @@ pub const Type = struct {
416416 .Normal = NonKey.Normal{ .variable_list = std.ArrayList(*Scope.Var).init(comp.gpa()) },
417417 };
418418 const cc_str = ccFnTypeStr(normal.cc);
419 try name_stream.print("{}fn(", cc_str);
419 try name_stream.print("{}fn(", .{cc_str});
420420 for (normal.params) |param, i| {
421421 if (i != 0) try name_stream.write(", ");
422422 if (param.is_noalias) try name_stream.write("noalias ");
......@@ -428,9 +428,9 @@ pub const Type = struct {
428428 }
429429 try name_stream.write(")");
430430 if (key.alignment) |alignment| {
431 try name_stream.print(" align({})", alignment);
431 try name_stream.print(" align({})", .{alignment});
432432 }
433 try name_stream.print(" {}", normal.return_type.name);
433 try name_stream.print(" {}", .{normal.return_type.name});
434434 },
435435 }
436436
......@@ -584,7 +584,7 @@ pub const Type = struct {
584584 errdefer comp.gpa().destroy(self);
585585
586586 const u_or_i = "ui"[@boolToInt(key.is_signed)];
587 const name = try std.fmt.allocPrint(comp.gpa(), "{c}{}", u_or_i, key.bit_count);
587 const name = try std.fmt.allocPrint(comp.gpa(), "{c}{}", .{ u_or_i, key.bit_count });
588588 errdefer comp.gpa().free(name);
589589
590590 self.base.init(comp, .Int, name);
......@@ -767,23 +767,19 @@ pub const Type = struct {
767767 .Non => "",
768768 };
769769 const name = switch (self.key.alignment) {
770 .Abi => try std.fmt.allocPrint(
771 comp.gpa(),
772 "{}{}{}{}",
770 .Abi => try std.fmt.allocPrint(comp.gpa(), "{}{}{}{}", .{
773771 size_str,
774772 mut_str,
775773 vol_str,
776774 self.key.child_type.name,
777 ),
778 .Override => |alignment| try std.fmt.allocPrint(
779 comp.gpa(),
780 "{}align<{}> {}{}{}",
775 }),
776 .Override => |alignment| try std.fmt.allocPrint(comp.gpa(), "{}align<{}> {}{}{}", .{
781777 size_str,
782778 alignment,
783779 mut_str,
784780 vol_str,
785781 self.key.child_type.name,
786 ),
782 }),
787783 };
788784 errdefer comp.gpa().free(name);
789785
......@@ -852,7 +848,7 @@ pub const Type = struct {
852848 };
853849 errdefer comp.gpa().destroy(self);
854850
855 const name = try std.fmt.allocPrint(comp.gpa(), "[{}]{}", key.len, key.elem_type.name);
851 const name = try std.fmt.allocPrint(comp.gpa(), "[{}]{}", .{ key.len, key.elem_type.name });
856852 errdefer comp.gpa().free(name);
857853
858854 self.base.init(comp, .Array, name);
src-self-hosted/util.zig+2-2
......@@ -175,7 +175,7 @@ pub fn llvmTargetFromTriple(triple: std.Buffer) !*llvm.Target {
175175 var result: *llvm.Target = undefined;
176176 var err_msg: [*:0]u8 = undefined;
177177 if (llvm.GetTargetFromTriple(triple.toSlice(), &result, &err_msg) != 0) {
178 std.debug.warn("triple: {s} error: {s}\n", triple.toSlice(), err_msg);
178 std.debug.warn("triple: {s} error: {s}\n", .{ triple.toSlice(), err_msg });
179179 return error.UnsupportedTarget;
180180 }
181181 return result;
......@@ -206,7 +206,7 @@ pub fn getTriple(allocator: *std.mem.Allocator, self: std.Target) !std.Buffer {
206206 const env_name = if (self.isWasm()) "wasm" else @tagName(self.getAbi());
207207
208208 var out = &std.io.BufferOutStream.init(&result).stream;
209 try out.print("{}-unknown-{}-{}", @tagName(self.getArch()), @tagName(self.getOs()), env_name);
209 try out.print("{}-unknown-{}-{}", .{ @tagName(self.getArch()), @tagName(self.getOs()), env_name });
210210
211211 return result;
212212}
src-self-hosted/value.zig+1-1
......@@ -53,7 +53,7 @@ pub const Value = struct {
5353 }
5454
5555 pub fn dump(base: *const Value) void {
56 std.debug.warn("{}", @tagName(base.id));
56 std.debug.warn("{}", .{@tagName(base.id)});
5757 }
5858
5959 pub fn getLlvmConst(base: *Value, ofile: *ObjectFile) (error{OutOfMemory}!?*llvm.Value) {
src/ir.cpp+12-4
......@@ -17025,7 +17025,7 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s
1702517025 {
1702617026 result_loc_pass1 = no_result_loc();
1702717027 }
17028 bool was_written = result_loc_pass1->written;
17028 bool was_already_resolved = result_loc_pass1->resolved_loc != nullptr;
1702917029 IrInstruction *result_loc = ir_resolve_result_raw(ira, suspend_source_instr, result_loc_pass1, value_type,
1703017030 value, force_runtime, non_null_comptime, allow_discard);
1703117031 if (result_loc == nullptr || (instr_is_unreachable(result_loc) || type_is_invalid(result_loc->value->type)))
......@@ -17038,7 +17038,7 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s
1703817038 }
1703917039
1704017040 InferredStructField *isf = result_loc->value->type->data.pointer.inferred_struct_field;
17041 if (!was_written && isf != nullptr) {
17041 if (!was_already_resolved && isf != nullptr) {
1704217042 // Now it's time to add the field to the struct type.
1704317043 uint32_t old_field_count = isf->inferred_struct_type->data.structure.src_field_count;
1704417044 uint32_t new_field_count = old_field_count + 1;
......@@ -18077,7 +18077,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i
1807718077 if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) {
1807818078 return result_loc;
1807918079 }
18080 if (!handle_is_ptr(result_loc->value->type->data.pointer.child_type)) {
18080 ZigType *res_child_type = result_loc->value->type->data.pointer.child_type;
18081 if (res_child_type == ira->codegen->builtin_types.entry_var) {
18082 res_child_type = impl_fn_type_id->return_type;
18083 }
18084 if (!handle_is_ptr(res_child_type)) {
1808118085 ir_reset_result(call_result_loc);
1808218086 result_loc = nullptr;
1808318087 }
......@@ -18240,7 +18244,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i
1824018244 if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) {
1824118245 return result_loc;
1824218246 }
18243 if (!handle_is_ptr(result_loc->value->type->data.pointer.child_type)) {
18247 ZigType *res_child_type = result_loc->value->type->data.pointer.child_type;
18248 if (res_child_type == ira->codegen->builtin_types.entry_var) {
18249 res_child_type = return_type;
18250 }
18251 if (!handle_is_ptr(res_child_type)) {
1824418252 ir_reset_result(call_result_loc);
1824518253 result_loc = nullptr;
1824618254 }
test/cli.zig+11-11
......@@ -19,11 +19,11 @@ pub fn main() !void {
1919 a = &arena.allocator;
2020
2121 const zig_exe_rel = try (arg_it.next(a) orelse {
22 std.debug.warn("Expected first argument to be path to zig compiler\n");
22 std.debug.warn("Expected first argument to be path to zig compiler\n", .{});
2323 return error.InvalidArgs;
2424 });
2525 const cache_root = try (arg_it.next(a) orelse {
26 std.debug.warn("Expected second argument to be cache root directory path\n");
26 std.debug.warn("Expected second argument to be cache root directory path\n", .{});
2727 return error.InvalidArgs;
2828 });
2929 const zig_exe = try fs.path.resolve(a, &[_][]const u8{zig_exe_rel});
......@@ -45,39 +45,39 @@ pub fn main() !void {
4545
4646fn unwrapArg(arg: UnwrapArgError![]u8) UnwrapArgError![]u8 {
4747 return arg catch |err| {
48 warn("Unable to parse command line: {}\n", err);
48 warn("Unable to parse command line: {}\n", .{err});
4949 return err;
5050 };
5151}
5252
5353fn printCmd(cwd: []const u8, argv: []const []const u8) void {
54 std.debug.warn("cd {} && ", cwd);
54 std.debug.warn("cd {} && ", .{cwd});
5555 for (argv) |arg| {
56 std.debug.warn("{} ", arg);
56 std.debug.warn("{} ", .{arg});
5757 }
58 std.debug.warn("\n");
58 std.debug.warn("\n", .{});
5959}
6060
6161fn exec(cwd: []const u8, argv: []const []const u8) !ChildProcess.ExecResult {
6262 const max_output_size = 100 * 1024;
6363 const result = ChildProcess.exec(a, argv, cwd, null, max_output_size) catch |err| {
64 std.debug.warn("The following command failed:\n");
64 std.debug.warn("The following command failed:\n", .{});
6565 printCmd(cwd, argv);
6666 return err;
6767 };
6868 switch (result.term) {
6969 .Exited => |code| {
7070 if (code != 0) {
71 std.debug.warn("The following command exited with error code {}:\n", code);
71 std.debug.warn("The following command exited with error code {}:\n", .{code});
7272 printCmd(cwd, argv);
73 std.debug.warn("stderr:\n{}\n", result.stderr);
73 std.debug.warn("stderr:\n{}\n", .{result.stderr});
7474 return error.CommandFailed;
7575 }
7676 },
7777 else => {
78 std.debug.warn("The following command terminated unexpectedly:\n");
78 std.debug.warn("The following command terminated unexpectedly:\n", .{});
7979 printCmd(cwd, argv);
80 std.debug.warn("stderr:\n{}\n", result.stderr);
80 std.debug.warn("stderr:\n{}\n", .{result.stderr});
8181 return error.CommandFailed;
8282 },
8383 }
test/compare_output.zig+33-33
......@@ -20,7 +20,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
2020 \\pub fn main() void {
2121 \\ privateFunction();
2222 \\ const stdout = &getStdOut().outStream().stream;
23 \\ stdout.print("OK 2\n") catch unreachable;
23 \\ stdout.print("OK 2\n", .{}) catch unreachable;
2424 \\}
2525 \\
2626 \\fn privateFunction() void {
......@@ -35,7 +35,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
3535 \\// but it's private so it should be OK
3636 \\fn privateFunction() void {
3737 \\ const stdout = &getStdOut().outStream().stream;
38 \\ stdout.print("OK 1\n") catch unreachable;
38 \\ stdout.print("OK 1\n", .{}) catch unreachable;
3939 \\}
4040 \\
4141 \\pub fn printText() void {
......@@ -61,7 +61,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
6161 \\usingnamespace @import("std").io;
6262 \\pub fn foo_function() void {
6363 \\ const stdout = &getStdOut().outStream().stream;
64 \\ stdout.print("OK\n") catch unreachable;
64 \\ stdout.print("OK\n", .{}) catch unreachable;
6565 \\}
6666 );
6767
......@@ -72,7 +72,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
7272 \\pub fn bar_function() void {
7373 \\ if (foo_function()) {
7474 \\ const stdout = &getStdOut().outStream().stream;
75 \\ stdout.print("OK\n") catch unreachable;
75 \\ stdout.print("OK\n", .{}) catch unreachable;
7676 \\ }
7777 \\}
7878 );
......@@ -104,7 +104,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
104104 \\
105105 \\pub fn ok() void {
106106 \\ const stdout = &io.getStdOut().outStream().stream;
107 \\ stdout.print(b_text) catch unreachable;
107 \\ stdout.print(b_text, .{}) catch unreachable;
108108 \\}
109109 );
110110
......@@ -122,7 +122,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
122122 \\
123123 \\pub fn main() void {
124124 \\ const stdout = &io.getStdOut().outStream().stream;
125 \\ stdout.print("Hello, world!\n{d:4} {x:3} {c}\n", @as(u32, 12), @as(u16, 0x12), @as(u8, 'a')) catch unreachable;
125 \\ stdout.print("Hello, world!\n{d:4} {x:3} {c}\n", .{@as(u32, 12), @as(u16, 0x12), @as(u8, 'a')}) catch unreachable;
126126 \\}
127127 , "Hello, world!\n 12 12 a\n");
128128
......@@ -265,7 +265,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
265265 \\}
266266 \\fn print_ok(val: @typeOf(x)) @typeOf(foo) {
267267 \\ const stdout = &io.getStdOut().outStream().stream;
268 \\ stdout.print("OK\n") catch unreachable;
268 \\ stdout.print("OK\n", .{}) catch unreachable;
269269 \\ return 0;
270270 \\}
271271 \\const foo : i32 = 0;
......@@ -348,12 +348,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
348348 \\ const foo = Foo {.field1 = bar,};
349349 \\ const stdout = &io.getStdOut().outStream().stream;
350350 \\ if (!foo.method()) {
351 \\ stdout.print("BAD\n") catch unreachable;
351 \\ stdout.print("BAD\n", .{}) catch unreachable;
352352 \\ }
353353 \\ if (!bar.method()) {
354 \\ stdout.print("BAD\n") catch unreachable;
354 \\ stdout.print("BAD\n", .{}) catch unreachable;
355355 \\ }
356 \\ stdout.print("OK\n") catch unreachable;
356 \\ stdout.print("OK\n", .{}) catch unreachable;
357357 \\}
358358 , "OK\n");
359359
......@@ -361,11 +361,11 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
361361 \\const io = @import("std").io;
362362 \\pub fn main() void {
363363 \\ const stdout = &io.getStdOut().outStream().stream;
364 \\ stdout.print("before\n") catch unreachable;
365 \\ defer stdout.print("defer1\n") catch unreachable;
366 \\ defer stdout.print("defer2\n") catch unreachable;
367 \\ defer stdout.print("defer3\n") catch unreachable;
368 \\ stdout.print("after\n") catch unreachable;
364 \\ stdout.print("before\n", .{}) catch unreachable;
365 \\ defer stdout.print("defer1\n", .{}) catch unreachable;
366 \\ defer stdout.print("defer2\n", .{}) catch unreachable;
367 \\ defer stdout.print("defer3\n", .{}) catch unreachable;
368 \\ stdout.print("after\n", .{}) catch unreachable;
369369 \\}
370370 , "before\nafter\ndefer3\ndefer2\ndefer1\n");
371371
......@@ -374,13 +374,13 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
374374 \\const os = @import("std").os;
375375 \\pub fn main() void {
376376 \\ const stdout = &io.getStdOut().outStream().stream;
377 \\ stdout.print("before\n") catch unreachable;
378 \\ defer stdout.print("defer1\n") catch unreachable;
379 \\ defer stdout.print("defer2\n") catch unreachable;
377 \\ stdout.print("before\n", .{}) catch unreachable;
378 \\ defer stdout.print("defer1\n", .{}) catch unreachable;
379 \\ defer stdout.print("defer2\n", .{}) catch unreachable;
380380 \\ var args_it = @import("std").process.args();
381381 \\ if (args_it.skip() and !args_it.skip()) return;
382 \\ defer stdout.print("defer3\n") catch unreachable;
383 \\ stdout.print("after\n") catch unreachable;
382 \\ defer stdout.print("defer3\n", .{}) catch unreachable;
383 \\ stdout.print("after\n", .{}) catch unreachable;
384384 \\}
385385 , "before\ndefer2\ndefer1\n");
386386
......@@ -391,12 +391,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
391391 \\}
392392 \\fn do_test() !void {
393393 \\ const stdout = &io.getStdOut().outStream().stream;
394 \\ stdout.print("before\n") catch unreachable;
395 \\ defer stdout.print("defer1\n") catch unreachable;
396 \\ errdefer stdout.print("deferErr\n") catch unreachable;
394 \\ stdout.print("before\n", .{}) catch unreachable;
395 \\ defer stdout.print("defer1\n", .{}) catch unreachable;
396 \\ errdefer stdout.print("deferErr\n", .{}) catch unreachable;
397397 \\ try its_gonna_fail();
398 \\ defer stdout.print("defer3\n") catch unreachable;
399 \\ stdout.print("after\n") catch unreachable;
398 \\ defer stdout.print("defer3\n", .{}) catch unreachable;
399 \\ stdout.print("after\n", .{}) catch unreachable;
400400 \\}
401401 \\fn its_gonna_fail() !void {
402402 \\ return error.IToldYouItWouldFail;
......@@ -410,12 +410,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
410410 \\}
411411 \\fn do_test() !void {
412412 \\ const stdout = &io.getStdOut().outStream().stream;
413 \\ stdout.print("before\n") catch unreachable;
414 \\ defer stdout.print("defer1\n") catch unreachable;
415 \\ errdefer stdout.print("deferErr\n") catch unreachable;
413 \\ stdout.print("before\n", .{}) catch unreachable;
414 \\ defer stdout.print("defer1\n", .{}) catch unreachable;
415 \\ errdefer stdout.print("deferErr\n", .{}) catch unreachable;
416416 \\ try its_gonna_pass();
417 \\ defer stdout.print("defer3\n") catch unreachable;
418 \\ stdout.print("after\n") catch unreachable;
417 \\ defer stdout.print("defer3\n", .{}) catch unreachable;
418 \\ stdout.print("after\n", .{}) catch unreachable;
419419 \\}
420420 \\fn its_gonna_pass() anyerror!void { }
421421 , "before\nafter\ndefer3\ndefer1\n");
......@@ -427,7 +427,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
427427 \\
428428 \\pub fn main() void {
429429 \\ const stdout = &io.getStdOut().outStream().stream;
430 \\ stdout.print(foo_txt) catch unreachable;
430 \\ stdout.print(foo_txt, .{}) catch unreachable;
431431 \\}
432432 , "1234\nabcd\n");
433433
......@@ -452,7 +452,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
452452 \\ _ = args_it.skip();
453453 \\ while (args_it.next(allocator)) |arg_or_err| : (index += 1) {
454454 \\ const arg = try arg_or_err;
455 \\ try stdout.print("{}: {}\n", index, arg);
455 \\ try stdout.print("{}: {}\n", .{index, arg});
456456 \\ }
457457 \\}
458458 ,
......@@ -493,7 +493,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void {
493493 \\ _ = args_it.skip();
494494 \\ while (args_it.next(allocator)) |arg_or_err| : (index += 1) {
495495 \\ const arg = try arg_or_err;
496 \\ try stdout.print("{}: {}\n", index, arg);
496 \\ try stdout.print("{}: {}\n", .{index, arg});
497497 \\ }
498498 \\}
499499 ,
test/compile_errors.zig+2-4
......@@ -2598,14 +2598,12 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
25982598 \\fn a(b: fn (*const u8) void) void {
25992599 \\ b('a');
26002600 \\}
2601 \\fn c(d: u8) void {
2602 \\ @import("std").debug.warn("{c}\n", d);
2603 \\}
2601 \\fn c(d: u8) void {}
26042602 \\export fn entry() void {
26052603 \\ a(c);
26062604 \\}
26072605 ,
2608 "tmp.zig:8:7: error: expected type 'fn(*const u8) void', found 'fn(u8) void'",
2606 "tmp.zig:6:7: error: expected type 'fn(*const u8) void', found 'fn(u8) void'",
26092607 );
26102608
26112609 cases.add(
test/standalone/cat/main.zig+5-5
......@@ -23,7 +23,7 @@ pub fn main() !void {
2323 return usage(exe);
2424 } else {
2525 const file = cwd.openFile(arg, .{}) catch |err| {
26 warn("Unable to open file: {}\n", @errorName(err));
26 warn("Unable to open file: {}\n", .{@errorName(err)});
2727 return err;
2828 };
2929 defer file.close();
......@@ -38,7 +38,7 @@ pub fn main() !void {
3838}
3939
4040fn usage(exe: []const u8) !void {
41 warn("Usage: {} [FILE]...\n", exe);
41 warn("Usage: {} [FILE]...\n", .{exe});
4242 return error.Invalid;
4343}
4444
......@@ -47,7 +47,7 @@ fn cat_file(stdout: fs.File, file: fs.File) !void {
4747
4848 while (true) {
4949 const bytes_read = file.read(buf[0..]) catch |err| {
50 warn("Unable to read from stream: {}\n", @errorName(err));
50 warn("Unable to read from stream: {}\n", .{@errorName(err)});
5151 return err;
5252 };
5353
......@@ -56,7 +56,7 @@ fn cat_file(stdout: fs.File, file: fs.File) !void {
5656 }
5757
5858 stdout.write(buf[0..bytes_read]) catch |err| {
59 warn("Unable to write to stdout: {}\n", @errorName(err));
59 warn("Unable to write to stdout: {}\n", .{@errorName(err)});
6060 return err;
6161 };
6262 }
......@@ -64,7 +64,7 @@ fn cat_file(stdout: fs.File, file: fs.File) !void {
6464
6565fn unwrapArg(arg: anyerror![]u8) ![]u8 {
6666 return arg catch |err| {
67 warn("Unable to parse command line: {}\n", err);
67 warn("Unable to parse command line: {}\n", .{err});
6868 return err;
6969 };
7070}
test/standalone/guess_number/main.zig+8-8
......@@ -6,11 +6,11 @@ const fmt = std.fmt;
66pub fn main() !void {
77 const stdout = &io.getStdOut().outStream().stream;
88
9 try stdout.print("Welcome to the Guess Number Game in Zig.\n");
9 try stdout.print("Welcome to the Guess Number Game in Zig.\n", .{});
1010
1111 var seed_bytes: [@sizeOf(u64)]u8 = undefined;
1212 std.crypto.randomBytes(seed_bytes[0..]) catch |err| {
13 std.debug.warn("unable to seed random number generator: {}", err);
13 std.debug.warn("unable to seed random number generator: {}", .{err});
1414 return err;
1515 };
1616 const seed = std.mem.readIntNative(u64, &seed_bytes);
......@@ -19,27 +19,27 @@ pub fn main() !void {
1919 const answer = prng.random.range(u8, 0, 100) + 1;
2020
2121 while (true) {
22 try stdout.print("\nGuess a number between 1 and 100: ");
22 try stdout.print("\nGuess a number between 1 and 100: ", .{});
2323 var line_buf: [20]u8 = undefined;
2424
2525 const line = io.readLineSlice(line_buf[0..]) catch |err| switch (err) {
2626 error.OutOfMemory => {
27 try stdout.print("Input too long.\n");
27 try stdout.print("Input too long.\n", .{});
2828 continue;
2929 },
3030 else => return err,
3131 };
3232
3333 const guess = fmt.parseUnsigned(u8, line, 10) catch {
34 try stdout.print("Invalid number.\n");
34 try stdout.print("Invalid number.\n", .{});
3535 continue;
3636 };
3737 if (guess > answer) {
38 try stdout.print("Guess lower.\n");
38 try stdout.print("Guess lower.\n", .{});
3939 } else if (guess < answer) {
40 try stdout.print("Guess higher.\n");
40 try stdout.print("Guess higher.\n", .{});
4141 } else {
42 try stdout.print("You win!\n");
42 try stdout.print("You win!\n", .{});
4343 return;
4444 }
4545 }
test/tests.zig+94-66
......@@ -411,7 +411,7 @@ pub fn addPkgTests(
411411 is_qemu_enabled: bool,
412412 glibc_dir: ?[]const u8,
413413) *build.Step {
414 const step = b.step(b.fmt("test-{}", name), desc);
414 const step = b.step(b.fmt("test-{}", .{name}), desc);
415415
416416 for (test_targets) |test_target| {
417417 if (skip_non_native and test_target.target != .Native)
......@@ -454,14 +454,14 @@ pub fn addPkgTests(
454454 test_target.target.zigTripleNoSubArch(b.allocator) catch unreachable;
455455
456456 const these_tests = b.addTest(root_src);
457 these_tests.setNamePrefix(b.fmt(
458 "{}-{}-{}-{}-{} ",
457 const single_threaded_txt = if (test_target.single_threaded) "single" else "multi";
458 these_tests.setNamePrefix(b.fmt("{}-{}-{}-{}-{} ", .{
459459 name,
460460 triple_prefix,
461461 @tagName(test_target.mode),
462462 libc_prefix,
463 if (test_target.single_threaded) "single" else "multi",
464 ));
463 single_threaded_txt,
464 }));
465465 these_tests.single_threaded = test_target.single_threaded;
466466 these_tests.setFilter(test_filter);
467467 these_tests.setBuildMode(test_target.mode);
......@@ -562,7 +562,7 @@ pub const CompareOutputContext = struct {
562562 args.append(arg) catch unreachable;
563563 }
564564
565 warn("Test {}/{} {}...", self.test_index + 1, self.context.test_index, self.name);
565 warn("Test {}/{} {}...", .{ self.test_index + 1, self.context.test_index, self.name });
566566
567567 const child = std.ChildProcess.init(args.toSliceConst(), b.allocator) catch unreachable;
568568 defer child.deinit();
......@@ -572,7 +572,7 @@ pub const CompareOutputContext = struct {
572572 child.stderr_behavior = .Pipe;
573573 child.env_map = b.env_map;
574574
575 child.spawn() catch |err| debug.panic("Unable to spawn {}: {}\n", full_exe_path, @errorName(err));
575 child.spawn() catch |err| debug.panic("Unable to spawn {}: {}\n", .{ full_exe_path, @errorName(err) });
576576
577577 var stdout = Buffer.initNull(b.allocator);
578578 var stderr = Buffer.initNull(b.allocator);
......@@ -584,18 +584,18 @@ pub const CompareOutputContext = struct {
584584 stderr_file_in_stream.stream.readAllBuffer(&stderr, max_stdout_size) catch unreachable;
585585
586586 const term = child.wait() catch |err| {
587 debug.panic("Unable to spawn {}: {}\n", full_exe_path, @errorName(err));
587 debug.panic("Unable to spawn {}: {}\n", .{ full_exe_path, @errorName(err) });
588588 };
589589 switch (term) {
590590 .Exited => |code| {
591591 if (code != 0) {
592 warn("Process {} exited with error code {}\n", full_exe_path, code);
592 warn("Process {} exited with error code {}\n", .{ full_exe_path, code });
593593 printInvocation(args.toSliceConst());
594594 return error.TestFailed;
595595 }
596596 },
597597 else => {
598 warn("Process {} terminated unexpectedly\n", full_exe_path);
598 warn("Process {} terminated unexpectedly\n", .{full_exe_path});
599599 printInvocation(args.toSliceConst());
600600 return error.TestFailed;
601601 },
......@@ -609,10 +609,10 @@ pub const CompareOutputContext = struct {
609609 \\========= But found: ====================
610610 \\{}
611611 \\
612 , self.expected_output, stdout.toSliceConst());
612 , .{ self.expected_output, stdout.toSliceConst() });
613613 return error.TestFailed;
614614 }
615 warn("OK\n");
615 warn("OK\n", .{});
616616 }
617617 };
618618
......@@ -644,7 +644,7 @@ pub const CompareOutputContext = struct {
644644
645645 const full_exe_path = self.exe.getOutputPath();
646646
647 warn("Test {}/{} {}...", self.test_index + 1, self.context.test_index, self.name);
647 warn("Test {}/{} {}...", .{ self.test_index + 1, self.context.test_index, self.name });
648648
649649 const child = std.ChildProcess.init(&[_][]const u8{full_exe_path}, b.allocator) catch unreachable;
650650 defer child.deinit();
......@@ -655,28 +655,34 @@ pub const CompareOutputContext = struct {
655655 child.stderr_behavior = .Ignore;
656656
657657 const term = child.spawnAndWait() catch |err| {
658 debug.panic("Unable to spawn {}: {}\n", full_exe_path, @errorName(err));
658 debug.panic("Unable to spawn {}: {}\n", .{ full_exe_path, @errorName(err) });
659659 };
660660
661661 const expected_exit_code: u32 = 126;
662662 switch (term) {
663663 .Exited => |code| {
664664 if (code != expected_exit_code) {
665 warn("\nProgram expected to exit with code {} " ++ "but exited with code {}\n", expected_exit_code, code);
665 warn("\nProgram expected to exit with code {} but exited with code {}\n", .{
666 expected_exit_code, code,
667 });
666668 return error.TestFailed;
667669 }
668670 },
669671 .Signal => |sig| {
670 warn("\nProgram expected to exit with code {} " ++ "but instead signaled {}\n", expected_exit_code, sig);
672 warn("\nProgram expected to exit with code {} but instead signaled {}\n", .{
673 expected_exit_code, sig,
674 });
671675 return error.TestFailed;
672676 },
673677 else => {
674 warn("\nProgram expected to exit with code {}" ++ " but exited in an unexpected way\n", expected_exit_code);
678 warn("\nProgram expected to exit with code {} but exited in an unexpected way\n", .{
679 expected_exit_code,
680 });
675681 return error.TestFailed;
676682 },
677683 }
678684
679 warn("OK\n");
685 warn("OK\n", .{});
680686 }
681687 };
682688
......@@ -729,7 +735,9 @@ pub const CompareOutputContext = struct {
729735
730736 switch (case.special) {
731737 Special.Asm => {
732 const annotated_case_name = fmt.allocPrint(self.b.allocator, "assemble-and-link {}", case.name) catch unreachable;
738 const annotated_case_name = fmt.allocPrint(self.b.allocator, "assemble-and-link {}", .{
739 case.name,
740 }) catch unreachable;
733741 if (self.test_filter) |filter| {
734742 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
735743 }
......@@ -758,7 +766,11 @@ pub const CompareOutputContext = struct {
758766 },
759767 Special.None => {
760768 for (self.modes) |mode| {
761 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{} {} ({})", "compare-output", case.name, @tagName(mode)) catch unreachable;
769 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{} {} ({})", .{
770 "compare-output",
771 case.name,
772 @tagName(mode),
773 }) catch unreachable;
762774 if (self.test_filter) |filter| {
763775 if (mem.indexOf(u8, annotated_case_name, filter) == null) continue;
764776 }
......@@ -790,7 +802,7 @@ pub const CompareOutputContext = struct {
790802 }
791803 },
792804 Special.RuntimeSafety => {
793 const annotated_case_name = fmt.allocPrint(self.b.allocator, "safety {}", case.name) catch unreachable;
805 const annotated_case_name = fmt.allocPrint(self.b.allocator, "safety {}", .{case.name}) catch unreachable;
794806 if (self.test_filter) |filter| {
795807 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
796808 }
......@@ -843,7 +855,11 @@ pub const StackTracesContext = struct {
843855 const expect_for_mode = expect[@enumToInt(mode)];
844856 if (expect_for_mode.len == 0) continue;
845857
846 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{} {} ({})", "stack-trace", name, @tagName(mode)) catch unreachable;
858 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{} {} ({})", .{
859 "stack-trace",
860 name,
861 @tagName(mode),
862 }) catch unreachable;
847863 if (self.test_filter) |filter| {
848864 if (mem.indexOf(u8, annotated_case_name, filter) == null) continue;
849865 }
......@@ -907,7 +923,7 @@ pub const StackTracesContext = struct {
907923 defer args.deinit();
908924 args.append(full_exe_path) catch unreachable;
909925
910 warn("Test {}/{} {}...", self.test_index + 1, self.context.test_index, self.name);
926 warn("Test {}/{} {}...", .{ self.test_index + 1, self.context.test_index, self.name });
911927
912928 const child = std.ChildProcess.init(args.toSliceConst(), b.allocator) catch unreachable;
913929 defer child.deinit();
......@@ -917,7 +933,7 @@ pub const StackTracesContext = struct {
917933 child.stderr_behavior = .Pipe;
918934 child.env_map = b.env_map;
919935
920 child.spawn() catch |err| debug.panic("Unable to spawn {}: {}\n", full_exe_path, @errorName(err));
936 child.spawn() catch |err| debug.panic("Unable to spawn {}: {}\n", .{ full_exe_path, @errorName(err) });
921937
922938 var stdout = Buffer.initNull(b.allocator);
923939 var stderr = Buffer.initNull(b.allocator);
......@@ -929,30 +945,34 @@ pub const StackTracesContext = struct {
929945 stderr_file_in_stream.stream.readAllBuffer(&stderr, max_stdout_size) catch unreachable;
930946
931947 const term = child.wait() catch |err| {
932 debug.panic("Unable to spawn {}: {}\n", full_exe_path, @errorName(err));
948 debug.panic("Unable to spawn {}: {}\n", .{ full_exe_path, @errorName(err) });
933949 };
934950
935951 switch (term) {
936952 .Exited => |code| {
937953 const expect_code: u32 = 1;
938954 if (code != expect_code) {
939 warn("Process {} exited with error code {} but expected code {}\n", full_exe_path, code, expect_code);
955 warn("Process {} exited with error code {} but expected code {}\n", .{
956 full_exe_path,
957 code,
958 expect_code,
959 });
940960 printInvocation(args.toSliceConst());
941961 return error.TestFailed;
942962 }
943963 },
944964 .Signal => |signum| {
945 warn("Process {} terminated on signal {}\n", full_exe_path, signum);
965 warn("Process {} terminated on signal {}\n", .{ full_exe_path, signum });
946966 printInvocation(args.toSliceConst());
947967 return error.TestFailed;
948968 },
949969 .Stopped => |signum| {
950 warn("Process {} stopped on signal {}\n", full_exe_path, signum);
970 warn("Process {} stopped on signal {}\n", .{ full_exe_path, signum });
951971 printInvocation(args.toSliceConst());
952972 return error.TestFailed;
953973 },
954974 .Unknown => |code| {
955 warn("Process {} terminated unexpectedly with error code {}\n", full_exe_path, code);
975 warn("Process {} terminated unexpectedly with error code {}\n", .{ full_exe_path, code });
956976 printInvocation(args.toSliceConst());
957977 return error.TestFailed;
958978 },
......@@ -1003,10 +1023,10 @@ pub const StackTracesContext = struct {
10031023 \\================================================
10041024 \\{}
10051025 \\
1006 , self.expect_output, got);
1026 , .{ self.expect_output, got });
10071027 return error.TestFailed;
10081028 }
1009 warn("OK\n");
1029 warn("OK\n", .{});
10101030 }
10111031 };
10121032};
......@@ -1129,7 +1149,7 @@ pub const CompileErrorContext = struct {
11291149 Mode.ReleaseSmall => zig_args.append("--release-small") catch unreachable,
11301150 }
11311151
1132 warn("Test {}/{} {}...", self.test_index + 1, self.context.test_index, self.name);
1152 warn("Test {}/{} {}...", .{ self.test_index + 1, self.context.test_index, self.name });
11331153
11341154 if (b.verbose) {
11351155 printInvocation(zig_args.toSliceConst());
......@@ -1143,7 +1163,7 @@ pub const CompileErrorContext = struct {
11431163 child.stdout_behavior = .Pipe;
11441164 child.stderr_behavior = .Pipe;
11451165
1146 child.spawn() catch |err| debug.panic("Unable to spawn {}: {}\n", zig_args.items[0], @errorName(err));
1166 child.spawn() catch |err| debug.panic("Unable to spawn {}: {}\n", .{ zig_args.items[0], @errorName(err) });
11471167
11481168 var stdout_buf = Buffer.initNull(b.allocator);
11491169 var stderr_buf = Buffer.initNull(b.allocator);
......@@ -1155,7 +1175,7 @@ pub const CompileErrorContext = struct {
11551175 stderr_file_in_stream.stream.readAllBuffer(&stderr_buf, max_stdout_size) catch unreachable;
11561176
11571177 const term = child.wait() catch |err| {
1158 debug.panic("Unable to spawn {}: {}\n", zig_args.items[0], @errorName(err));
1178 debug.panic("Unable to spawn {}: {}\n", .{ zig_args.items[0], @errorName(err) });
11591179 };
11601180 switch (term) {
11611181 .Exited => |code| {
......@@ -1165,7 +1185,7 @@ pub const CompileErrorContext = struct {
11651185 }
11661186 },
11671187 else => {
1168 warn("Process {} terminated unexpectedly\n", b.zig_exe);
1188 warn("Process {} terminated unexpectedly\n", .{b.zig_exe});
11691189 printInvocation(zig_args.toSliceConst());
11701190 return error.TestFailed;
11711191 },
......@@ -1182,7 +1202,7 @@ pub const CompileErrorContext = struct {
11821202 \\{}
11831203 \\================================================
11841204 \\
1185 , stdout);
1205 , .{stdout});
11861206 return error.TestFailed;
11871207 }
11881208
......@@ -1200,9 +1220,9 @@ pub const CompileErrorContext = struct {
12001220 ok = ok and i == self.case.expected_errors.len;
12011221
12021222 if (!ok) {
1203 warn("\n======== Expected these compile errors: ========\n");
1223 warn("\n======== Expected these compile errors: ========\n", .{});
12041224 for (self.case.expected_errors.toSliceConst()) |expected| {
1205 warn("{}\n", expected);
1225 warn("{}\n", .{expected});
12061226 }
12071227 }
12081228 } else {
......@@ -1213,7 +1233,7 @@ pub const CompileErrorContext = struct {
12131233 \\=========== Expected compile error: ============
12141234 \\{}
12151235 \\
1216 , expected);
1236 , .{expected});
12171237 ok = false;
12181238 break;
12191239 }
......@@ -1225,11 +1245,11 @@ pub const CompileErrorContext = struct {
12251245 \\================= Full output: =================
12261246 \\{}
12271247 \\
1228 , stderr);
1248 , .{stderr});
12291249 return error.TestFailed;
12301250 }
12311251
1232 warn("OK\n");
1252 warn("OK\n", .{});
12331253 }
12341254 };
12351255
......@@ -1279,7 +1299,9 @@ pub const CompileErrorContext = struct {
12791299 pub fn addCase(self: *CompileErrorContext, case: *const TestCase) void {
12801300 const b = self.b;
12811301
1282 const annotated_case_name = fmt.allocPrint(self.b.allocator, "compile-error {}", case.name) catch unreachable;
1302 const annotated_case_name = fmt.allocPrint(self.b.allocator, "compile-error {}", .{
1303 case.name,
1304 }) catch unreachable;
12831305 if (self.test_filter) |filter| {
12841306 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
12851307 }
......@@ -1316,7 +1338,7 @@ pub const StandaloneContext = struct {
13161338 pub fn addBuildFile(self: *StandaloneContext, build_file: []const u8) void {
13171339 const b = self.b;
13181340
1319 const annotated_case_name = b.fmt("build {} (Debug)", build_file);
1341 const annotated_case_name = b.fmt("build {} (Debug)", .{build_file});
13201342 if (self.test_filter) |filter| {
13211343 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
13221344 }
......@@ -1337,7 +1359,7 @@ pub const StandaloneContext = struct {
13371359
13381360 const run_cmd = b.addSystemCommand(zig_args.toSliceConst());
13391361
1340 const log_step = b.addLog("PASS {}\n", annotated_case_name);
1362 const log_step = b.addLog("PASS {}\n", .{annotated_case_name});
13411363 log_step.step.dependOn(&run_cmd.step);
13421364
13431365 self.step.dependOn(&log_step.step);
......@@ -1347,7 +1369,10 @@ pub const StandaloneContext = struct {
13471369 const b = self.b;
13481370
13491371 for (self.modes) |mode| {
1350 const annotated_case_name = fmt.allocPrint(self.b.allocator, "build {} ({})", root_src, @tagName(mode)) catch unreachable;
1372 const annotated_case_name = fmt.allocPrint(self.b.allocator, "build {} ({})", .{
1373 root_src,
1374 @tagName(mode),
1375 }) catch unreachable;
13511376 if (self.test_filter) |filter| {
13521377 if (mem.indexOf(u8, annotated_case_name, filter) == null) continue;
13531378 }
......@@ -1358,7 +1383,7 @@ pub const StandaloneContext = struct {
13581383 exe.linkSystemLibrary("c");
13591384 }
13601385
1361 const log_step = b.addLog("PASS {}\n", annotated_case_name);
1386 const log_step = b.addLog("PASS {}\n", .{annotated_case_name});
13621387 log_step.step.dependOn(&exe.step);
13631388
13641389 self.step.dependOn(&log_step.step);
......@@ -1434,7 +1459,7 @@ pub const TranslateCContext = struct {
14341459 zig_args.append(translate_c_cmd) catch unreachable;
14351460 zig_args.append(b.pathFromRoot(root_src)) catch unreachable;
14361461
1437 warn("Test {}/{} {}...", self.test_index + 1, self.context.test_index, self.name);
1462 warn("Test {}/{} {}...", .{ self.test_index + 1, self.context.test_index, self.name });
14381463
14391464 if (b.verbose) {
14401465 printInvocation(zig_args.toSliceConst());
......@@ -1448,7 +1473,10 @@ pub const TranslateCContext = struct {
14481473 child.stdout_behavior = .Pipe;
14491474 child.stderr_behavior = .Pipe;
14501475
1451 child.spawn() catch |err| debug.panic("Unable to spawn {}: {}\n", zig_args.toSliceConst()[0], @errorName(err));
1476 child.spawn() catch |err| debug.panic("Unable to spawn {}: {}\n", .{
1477 zig_args.toSliceConst()[0],
1478 @errorName(err),
1479 });
14521480
14531481 var stdout_buf = Buffer.initNull(b.allocator);
14541482 var stderr_buf = Buffer.initNull(b.allocator);
......@@ -1460,23 +1488,23 @@ pub const TranslateCContext = struct {
14601488 stderr_file_in_stream.stream.readAllBuffer(&stderr_buf, max_stdout_size) catch unreachable;
14611489
14621490 const term = child.wait() catch |err| {
1463 debug.panic("Unable to spawn {}: {}\n", zig_args.toSliceConst()[0], @errorName(err));
1491 debug.panic("Unable to spawn {}: {}\n", .{ zig_args.toSliceConst()[0], @errorName(err) });
14641492 };
14651493 switch (term) {
14661494 .Exited => |code| {
14671495 if (code != 0) {
1468 warn("Compilation failed with exit code {}\n", code);
1496 warn("Compilation failed with exit code {}\n", .{code});
14691497 printInvocation(zig_args.toSliceConst());
14701498 return error.TestFailed;
14711499 }
14721500 },
14731501 .Signal => |code| {
1474 warn("Compilation failed with signal {}\n", code);
1502 warn("Compilation failed with signal {}\n", .{code});
14751503 printInvocation(zig_args.toSliceConst());
14761504 return error.TestFailed;
14771505 },
14781506 else => {
1479 warn("Compilation terminated unexpectedly\n");
1507 warn("Compilation terminated unexpectedly\n", .{});
14801508 printInvocation(zig_args.toSliceConst());
14811509 return error.TestFailed;
14821510 },
......@@ -1491,7 +1519,7 @@ pub const TranslateCContext = struct {
14911519 \\{}
14921520 \\============================================
14931521 \\
1494 , stderr);
1522 , .{stderr});
14951523 printInvocation(zig_args.toSliceConst());
14961524 return error.TestFailed;
14971525 }
......@@ -1505,20 +1533,20 @@ pub const TranslateCContext = struct {
15051533 \\========= But found: ===========================
15061534 \\{}
15071535 \\
1508 , expected_line, stdout);
1536 , .{ expected_line, stdout });
15091537 printInvocation(zig_args.toSliceConst());
15101538 return error.TestFailed;
15111539 }
15121540 }
1513 warn("OK\n");
1541 warn("OK\n", .{});
15141542 }
15151543 };
15161544
15171545 fn printInvocation(args: []const []const u8) void {
15181546 for (args) |arg| {
1519 warn("{} ", arg);
1547 warn("{} ", .{arg});
15201548 }
1521 warn("\n");
1549 warn("\n", .{});
15221550 }
15231551
15241552 pub fn create(self: *TranslateCContext, allow_warnings: bool, filename: []const u8, name: []const u8, source: []const u8, expected_lines: ...) *TestCase {
......@@ -1586,7 +1614,7 @@ pub const TranslateCContext = struct {
15861614 const b = self.b;
15871615
15881616 const translate_c_cmd = if (case.stage2) "translate-c-2" else "translate-c";
1589 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{} {}", translate_c_cmd, case.name) catch unreachable;
1617 const annotated_case_name = fmt.allocPrint(self.b.allocator, "{} {}", .{ translate_c_cmd, case.name }) catch unreachable;
15901618 if (self.test_filter) |filter| {
15911619 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
15921620 }
......@@ -1666,7 +1694,7 @@ pub const GenHContext = struct {
16661694 const self = @fieldParentPtr(GenHCmpOutputStep, "step", step);
16671695 const b = self.context.b;
16681696
1669 warn("Test {}/{} {}...", self.test_index + 1, self.context.test_index, self.name);
1697 warn("Test {}/{} {}...", .{ self.test_index + 1, self.context.test_index, self.name });
16701698
16711699 const full_h_path = self.obj.getOutputHPath();
16721700 const actual_h = try io.readFileAlloc(b.allocator, full_h_path);
......@@ -1680,19 +1708,19 @@ pub const GenHContext = struct {
16801708 \\========= But found: ===========================
16811709 \\{}
16821710 \\
1683 , expected_line, actual_h);
1711 , .{ expected_line, actual_h });
16841712 return error.TestFailed;
16851713 }
16861714 }
1687 warn("OK\n");
1715 warn("OK\n", .{});
16881716 }
16891717 };
16901718
16911719 fn printInvocation(args: []const []const u8) void {
16921720 for (args) |arg| {
1693 warn("{} ", arg);
1721 warn("{} ", .{arg});
16941722 }
1695 warn("\n");
1723 warn("\n", .{});
16961724 }
16971725
16981726 pub fn create(self: *GenHContext, filename: []const u8, name: []const u8, source: []const u8, expected_lines: ...) *TestCase {
......@@ -1724,7 +1752,7 @@ pub const GenHContext = struct {
17241752 ) catch unreachable;
17251753
17261754 const mode = builtin.Mode.Debug;
1727 const annotated_case_name = fmt.allocPrint(self.b.allocator, "gen-h {} ({})", case.name, @tagName(mode)) catch unreachable;
1755 const annotated_case_name = fmt.allocPrint(self.b.allocator, "gen-h {} ({})", .{ case.name, @tagName(mode) }) catch unreachable;
17281756 if (self.test_filter) |filter| {
17291757 if (mem.indexOf(u8, annotated_case_name, filter) == null) return;
17301758 }
......@@ -1749,7 +1777,7 @@ pub const GenHContext = struct {
17491777
17501778fn printInvocation(args: []const []const u8) void {
17511779 for (args) |arg| {
1752 warn("{} ", arg);
1780 warn("{} ", .{arg});
17531781 }
1754 warn("\n");
1782 warn("\n", .{});
17551783}