| author | |
| committer | |
| log | 640e09183d3100c477a26c6cdc26f1eae31472a1 |
| tree | 0bddf7eb99d6daaaa2e5ee80b51a6766aefb7d9c |
| parent | 5874cb04bd544ca155d1489bb0bdf9397fa3b41c |
| parent | 8b3c0bbeeef080b77d0cb7999682abc52de437e3 |
| signature | Signed by PGP key 4AEE18F83AFDEB23 |
std.fmt.format: tuple parameter instead of var args63 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 { |
| 154 | 154 | const static_bare_name = if (mem.eql(u8, lib, "curses")) |
| 155 | 155 | @as([]const u8, "libncurses.a") |
| 156 | 156 | else |
| 157 | b.fmt("lib{}.a", lib); | |
| 157 | b.fmt("lib{}.a", .{lib}); | |
| 158 | 158 | const static_lib_name = fs.path.join( |
| 159 | 159 | b.allocator, |
| 160 | 160 | &[_][]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 |
| 186 | 186 | lib_exe_obj.addObjectFile(fs.path.join(b.allocator, &[_][]const u8{ |
| 187 | 187 | cmake_binary_dir, |
| 188 | 188 | "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() }), | |
| 190 | 190 | }) catch unreachable); |
| 191 | 191 | } |
| 192 | 192 | |
| ... | ... | @@ -343,14 +343,14 @@ fn addCxxKnownPath( |
| 343 | 343 | ) !void { |
| 344 | 344 | const path_padded = try b.exec(&[_][]const u8{ |
| 345 | 345 | ctx.cxx_compiler, |
| 346 | b.fmt("-print-file-name={}", objname), | |
| 346 | b.fmt("-print-file-name={}", .{objname}), | |
| 347 | 347 | }); |
| 348 | 348 | const path_unpadded = mem.tokenize(path_padded, "\r\n").next().?; |
| 349 | 349 | if (mem.eql(u8, path_unpadded, objname)) { |
| 350 | 350 | if (errtxt) |msg| { |
| 351 | warn("{}", msg); | |
| 351 | warn("{}", .{msg}); | |
| 352 | 352 | } else { |
| 353 | warn("Unable to determine path to {}\n", objname); | |
| 353 | warn("Unable to determine path to {}\n", .{objname}); | |
| 354 | 354 | } |
| 355 | 355 | return error.RequiredLibraryNotFound; |
| 356 | 356 | } |
doc/docgen.zig+146-135| ... | ... | @@ -215,32 +215,33 @@ const Tokenizer = struct { |
| 215 | 215 | } |
| 216 | 216 | }; |
| 217 | 217 | |
| 218 | fn parseError(tokenizer: *Tokenizer, token: Token, comptime fmt: []const u8, args: ...) anyerror { | |
| 218 | fn parseError(tokenizer: *Tokenizer, token: Token, comptime fmt: []const u8, args: var) anyerror { | |
| 219 | 219 | 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); | |
| 221 | 222 | 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]}); | |
| 223 | 224 | { |
| 224 | 225 | var i: usize = 0; |
| 225 | 226 | while (i < loc.column) : (i += 1) { |
| 226 | warn(" "); | |
| 227 | warn(" ", .{}); | |
| 227 | 228 | } |
| 228 | 229 | } |
| 229 | 230 | { |
| 230 | 231 | const caret_count = token.end - token.start; |
| 231 | 232 | var i: usize = 0; |
| 232 | 233 | while (i < caret_count) : (i += 1) { |
| 233 | warn("~"); | |
| 234 | warn("~", .{}); | |
| 234 | 235 | } |
| 235 | 236 | } |
| 236 | warn("\n"); | |
| 237 | warn("\n", .{}); | |
| 237 | 238 | } |
| 238 | 239 | return error.ParseError; |
| 239 | 240 | } |
| 240 | 241 | |
| 241 | 242 | fn assertToken(tokenizer: *Tokenizer, token: Token, id: Token.Id) !void { |
| 242 | 243 | 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) }); | |
| 244 | 245 | } |
| 245 | 246 | } |
| 246 | 247 | |
| ... | ... | @@ -339,7 +340,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { |
| 339 | 340 | switch (token.id) { |
| 340 | 341 | Token.Id.Eof => { |
| 341 | 342 | if (header_stack_size != 0) { |
| 342 | return parseError(tokenizer, token, "unbalanced headers"); | |
| 343 | return parseError(tokenizer, token, "unbalanced headers", .{}); | |
| 343 | 344 | } |
| 344 | 345 | try toc.write(" </ul>\n"); |
| 345 | 346 | break; |
| ... | ... | @@ -373,10 +374,15 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { |
| 373 | 374 | if (mem.eql(u8, param, "3col")) { |
| 374 | 375 | columns = 3; |
| 375 | 376 | } 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 | ); | |
| 377 | 383 | } |
| 378 | 384 | }, |
| 379 | else => return parseError(tokenizer, bracket_tok, "invalid header_open token"), | |
| 385 | else => return parseError(tokenizer, bracket_tok, "invalid header_open token", .{}), | |
| 380 | 386 | } |
| 381 | 387 | } |
| 382 | 388 | |
| ... | ... | @@ -391,15 +397,15 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { |
| 391 | 397 | }, |
| 392 | 398 | }); |
| 393 | 399 | 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 {}; | |
| 396 | 402 | return error.ParseError; |
| 397 | 403 | } |
| 398 | 404 | if (last_action == Action.Open) { |
| 399 | 405 | try toc.writeByte('\n'); |
| 400 | 406 | try toc.writeByteNTimes(' ', header_stack_size * 4); |
| 401 | 407 | if (last_columns) |n| { |
| 402 | try toc.print("<ul style=\"columns: {}\">\n", n); | |
| 408 | try toc.print("<ul style=\"columns: {}\">\n", .{n}); | |
| 403 | 409 | } else { |
| 404 | 410 | try toc.write("<ul>\n"); |
| 405 | 411 | } |
| ... | ... | @@ -408,10 +414,10 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { |
| 408 | 414 | } |
| 409 | 415 | last_columns = columns; |
| 410 | 416 | 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 }); | |
| 412 | 418 | } else if (mem.eql(u8, tag_name, "header_close")) { |
| 413 | 419 | if (header_stack_size == 0) { |
| 414 | return parseError(tokenizer, tag_token, "unbalanced close header"); | |
| 420 | return parseError(tokenizer, tag_token, "unbalanced close header", .{}); | |
| 415 | 421 | } |
| 416 | 422 | header_stack_size -= 1; |
| 417 | 423 | _ = try eatToken(tokenizer, Token.Id.BracketClose); |
| ... | ... | @@ -442,7 +448,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { |
| 442 | 448 | try nodes.append(Node{ .SeeAlso = list.toOwnedSlice() }); |
| 443 | 449 | break; |
| 444 | 450 | }, |
| 445 | else => return parseError(tokenizer, see_also_tok, "invalid see_also token"), | |
| 451 | else => return parseError(tokenizer, see_also_tok, "invalid see_also token", .{}), | |
| 446 | 452 | } |
| 447 | 453 | } |
| 448 | 454 | } else if (mem.eql(u8, tag_name, "link")) { |
| ... | ... | @@ -459,7 +465,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { |
| 459 | 465 | _ = try eatToken(tokenizer, Token.Id.BracketClose); |
| 460 | 466 | break :blk tokenizer.buffer[explicit_text.start..explicit_text.end]; |
| 461 | 467 | }, |
| 462 | else => return parseError(tokenizer, tok, "invalid link token"), | |
| 468 | else => return parseError(tokenizer, tok, "invalid link token", .{}), | |
| 463 | 469 | } |
| 464 | 470 | }; |
| 465 | 471 | |
| ... | ... | @@ -482,7 +488,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { |
| 482 | 488 | _ = try eatToken(tokenizer, Token.Id.BracketClose); |
| 483 | 489 | }, |
| 484 | 490 | Token.Id.BracketClose => {}, |
| 485 | else => return parseError(tokenizer, token, "invalid token"), | |
| 491 | else => return parseError(tokenizer, token, "invalid token", .{}), | |
| 486 | 492 | } |
| 487 | 493 | const code_kind_str = tokenizer.buffer[code_kind_tok.start..code_kind_tok.end]; |
| 488 | 494 | var code_kind_id: Code.Id = undefined; |
| ... | ... | @@ -512,7 +518,7 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { |
| 512 | 518 | code_kind_id = Code.Id{ .Obj = null }; |
| 513 | 519 | is_inline = true; |
| 514 | 520 | } 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}); | |
| 516 | 522 | } |
| 517 | 523 | |
| 518 | 524 | var mode = builtin.Mode.Debug; |
| ... | ... | @@ -550,7 +556,12 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { |
| 550 | 556 | _ = try eatToken(tokenizer, Token.Id.BracketClose); |
| 551 | 557 | break content_tok; |
| 552 | 558 | } 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 | ); | |
| 554 | 565 | } |
| 555 | 566 | _ = try eatToken(tokenizer, Token.Id.BracketClose); |
| 556 | 567 | } else |
| ... | ... | @@ -575,15 +586,20 @@ fn genToc(allocator: *mem.Allocator, tokenizer: *Tokenizer) !Toc { |
| 575 | 586 | const end_syntax_tag = try eatToken(tokenizer, Token.Id.TagContent); |
| 576 | 587 | const end_tag_name = tokenizer.buffer[end_syntax_tag.start..end_syntax_tag.end]; |
| 577 | 588 | 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 | ); | |
| 579 | 595 | } |
| 580 | 596 | _ = try eatToken(tokenizer, Token.Id.BracketClose); |
| 581 | 597 | try nodes.append(Node{ .Syntax = content_tok }); |
| 582 | 598 | } else { |
| 583 | return parseError(tokenizer, tag_token, "unrecognized tag name: {}", tag_name); | |
| 599 | return parseError(tokenizer, tag_token, "unrecognized tag name: {}", .{tag_name}); | |
| 584 | 600 | } |
| 585 | 601 | }, |
| 586 | else => return parseError(tokenizer, token, "invalid token"), | |
| 602 | else => return parseError(tokenizer, token, "invalid token", .{}), | |
| 587 | 603 | } |
| 588 | 604 | } |
| 589 | 605 | |
| ... | ... | @@ -729,7 +745,7 @@ fn termColor(allocator: *mem.Allocator, input: []const u8) ![]u8 { |
| 729 | 745 | try out.write("</span>"); |
| 730 | 746 | } |
| 731 | 747 | 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 }); | |
| 733 | 749 | open_span_count += 1; |
| 734 | 750 | } |
| 735 | 751 | }, |
| ... | ... | @@ -960,6 +976,7 @@ fn tokenizeAndPrintRaw(docgen_tokenizer: *Tokenizer, out: var, source_token: Tok |
| 960 | 976 | docgen_tokenizer, |
| 961 | 977 | source_token, |
| 962 | 978 | "syntax error", |
| 979 | .{}, | |
| 963 | 980 | ), |
| 964 | 981 | } |
| 965 | 982 | index = token.end; |
| ... | ... | @@ -987,9 +1004,9 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 987 | 1004 | }, |
| 988 | 1005 | Node.Link => |info| { |
| 989 | 1006 | 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}); | |
| 991 | 1008 | } |
| 992 | try out.print("<a href=\"#{}\">{}</a>", info.url, info.name); | |
| 1009 | try out.print("<a href=\"#{}\">{}</a>", .{ info.url, info.name }); | |
| 993 | 1010 | }, |
| 994 | 1011 | Node.Nav => { |
| 995 | 1012 | try out.write(toc.toc); |
| ... | ... | @@ -1002,12 +1019,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1002 | 1019 | Node.HeaderOpen => |info| { |
| 1003 | 1020 | try out.print( |
| 1004 | 1021 | "<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 }, | |
| 1011 | 1023 | ); |
| 1012 | 1024 | }, |
| 1013 | 1025 | Node.SeeAlso => |items| { |
| ... | ... | @@ -1015,9 +1027,9 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1015 | 1027 | for (items) |item| { |
| 1016 | 1028 | const url = try urlize(allocator, item.name); |
| 1017 | 1029 | 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}); | |
| 1019 | 1031 | } |
| 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 }); | |
| 1021 | 1033 | } |
| 1022 | 1034 | try out.write("</ul>\n"); |
| 1023 | 1035 | }, |
| ... | ... | @@ -1026,17 +1038,17 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1026 | 1038 | }, |
| 1027 | 1039 | Node.Code => |code| { |
| 1028 | 1040 | 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 }); | |
| 1030 | 1042 | |
| 1031 | 1043 | const raw_source = tokenizer.buffer[code.source_token.start..code.source_token.end]; |
| 1032 | 1044 | const trimmed_raw_source = mem.trim(u8, raw_source, " \n"); |
| 1033 | 1045 | 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}); | |
| 1035 | 1047 | } |
| 1036 | 1048 | try out.write("<pre>"); |
| 1037 | 1049 | try tokenizeAndPrint(tokenizer, out, code.source_token); |
| 1038 | 1050 | 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}); | |
| 1040 | 1052 | const tmp_source_file_name = try fs.path.join( |
| 1041 | 1053 | allocator, |
| 1042 | 1054 | &[_][]const u8{ tmp_dir_name, name_plus_ext }, |
| ... | ... | @@ -1045,7 +1057,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1045 | 1057 | |
| 1046 | 1058 | switch (code.id) { |
| 1047 | 1059 | 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 }); | |
| 1049 | 1061 | var build_args = std.ArrayList([]const u8).init(allocator); |
| 1050 | 1062 | defer build_args.deinit(); |
| 1051 | 1063 | try build_args.appendSlice(&[_][]const u8{ |
| ... | ... | @@ -1059,40 +1071,40 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1059 | 1071 | "--cache", |
| 1060 | 1072 | "on", |
| 1061 | 1073 | }); |
| 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}); | |
| 1063 | 1075 | switch (code.mode) { |
| 1064 | 1076 | builtin.Mode.Debug => {}, |
| 1065 | 1077 | builtin.Mode.ReleaseSafe => { |
| 1066 | 1078 | try build_args.append("--release-safe"); |
| 1067 | try out.print(" --release-safe"); | |
| 1079 | try out.print(" --release-safe", .{}); | |
| 1068 | 1080 | }, |
| 1069 | 1081 | builtin.Mode.ReleaseFast => { |
| 1070 | 1082 | try build_args.append("--release-fast"); |
| 1071 | try out.print(" --release-fast"); | |
| 1083 | try out.print(" --release-fast", .{}); | |
| 1072 | 1084 | }, |
| 1073 | 1085 | builtin.Mode.ReleaseSmall => { |
| 1074 | 1086 | try build_args.append("--release-small"); |
| 1075 | try out.print(" --release-small"); | |
| 1087 | try out.print(" --release-small", .{}); | |
| 1076 | 1088 | }, |
| 1077 | 1089 | } |
| 1078 | 1090 | 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 }); | |
| 1080 | 1092 | const full_path_object = try fs.path.join( |
| 1081 | 1093 | allocator, |
| 1082 | 1094 | &[_][]const u8{ tmp_dir_name, name_with_ext }, |
| 1083 | 1095 | ); |
| 1084 | 1096 | try build_args.append("--object"); |
| 1085 | 1097 | try build_args.append(full_path_object); |
| 1086 | try out.print(" --object {}", name_with_ext); | |
| 1098 | try out.print(" --object {}", .{name_with_ext}); | |
| 1087 | 1099 | } |
| 1088 | 1100 | if (code.link_libc) { |
| 1089 | 1101 | try build_args.append("-lc"); |
| 1090 | try out.print(" -lc"); | |
| 1102 | try out.print(" -lc", .{}); | |
| 1091 | 1103 | } |
| 1092 | 1104 | if (code.target_str) |triple| { |
| 1093 | 1105 | try build_args.appendSlice(&[_][]const u8{ "-target", triple }); |
| 1094 | 1106 | if (!code.is_inline) { |
| 1095 | try out.print(" -target {}", triple); | |
| 1107 | try out.print(" -target {}", .{triple}); | |
| 1096 | 1108 | } |
| 1097 | 1109 | } |
| 1098 | 1110 | if (expected_outcome == .BuildFail) { |
| ... | ... | @@ -1106,29 +1118,29 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1106 | 1118 | switch (result.term) { |
| 1107 | 1119 | .Exited => |exit_code| { |
| 1108 | 1120 | if (exit_code == 0) { |
| 1109 | warn("{}\nThe following command incorrectly succeeded:\n", result.stderr); | |
| 1121 | warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr}); | |
| 1110 | 1122 | for (build_args.toSliceConst()) |arg| |
| 1111 | warn("{} ", arg) | |
| 1123 | warn("{} ", .{arg}) | |
| 1112 | 1124 | 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", .{}); | |
| 1115 | 1127 | } |
| 1116 | 1128 | }, |
| 1117 | 1129 | else => { |
| 1118 | warn("{}\nThe following command crashed:\n", result.stderr); | |
| 1130 | warn("{}\nThe following command crashed:\n", .{result.stderr}); | |
| 1119 | 1131 | for (build_args.toSliceConst()) |arg| |
| 1120 | warn("{} ", arg) | |
| 1132 | warn("{} ", .{arg}) | |
| 1121 | 1133 | 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", .{}); | |
| 1124 | 1136 | }, |
| 1125 | 1137 | } |
| 1126 | 1138 | const escaped_stderr = try escapeHtml(allocator, result.stderr); |
| 1127 | 1139 | 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}); | |
| 1129 | 1141 | break :code_block; |
| 1130 | 1142 | } |
| 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", .{}); | |
| 1132 | 1144 | |
| 1133 | 1145 | if (code.target_str) |triple| { |
| 1134 | 1146 | if (mem.startsWith(u8, triple, "wasm32") or |
| ... | ... | @@ -1137,7 +1149,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1137 | 1149 | (builtin.os != .linux or builtin.arch != .x86_64)) |
| 1138 | 1150 | { |
| 1139 | 1151 | // skip execution |
| 1140 | try out.print("</code></pre>\n"); | |
| 1152 | try out.print("</code></pre>\n", .{}); | |
| 1141 | 1153 | break :code_block; |
| 1142 | 1154 | } |
| 1143 | 1155 | } |
| ... | ... | @@ -1152,12 +1164,12 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1152 | 1164 | switch (result.term) { |
| 1153 | 1165 | .Exited => |exit_code| { |
| 1154 | 1166 | if (exit_code == 0) { |
| 1155 | warn("{}\nThe following command incorrectly succeeded:\n", result.stderr); | |
| 1167 | warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr}); | |
| 1156 | 1168 | for (run_args) |arg| |
| 1157 | warn("{} ", arg) | |
| 1169 | warn("{} ", .{arg}) | |
| 1158 | 1170 | 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", .{}); | |
| 1161 | 1173 | } |
| 1162 | 1174 | }, |
| 1163 | 1175 | .Signal => exited_with_signal = true, |
| ... | ... | @@ -1165,7 +1177,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1165 | 1177 | } |
| 1166 | 1178 | break :blk result; |
| 1167 | 1179 | } 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", .{}); | |
| 1169 | 1181 | }; |
| 1170 | 1182 | |
| 1171 | 1183 | const escaped_stderr = try escapeHtml(allocator, result.stderr); |
| ... | ... | @@ -1174,11 +1186,11 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1174 | 1186 | const colored_stderr = try termColor(allocator, escaped_stderr); |
| 1175 | 1187 | const colored_stdout = try termColor(allocator, escaped_stdout); |
| 1176 | 1188 | |
| 1177 | try out.print("\n$ ./{}\n{}{}", code.name, colored_stdout, colored_stderr); | |
| 1189 | try out.print("\n$ ./{}\n{}{}", .{ code.name, colored_stdout, colored_stderr }); | |
| 1178 | 1190 | if (exited_with_signal) { |
| 1179 | try out.print("(process terminated by signal)"); | |
| 1191 | try out.print("(process terminated by signal)", .{}); | |
| 1180 | 1192 | } |
| 1181 | try out.print("</code></pre>\n"); | |
| 1193 | try out.print("</code></pre>\n", .{}); | |
| 1182 | 1194 | }, |
| 1183 | 1195 | Code.Id.Test => { |
| 1184 | 1196 | var test_args = std.ArrayList([]const u8).init(allocator); |
| ... | ... | @@ -1191,34 +1203,34 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1191 | 1203 | "--cache", |
| 1192 | 1204 | "on", |
| 1193 | 1205 | }); |
| 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}); | |
| 1195 | 1207 | switch (code.mode) { |
| 1196 | 1208 | builtin.Mode.Debug => {}, |
| 1197 | 1209 | builtin.Mode.ReleaseSafe => { |
| 1198 | 1210 | try test_args.append("--release-safe"); |
| 1199 | try out.print(" --release-safe"); | |
| 1211 | try out.print(" --release-safe", .{}); | |
| 1200 | 1212 | }, |
| 1201 | 1213 | builtin.Mode.ReleaseFast => { |
| 1202 | 1214 | try test_args.append("--release-fast"); |
| 1203 | try out.print(" --release-fast"); | |
| 1215 | try out.print(" --release-fast", .{}); | |
| 1204 | 1216 | }, |
| 1205 | 1217 | builtin.Mode.ReleaseSmall => { |
| 1206 | 1218 | try test_args.append("--release-small"); |
| 1207 | try out.print(" --release-small"); | |
| 1219 | try out.print(" --release-small", .{}); | |
| 1208 | 1220 | }, |
| 1209 | 1221 | } |
| 1210 | 1222 | if (code.link_libc) { |
| 1211 | 1223 | try test_args.append("-lc"); |
| 1212 | try out.print(" -lc"); | |
| 1224 | try out.print(" -lc", .{}); | |
| 1213 | 1225 | } |
| 1214 | 1226 | if (code.target_str) |triple| { |
| 1215 | 1227 | try test_args.appendSlice(&[_][]const u8{ "-target", triple }); |
| 1216 | try out.print(" -target {}", triple); | |
| 1228 | try out.print(" -target {}", .{triple}); | |
| 1217 | 1229 | } |
| 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", .{}); | |
| 1219 | 1231 | const escaped_stderr = try escapeHtml(allocator, result.stderr); |
| 1220 | 1232 | 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 }); | |
| 1222 | 1234 | }, |
| 1223 | 1235 | Code.Id.TestError => |error_match| { |
| 1224 | 1236 | var test_args = std.ArrayList([]const u8).init(allocator); |
| ... | ... | @@ -1233,50 +1245,50 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1233 | 1245 | "--output-dir", |
| 1234 | 1246 | tmp_dir_name, |
| 1235 | 1247 | }); |
| 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}); | |
| 1237 | 1249 | switch (code.mode) { |
| 1238 | 1250 | builtin.Mode.Debug => {}, |
| 1239 | 1251 | builtin.Mode.ReleaseSafe => { |
| 1240 | 1252 | try test_args.append("--release-safe"); |
| 1241 | try out.print(" --release-safe"); | |
| 1253 | try out.print(" --release-safe", .{}); | |
| 1242 | 1254 | }, |
| 1243 | 1255 | builtin.Mode.ReleaseFast => { |
| 1244 | 1256 | try test_args.append("--release-fast"); |
| 1245 | try out.print(" --release-fast"); | |
| 1257 | try out.print(" --release-fast", .{}); | |
| 1246 | 1258 | }, |
| 1247 | 1259 | builtin.Mode.ReleaseSmall => { |
| 1248 | 1260 | try test_args.append("--release-small"); |
| 1249 | try out.print(" --release-small"); | |
| 1261 | try out.print(" --release-small", .{}); | |
| 1250 | 1262 | }, |
| 1251 | 1263 | } |
| 1252 | 1264 | const result = try ChildProcess.exec(allocator, test_args.toSliceConst(), null, &env_map, max_doc_file_size); |
| 1253 | 1265 | switch (result.term) { |
| 1254 | 1266 | .Exited => |exit_code| { |
| 1255 | 1267 | if (exit_code == 0) { |
| 1256 | warn("{}\nThe following command incorrectly succeeded:\n", result.stderr); | |
| 1268 | warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr}); | |
| 1257 | 1269 | for (test_args.toSliceConst()) |arg| |
| 1258 | warn("{} ", arg) | |
| 1270 | warn("{} ", .{arg}) | |
| 1259 | 1271 | 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", .{}); | |
| 1262 | 1274 | } |
| 1263 | 1275 | }, |
| 1264 | 1276 | else => { |
| 1265 | warn("{}\nThe following command crashed:\n", result.stderr); | |
| 1277 | warn("{}\nThe following command crashed:\n", .{result.stderr}); | |
| 1266 | 1278 | for (test_args.toSliceConst()) |arg| |
| 1267 | warn("{} ", arg) | |
| 1279 | warn("{} ", .{arg}) | |
| 1268 | 1280 | 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", .{}); | |
| 1271 | 1283 | }, |
| 1272 | 1284 | } |
| 1273 | 1285 | 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", .{}); | |
| 1276 | 1288 | } |
| 1277 | 1289 | const escaped_stderr = try escapeHtml(allocator, result.stderr); |
| 1278 | 1290 | 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}); | |
| 1280 | 1292 | }, |
| 1281 | 1293 | |
| 1282 | 1294 | Code.Id.TestSafety => |error_match| { |
| ... | ... | @@ -1311,38 +1323,37 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1311 | 1323 | switch (result.term) { |
| 1312 | 1324 | .Exited => |exit_code| { |
| 1313 | 1325 | if (exit_code == 0) { |
| 1314 | warn("{}\nThe following command incorrectly succeeded:\n", result.stderr); | |
| 1326 | warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr}); | |
| 1315 | 1327 | for (test_args.toSliceConst()) |arg| |
| 1316 | warn("{} ", arg) | |
| 1328 | warn("{} ", .{arg}) | |
| 1317 | 1329 | 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", .{}); | |
| 1320 | 1332 | } |
| 1321 | 1333 | }, |
| 1322 | 1334 | else => { |
| 1323 | warn("{}\nThe following command crashed:\n", result.stderr); | |
| 1335 | warn("{}\nThe following command crashed:\n", .{result.stderr}); | |
| 1324 | 1336 | for (test_args.toSliceConst()) |arg| |
| 1325 | warn("{} ", arg) | |
| 1337 | warn("{} ", .{arg}) | |
| 1326 | 1338 | 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", .{}); | |
| 1329 | 1341 | }, |
| 1330 | 1342 | } |
| 1331 | 1343 | 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", .{}); | |
| 1334 | 1346 | } |
| 1335 | 1347 | const escaped_stderr = try escapeHtml(allocator, result.stderr); |
| 1336 | 1348 | 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", .{ | |
| 1339 | 1350 | code.name, |
| 1340 | 1351 | mode_arg, |
| 1341 | 1352 | colored_stderr, |
| 1342 | ); | |
| 1353 | }); | |
| 1343 | 1354 | }, |
| 1344 | 1355 | 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 }); | |
| 1346 | 1357 | const tmp_obj_file_name = try fs.path.join( |
| 1347 | 1358 | allocator, |
| 1348 | 1359 | &[_][]const u8{ tmp_dir_name, name_plus_obj_ext }, |
| ... | ... | @@ -1350,7 +1361,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1350 | 1361 | var build_args = std.ArrayList([]const u8).init(allocator); |
| 1351 | 1362 | defer build_args.deinit(); |
| 1352 | 1363 | |
| 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}); | |
| 1354 | 1365 | const output_h_file_name = try fs.path.join( |
| 1355 | 1366 | allocator, |
| 1356 | 1367 | &[_][]const u8{ tmp_dir_name, name_plus_h_ext }, |
| ... | ... | @@ -1369,7 +1380,7 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1369 | 1380 | }); |
| 1370 | 1381 | |
| 1371 | 1382 | 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}); | |
| 1373 | 1384 | } |
| 1374 | 1385 | |
| 1375 | 1386 | switch (code.mode) { |
| ... | ... | @@ -1377,26 +1388,26 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1377 | 1388 | builtin.Mode.ReleaseSafe => { |
| 1378 | 1389 | try build_args.append("--release-safe"); |
| 1379 | 1390 | if (!code.is_inline) { |
| 1380 | try out.print(" --release-safe"); | |
| 1391 | try out.print(" --release-safe", .{}); | |
| 1381 | 1392 | } |
| 1382 | 1393 | }, |
| 1383 | 1394 | builtin.Mode.ReleaseFast => { |
| 1384 | 1395 | try build_args.append("--release-fast"); |
| 1385 | 1396 | if (!code.is_inline) { |
| 1386 | try out.print(" --release-fast"); | |
| 1397 | try out.print(" --release-fast", .{}); | |
| 1387 | 1398 | } |
| 1388 | 1399 | }, |
| 1389 | 1400 | builtin.Mode.ReleaseSmall => { |
| 1390 | 1401 | try build_args.append("--release-small"); |
| 1391 | 1402 | if (!code.is_inline) { |
| 1392 | try out.print(" --release-small"); | |
| 1403 | try out.print(" --release-small", .{}); | |
| 1393 | 1404 | } |
| 1394 | 1405 | }, |
| 1395 | 1406 | } |
| 1396 | 1407 | |
| 1397 | 1408 | if (code.target_str) |triple| { |
| 1398 | 1409 | try build_args.appendSlice(&[_][]const u8{ "-target", triple }); |
| 1399 | try out.print(" -target {}", triple); | |
| 1410 | try out.print(" -target {}", .{triple}); | |
| 1400 | 1411 | } |
| 1401 | 1412 | |
| 1402 | 1413 | if (maybe_error_match) |error_match| { |
| ... | ... | @@ -1404,35 +1415,35 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1404 | 1415 | switch (result.term) { |
| 1405 | 1416 | .Exited => |exit_code| { |
| 1406 | 1417 | if (exit_code == 0) { |
| 1407 | warn("{}\nThe following command incorrectly succeeded:\n", result.stderr); | |
| 1418 | warn("{}\nThe following command incorrectly succeeded:\n", .{result.stderr}); | |
| 1408 | 1419 | for (build_args.toSliceConst()) |arg| |
| 1409 | warn("{} ", arg) | |
| 1420 | warn("{} ", .{arg}) | |
| 1410 | 1421 | 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", .{}); | |
| 1413 | 1424 | } |
| 1414 | 1425 | }, |
| 1415 | 1426 | else => { |
| 1416 | warn("{}\nThe following command crashed:\n", result.stderr); | |
| 1427 | warn("{}\nThe following command crashed:\n", .{result.stderr}); | |
| 1417 | 1428 | for (build_args.toSliceConst()) |arg| |
| 1418 | warn("{} ", arg) | |
| 1429 | warn("{} ", .{arg}) | |
| 1419 | 1430 | 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", .{}); | |
| 1422 | 1433 | }, |
| 1423 | 1434 | } |
| 1424 | 1435 | 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", .{}); | |
| 1427 | 1438 | } |
| 1428 | 1439 | const escaped_stderr = try escapeHtml(allocator, result.stderr); |
| 1429 | 1440 | const colored_stderr = try termColor(allocator, escaped_stderr); |
| 1430 | try out.print("\n{}", colored_stderr); | |
| 1441 | try out.print("\n{}", .{colored_stderr}); | |
| 1431 | 1442 | } 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", .{}); | |
| 1433 | 1444 | } |
| 1434 | 1445 | if (!code.is_inline) { |
| 1435 | try out.print("</code></pre>\n"); | |
| 1446 | try out.print("</code></pre>\n", .{}); | |
| 1436 | 1447 | } |
| 1437 | 1448 | }, |
| 1438 | 1449 | Code.Id.Lib => { |
| ... | ... | @@ -1446,33 +1457,33 @@ fn genHtml(allocator: *mem.Allocator, tokenizer: *Tokenizer, toc: *Toc, out: var |
| 1446 | 1457 | "--output-dir", |
| 1447 | 1458 | tmp_dir_name, |
| 1448 | 1459 | }); |
| 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}); | |
| 1450 | 1461 | switch (code.mode) { |
| 1451 | 1462 | builtin.Mode.Debug => {}, |
| 1452 | 1463 | builtin.Mode.ReleaseSafe => { |
| 1453 | 1464 | try test_args.append("--release-safe"); |
| 1454 | try out.print(" --release-safe"); | |
| 1465 | try out.print(" --release-safe", .{}); | |
| 1455 | 1466 | }, |
| 1456 | 1467 | builtin.Mode.ReleaseFast => { |
| 1457 | 1468 | try test_args.append("--release-fast"); |
| 1458 | try out.print(" --release-fast"); | |
| 1469 | try out.print(" --release-fast", .{}); | |
| 1459 | 1470 | }, |
| 1460 | 1471 | builtin.Mode.ReleaseSmall => { |
| 1461 | 1472 | try test_args.append("--release-small"); |
| 1462 | try out.print(" --release-small"); | |
| 1473 | try out.print(" --release-small", .{}); | |
| 1463 | 1474 | }, |
| 1464 | 1475 | } |
| 1465 | 1476 | if (code.target_str) |triple| { |
| 1466 | 1477 | try test_args.appendSlice(&[_][]const u8{ "-target", triple }); |
| 1467 | try out.print(" -target {}", triple); | |
| 1478 | try out.print(" -target {}", .{triple}); | |
| 1468 | 1479 | } |
| 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", .{}); | |
| 1470 | 1481 | const escaped_stderr = try escapeHtml(allocator, result.stderr); |
| 1471 | 1482 | 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 }); | |
| 1473 | 1484 | }, |
| 1474 | 1485 | } |
| 1475 | warn("OK\n"); | |
| 1486 | warn("OK\n", .{}); | |
| 1476 | 1487 | }, |
| 1477 | 1488 | } |
| 1478 | 1489 | } |
| ... | ... | @@ -1483,20 +1494,20 @@ fn exec(allocator: *mem.Allocator, env_map: *std.BufMap, args: []const []const u |
| 1483 | 1494 | switch (result.term) { |
| 1484 | 1495 | .Exited => |exit_code| { |
| 1485 | 1496 | 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 }); | |
| 1487 | 1498 | for (args) |arg| |
| 1488 | warn("{} ", arg) | |
| 1499 | warn("{} ", .{arg}) | |
| 1489 | 1500 | else |
| 1490 | warn("\n"); | |
| 1501 | warn("\n", .{}); | |
| 1491 | 1502 | return error.ChildExitError; |
| 1492 | 1503 | } |
| 1493 | 1504 | }, |
| 1494 | 1505 | else => { |
| 1495 | warn("{}\nThe following command crashed:\n", result.stderr); | |
| 1506 | warn("{}\nThe following command crashed:\n", .{result.stderr}); | |
| 1496 | 1507 | for (args) |arg| |
| 1497 | warn("{} ", arg) | |
| 1508 | warn("{} ", .{arg}) | |
| 1498 | 1509 | else |
| 1499 | warn("\n"); | |
| 1510 | warn("\n", .{}); | |
| 1500 | 1511 | return error.ChildCrashed; |
| 1501 | 1512 | }, |
| 1502 | 1513 | } |
doc/langref.html.in+82-70| ... | ... | @@ -205,7 +205,7 @@ const std = @import("std"); |
| 205 | 205 | |
| 206 | 206 | pub fn main() !void { |
| 207 | 207 | const stdout = &std.io.getStdOut().outStream().stream; |
| 208 | try stdout.print("Hello, {}!\n", "world"); | |
| 208 | try stdout.print("Hello, {}!\n", .{"world"}); | |
| 209 | 209 | } |
| 210 | 210 | {#code_end#} |
| 211 | 211 | <p> |
| ... | ... | @@ -217,7 +217,7 @@ pub fn main() !void { |
| 217 | 217 | const warn = @import("std").debug.warn; |
| 218 | 218 | |
| 219 | 219 | pub fn main() void { |
| 220 | warn("Hello, world!\n"); | |
| 220 | warn("Hello, world!\n", .{}); | |
| 221 | 221 | } |
| 222 | 222 | {#code_end#} |
| 223 | 223 | <p> |
| ... | ... | @@ -289,41 +289,50 @@ const assert = std.debug.assert; |
| 289 | 289 | pub fn main() void { |
| 290 | 290 | // integers |
| 291 | 291 | const one_plus_one: i32 = 1 + 1; |
| 292 | warn("1 + 1 = {}\n", one_plus_one); | |
| 292 | warn("1 + 1 = {}\n", .{one_plus_one}); | |
| 293 | 293 | |
| 294 | 294 | // floats |
| 295 | 295 | 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}); | |
| 297 | 297 | |
| 298 | 298 | // boolean |
| 299 | warn("{}\n{}\n{}\n", | |
| 299 | warn("{}\n{}\n{}\n", .{ | |
| 300 | 300 | true and false, |
| 301 | 301 | true or false, |
| 302 | !true); | |
| 302 | !true, | |
| 303 | }); | |
| 303 | 304 | |
| 304 | 305 | // optional |
| 305 | 306 | var optional_value: ?[]const u8 = null; |
| 306 | 307 | assert(optional_value == null); |
| 307 | 308 | |
| 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 | }); | |
| 310 | 313 | |
| 311 | 314 | optional_value = "hi"; |
| 312 | 315 | assert(optional_value != null); |
| 313 | 316 | |
| 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 | }); | |
| 316 | 321 | |
| 317 | 322 | // error union |
| 318 | 323 | var number_or_error: anyerror!i32 = error.ArgNotFound; |
| 319 | 324 | |
| 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 | }); | |
| 322 | 329 | |
| 323 | 330 | number_or_error = 1234; |
| 324 | 331 | |
| 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 | }); | |
| 327 | 336 | } |
| 328 | 337 | {#code_end#} |
| 329 | 338 | {#header_open|Primitive Types#} |
| ... | ... | @@ -954,8 +963,8 @@ extern fn foo_optimized(x: f64) f64; |
| 954 | 963 | |
| 955 | 964 | pub fn main() void { |
| 956 | 965 | 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)}); | |
| 959 | 968 | } |
| 960 | 969 | {#code_end#} |
| 961 | 970 | {#see_also|@setFloatMode|Division by Zero#} |
| ... | ... | @@ -2182,7 +2191,7 @@ test "using slices for strings" { |
| 2182 | 2191 | // You can use slice syntax on an array to convert an array into a slice. |
| 2183 | 2192 | const all_together_slice = all_together[0..]; |
| 2184 | 2193 | // 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}); | |
| 2186 | 2195 | |
| 2187 | 2196 | // Generally, you can use UTF-8 and not worry about whether something is a |
| 2188 | 2197 | // string. If you don't need to deal with individual characters, no need |
| ... | ... | @@ -2623,9 +2632,9 @@ const std = @import("std"); |
| 2623 | 2632 | |
| 2624 | 2633 | pub fn main() void { |
| 2625 | 2634 | 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))}); | |
| 2629 | 2638 | } |
| 2630 | 2639 | |
| 2631 | 2640 | fn List(comptime T: type) type { |
| ... | ... | @@ -3806,18 +3815,18 @@ test "defer basics" { |
| 3806 | 3815 | // If multiple defer statements are specified, they will be executed in |
| 3807 | 3816 | // the reverse order they were run. |
| 3808 | 3817 | fn deferUnwindExample() void { |
| 3809 | warn("\n"); | |
| 3818 | warn("\n", .{}); | |
| 3810 | 3819 | |
| 3811 | 3820 | defer { |
| 3812 | warn("1 "); | |
| 3821 | warn("1 ", .{}); | |
| 3813 | 3822 | } |
| 3814 | 3823 | defer { |
| 3815 | warn("2 "); | |
| 3824 | warn("2 ", .{}); | |
| 3816 | 3825 | } |
| 3817 | 3826 | if (false) { |
| 3818 | 3827 | // defers are not run if they are never executed. |
| 3819 | 3828 | defer { |
| 3820 | warn("3 "); | |
| 3829 | warn("3 ", .{}); | |
| 3821 | 3830 | } |
| 3822 | 3831 | } |
| 3823 | 3832 | } |
| ... | ... | @@ -3832,15 +3841,15 @@ test "defer unwinding" { |
| 3832 | 3841 | // This is especially useful in allowing a function to clean up properly |
| 3833 | 3842 | // on error, and replaces goto error handling tactics as seen in c. |
| 3834 | 3843 | fn deferErrorExample(is_error: bool) !void { |
| 3835 | warn("\nstart of function\n"); | |
| 3844 | warn("\nstart of function\n", .{}); | |
| 3836 | 3845 | |
| 3837 | 3846 | // This will always be executed on exit |
| 3838 | 3847 | defer { |
| 3839 | warn("end of function\n"); | |
| 3848 | warn("end of function\n", .{}); | |
| 3840 | 3849 | } |
| 3841 | 3850 | |
| 3842 | 3851 | errdefer { |
| 3843 | warn("encountered an error!\n"); | |
| 3852 | warn("encountered an error!\n", .{}); | |
| 3844 | 3853 | } |
| 3845 | 3854 | |
| 3846 | 3855 | if (is_error) { |
| ... | ... | @@ -5843,7 +5852,7 @@ const a_number: i32 = 1234; |
| 5843 | 5852 | const a_string = "foobar"; |
| 5844 | 5853 | |
| 5845 | 5854 | pub 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}); | |
| 5847 | 5856 | } |
| 5848 | 5857 | {#code_end#} |
| 5849 | 5858 | |
| ... | ... | @@ -5960,8 +5969,11 @@ const a_number: i32 = 1234; |
| 5960 | 5969 | const a_string = "foobar"; |
| 5961 | 5970 | |
| 5962 | 5971 | test "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 | }); | |
| 5965 | 5977 | } |
| 5966 | 5978 | {#code_end#} |
| 5967 | 5979 | <p> |
| ... | ... | @@ -5979,7 +5991,7 @@ const a_string = "foobar"; |
| 5979 | 5991 | const fmt = "here is a string: '{}' here is a number: {}\n"; |
| 5980 | 5992 | |
| 5981 | 5993 | pub fn main() void { |
| 5982 | warn(fmt, a_string, a_number); | |
| 5994 | warn(fmt, .{a_string, a_number}); | |
| 5983 | 5995 | } |
| 5984 | 5996 | {#code_end#} |
| 5985 | 5997 | <p> |
| ... | ... | @@ -6417,7 +6429,7 @@ pub fn main() void { |
| 6417 | 6429 | |
| 6418 | 6430 | fn amainWrap() void { |
| 6419 | 6431 | amain() catch |e| { |
| 6420 | std.debug.warn("{}\n", e); | |
| 6432 | std.debug.warn("{}\n", .{e}); | |
| 6421 | 6433 | if (@errorReturnTrace()) |trace| { |
| 6422 | 6434 | std.debug.dumpStackTrace(trace.*); |
| 6423 | 6435 | } |
| ... | ... | @@ -6447,8 +6459,8 @@ fn amain() !void { |
| 6447 | 6459 | const download_text = try await download_frame; |
| 6448 | 6460 | defer allocator.free(download_text); |
| 6449 | 6461 | |
| 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}); | |
| 6452 | 6464 | } |
| 6453 | 6465 | |
| 6454 | 6466 | var global_download_frame: anyframe = undefined; |
| ... | ... | @@ -6458,7 +6470,7 @@ fn fetchUrl(allocator: *Allocator, url: []const u8) ![]u8 { |
| 6458 | 6470 | suspend { |
| 6459 | 6471 | global_download_frame = @frame(); |
| 6460 | 6472 | } |
| 6461 | std.debug.warn("fetchUrl returning\n"); | |
| 6473 | std.debug.warn("fetchUrl returning\n", .{}); | |
| 6462 | 6474 | return result; |
| 6463 | 6475 | } |
| 6464 | 6476 | |
| ... | ... | @@ -6469,7 +6481,7 @@ fn readFile(allocator: *Allocator, filename: []const u8) ![]u8 { |
| 6469 | 6481 | suspend { |
| 6470 | 6482 | global_file_frame = @frame(); |
| 6471 | 6483 | } |
| 6472 | std.debug.warn("readFile returning\n"); | |
| 6484 | std.debug.warn("readFile returning\n", .{}); | |
| 6473 | 6485 | return result; |
| 6474 | 6486 | } |
| 6475 | 6487 | {#code_end#} |
| ... | ... | @@ -6487,7 +6499,7 @@ pub fn main() void { |
| 6487 | 6499 | |
| 6488 | 6500 | fn amainWrap() void { |
| 6489 | 6501 | amain() catch |e| { |
| 6490 | std.debug.warn("{}\n", e); | |
| 6502 | std.debug.warn("{}\n", .{e}); | |
| 6491 | 6503 | if (@errorReturnTrace()) |trace| { |
| 6492 | 6504 | std.debug.dumpStackTrace(trace.*); |
| 6493 | 6505 | } |
| ... | ... | @@ -6517,21 +6529,21 @@ fn amain() !void { |
| 6517 | 6529 | const download_text = try await download_frame; |
| 6518 | 6530 | defer allocator.free(download_text); |
| 6519 | 6531 | |
| 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}); | |
| 6522 | 6534 | } |
| 6523 | 6535 | |
| 6524 | 6536 | fn fetchUrl(allocator: *Allocator, url: []const u8) ![]u8 { |
| 6525 | 6537 | const result = try std.mem.dupe(allocator, u8, "this is the downloaded url contents"); |
| 6526 | 6538 | errdefer allocator.free(result); |
| 6527 | std.debug.warn("fetchUrl returning\n"); | |
| 6539 | std.debug.warn("fetchUrl returning\n", .{}); | |
| 6528 | 6540 | return result; |
| 6529 | 6541 | } |
| 6530 | 6542 | |
| 6531 | 6543 | fn readFile(allocator: *Allocator, filename: []const u8) ![]u8 { |
| 6532 | 6544 | const result = try std.mem.dupe(allocator, u8, "this is the file contents"); |
| 6533 | 6545 | errdefer allocator.free(result); |
| 6534 | std.debug.warn("readFile returning\n"); | |
| 6546 | std.debug.warn("readFile returning\n", .{}); | |
| 6535 | 6547 | return result; |
| 6536 | 6548 | } |
| 6537 | 6549 | {#code_end#} |
| ... | ... | @@ -7103,7 +7115,7 @@ const num1 = blk: { |
| 7103 | 7115 | test "main" { |
| 7104 | 7116 | @compileLog("comptime in main"); |
| 7105 | 7117 | |
| 7106 | warn("Runtime in main, num1 = {}.\n", num1); | |
| 7118 | warn("Runtime in main, num1 = {}.\n", .{num1}); | |
| 7107 | 7119 | } |
| 7108 | 7120 | {#code_end#} |
| 7109 | 7121 | <p> |
| ... | ... | @@ -7124,7 +7136,7 @@ const num1 = blk: { |
| 7124 | 7136 | }; |
| 7125 | 7137 | |
| 7126 | 7138 | test "main" { |
| 7127 | warn("Runtime in main, num1 = {}.\n", num1); | |
| 7139 | warn("Runtime in main, num1 = {}.\n", .{num1}); | |
| 7128 | 7140 | } |
| 7129 | 7141 | {#code_end#} |
| 7130 | 7142 | {#header_close#} |
| ... | ... | @@ -8706,7 +8718,7 @@ const std = @import("std"); |
| 8706 | 8718 | pub fn main() void { |
| 8707 | 8719 | var value: i32 = -1; |
| 8708 | 8720 | var unsigned = @intCast(u32, value); |
| 8709 | std.debug.warn("value: {}\n", unsigned); | |
| 8721 | std.debug.warn("value: {}\n", .{unsigned}); | |
| 8710 | 8722 | } |
| 8711 | 8723 | {#code_end#} |
| 8712 | 8724 | <p> |
| ... | ... | @@ -8728,7 +8740,7 @@ const std = @import("std"); |
| 8728 | 8740 | pub fn main() void { |
| 8729 | 8741 | var spartan_count: u16 = 300; |
| 8730 | 8742 | const byte = @intCast(u8, spartan_count); |
| 8731 | std.debug.warn("value: {}\n", byte); | |
| 8743 | std.debug.warn("value: {}\n", .{byte}); | |
| 8732 | 8744 | } |
| 8733 | 8745 | {#code_end#} |
| 8734 | 8746 | <p> |
| ... | ... | @@ -8762,7 +8774,7 @@ const std = @import("std"); |
| 8762 | 8774 | pub fn main() void { |
| 8763 | 8775 | var byte: u8 = 255; |
| 8764 | 8776 | byte += 1; |
| 8765 | std.debug.warn("value: {}\n", byte); | |
| 8777 | std.debug.warn("value: {}\n", .{byte}); | |
| 8766 | 8778 | } |
| 8767 | 8779 | {#code_end#} |
| 8768 | 8780 | {#header_close#} |
| ... | ... | @@ -8785,11 +8797,11 @@ pub fn main() !void { |
| 8785 | 8797 | var byte: u8 = 255; |
| 8786 | 8798 | |
| 8787 | 8799 | 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)}); | |
| 8789 | 8801 | return err; |
| 8790 | 8802 | }; |
| 8791 | 8803 | |
| 8792 | warn("result: {}\n", byte); | |
| 8804 | warn("result: {}\n", .{byte}); | |
| 8793 | 8805 | } |
| 8794 | 8806 | {#code_end#} |
| 8795 | 8807 | {#header_close#} |
| ... | ... | @@ -8814,9 +8826,9 @@ pub fn main() void { |
| 8814 | 8826 | |
| 8815 | 8827 | var result: u8 = undefined; |
| 8816 | 8828 | if (@addWithOverflow(u8, byte, 10, &result)) { |
| 8817 | warn("overflowed result: {}\n", result); | |
| 8829 | warn("overflowed result: {}\n", .{result}); | |
| 8818 | 8830 | } else { |
| 8819 | warn("result: {}\n", result); | |
| 8831 | warn("result: {}\n", .{result}); | |
| 8820 | 8832 | } |
| 8821 | 8833 | } |
| 8822 | 8834 | {#code_end#} |
| ... | ... | @@ -8861,7 +8873,7 @@ const std = @import("std"); |
| 8861 | 8873 | pub fn main() void { |
| 8862 | 8874 | var x: u8 = 0b01010101; |
| 8863 | 8875 | var y = @shlExact(x, 2); |
| 8864 | std.debug.warn("value: {}\n", y); | |
| 8876 | std.debug.warn("value: {}\n", .{y}); | |
| 8865 | 8877 | } |
| 8866 | 8878 | {#code_end#} |
| 8867 | 8879 | {#header_close#} |
| ... | ... | @@ -8879,7 +8891,7 @@ const std = @import("std"); |
| 8879 | 8891 | pub fn main() void { |
| 8880 | 8892 | var x: u8 = 0b10101010; |
| 8881 | 8893 | var y = @shrExact(x, 2); |
| 8882 | std.debug.warn("value: {}\n", y); | |
| 8894 | std.debug.warn("value: {}\n", .{y}); | |
| 8883 | 8895 | } |
| 8884 | 8896 | {#code_end#} |
| 8885 | 8897 | {#header_close#} |
| ... | ... | @@ -8900,7 +8912,7 @@ pub fn main() void { |
| 8900 | 8912 | var a: u32 = 1; |
| 8901 | 8913 | var b: u32 = 0; |
| 8902 | 8914 | var c = a / b; |
| 8903 | std.debug.warn("value: {}\n", c); | |
| 8915 | std.debug.warn("value: {}\n", .{c}); | |
| 8904 | 8916 | } |
| 8905 | 8917 | {#code_end#} |
| 8906 | 8918 | {#header_close#} |
| ... | ... | @@ -8921,7 +8933,7 @@ pub fn main() void { |
| 8921 | 8933 | var a: u32 = 10; |
| 8922 | 8934 | var b: u32 = 0; |
| 8923 | 8935 | var c = a % b; |
| 8924 | std.debug.warn("value: {}\n", c); | |
| 8936 | std.debug.warn("value: {}\n", .{c}); | |
| 8925 | 8937 | } |
| 8926 | 8938 | {#code_end#} |
| 8927 | 8939 | {#header_close#} |
| ... | ... | @@ -8942,7 +8954,7 @@ pub fn main() void { |
| 8942 | 8954 | var a: u32 = 10; |
| 8943 | 8955 | var b: u32 = 3; |
| 8944 | 8956 | var c = @divExact(a, b); |
| 8945 | std.debug.warn("value: {}\n", c); | |
| 8957 | std.debug.warn("value: {}\n", .{c}); | |
| 8946 | 8958 | } |
| 8947 | 8959 | {#code_end#} |
| 8948 | 8960 | {#header_close#} |
| ... | ... | @@ -8961,7 +8973,7 @@ const std = @import("std"); |
| 8961 | 8973 | pub fn main() void { |
| 8962 | 8974 | var bytes = [5]u8{ 1, 2, 3, 4, 5 }; |
| 8963 | 8975 | var slice = @bytesToSlice(u32, bytes[0..]); |
| 8964 | std.debug.warn("value: {}\n", slice[0]); | |
| 8976 | std.debug.warn("value: {}\n", .{slice[0]}); | |
| 8965 | 8977 | } |
| 8966 | 8978 | {#code_end#} |
| 8967 | 8979 | {#header_close#} |
| ... | ... | @@ -8980,7 +8992,7 @@ const std = @import("std"); |
| 8980 | 8992 | pub fn main() void { |
| 8981 | 8993 | var optional_number: ?i32 = null; |
| 8982 | 8994 | var number = optional_number.?; |
| 8983 | std.debug.warn("value: {}\n", number); | |
| 8995 | std.debug.warn("value: {}\n", .{number}); | |
| 8984 | 8996 | } |
| 8985 | 8997 | {#code_end#} |
| 8986 | 8998 | <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 { |
| 8991 | 9003 | const optional_number: ?i32 = null; |
| 8992 | 9004 | |
| 8993 | 9005 | if (optional_number) |number| { |
| 8994 | warn("got number: {}\n", number); | |
| 9006 | warn("got number: {}\n", .{number}); | |
| 8995 | 9007 | } else { |
| 8996 | warn("it's null\n"); | |
| 9008 | warn("it's null\n", .{}); | |
| 8997 | 9009 | } |
| 8998 | 9010 | } |
| 8999 | 9011 | {#code_end#} |
| ... | ... | @@ -9016,7 +9028,7 @@ const std = @import("std"); |
| 9016 | 9028 | |
| 9017 | 9029 | pub fn main() void { |
| 9018 | 9030 | const number = getNumberOrFail() catch unreachable; |
| 9019 | std.debug.warn("value: {}\n", number); | |
| 9031 | std.debug.warn("value: {}\n", .{number}); | |
| 9020 | 9032 | } |
| 9021 | 9033 | |
| 9022 | 9034 | fn getNumberOrFail() !i32 { |
| ... | ... | @@ -9032,9 +9044,9 @@ pub fn main() void { |
| 9032 | 9044 | const result = getNumberOrFail(); |
| 9033 | 9045 | |
| 9034 | 9046 | if (result) |number| { |
| 9035 | warn("got number: {}\n", number); | |
| 9047 | warn("got number: {}\n", .{number}); | |
| 9036 | 9048 | } else |err| { |
| 9037 | warn("got error: {}\n", @errorName(err)); | |
| 9049 | warn("got error: {}\n", .{@errorName(err)}); | |
| 9038 | 9050 | } |
| 9039 | 9051 | } |
| 9040 | 9052 | |
| ... | ... | @@ -9061,7 +9073,7 @@ pub fn main() void { |
| 9061 | 9073 | var err = error.AnError; |
| 9062 | 9074 | var number = @errorToInt(err) + 500; |
| 9063 | 9075 | var invalid_err = @intToError(number); |
| 9064 | std.debug.warn("value: {}\n", number); | |
| 9076 | std.debug.warn("value: {}\n", .{number}); | |
| 9065 | 9077 | } |
| 9066 | 9078 | {#code_end#} |
| 9067 | 9079 | {#header_close#} |
| ... | ... | @@ -9091,7 +9103,7 @@ const Foo = enum { |
| 9091 | 9103 | pub fn main() void { |
| 9092 | 9104 | var a: u2 = 3; |
| 9093 | 9105 | var b = @intToEnum(Foo, a); |
| 9094 | std.debug.warn("value: {}\n", @tagName(b)); | |
| 9106 | std.debug.warn("value: {}\n", .{@tagName(b)}); | |
| 9095 | 9107 | } |
| 9096 | 9108 | {#code_end#} |
| 9097 | 9109 | {#header_close#} |
| ... | ... | @@ -9128,7 +9140,7 @@ pub fn main() void { |
| 9128 | 9140 | } |
| 9129 | 9141 | fn foo(set1: Set1) void { |
| 9130 | 9142 | const x = @errSetCast(Set2, set1); |
| 9131 | std.debug.warn("value: {}\n", x); | |
| 9143 | std.debug.warn("value: {}\n", .{x}); | |
| 9132 | 9144 | } |
| 9133 | 9145 | {#code_end#} |
| 9134 | 9146 | {#header_close#} |
| ... | ... | @@ -9184,7 +9196,7 @@ pub fn main() void { |
| 9184 | 9196 | |
| 9185 | 9197 | fn bar(f: *Foo) void { |
| 9186 | 9198 | f.float = 12.34; |
| 9187 | std.debug.warn("value: {}\n", f.float); | |
| 9199 | std.debug.warn("value: {}\n", .{f.float}); | |
| 9188 | 9200 | } |
| 9189 | 9201 | {#code_end#} |
| 9190 | 9202 | <p> |
| ... | ... | @@ -9208,7 +9220,7 @@ pub fn main() void { |
| 9208 | 9220 | |
| 9209 | 9221 | fn bar(f: *Foo) void { |
| 9210 | 9222 | f.* = Foo{ .float = 12.34 }; |
| 9211 | std.debug.warn("value: {}\n", f.float); | |
| 9223 | std.debug.warn("value: {}\n", .{f.float}); | |
| 9212 | 9224 | } |
| 9213 | 9225 | {#code_end#} |
| 9214 | 9226 | <p> |
| ... | ... | @@ -9227,7 +9239,7 @@ pub fn main() void { |
| 9227 | 9239 | var f = Foo{ .int = 42 }; |
| 9228 | 9240 | f = Foo{ .float = undefined }; |
| 9229 | 9241 | bar(&f); |
| 9230 | std.debug.warn("value: {}\n", f.float); | |
| 9242 | std.debug.warn("value: {}\n", .{f.float}); | |
| 9231 | 9243 | } |
| 9232 | 9244 | |
| 9233 | 9245 | fn bar(f: *Foo) void { |
| ... | ... | @@ -9348,7 +9360,7 @@ pub fn main() !void { |
| 9348 | 9360 | const allocator = &arena.allocator; |
| 9349 | 9361 | |
| 9350 | 9362 | const ptr = try allocator.create(i32); |
| 9351 | std.debug.warn("ptr={*}\n", ptr); | |
| 9363 | std.debug.warn("ptr={*}\n", .{ptr}); | |
| 9352 | 9364 | } |
| 9353 | 9365 | {#code_end#} |
| 9354 | 9366 | When using this kind of allocator, there is no need to free anything manually. Everything |
| ... | ... | @@ -9881,7 +9893,7 @@ pub fn main() !void { |
| 9881 | 9893 | defer std.process.argsFree(std.heap.page_allocator, args); |
| 9882 | 9894 | |
| 9883 | 9895 | for (args) |arg, i| { |
| 9884 | std.debug.warn("{}: {}\n", i, arg); | |
| 9896 | std.debug.warn("{}: {}\n", .{i, arg}); | |
| 9885 | 9897 | } |
| 9886 | 9898 | } |
| 9887 | 9899 | {#code_end#} |
lib/std/atomic/queue.zig+9-10| ... | ... | @@ -116,19 +116,19 @@ pub fn Queue(comptime T: type) type { |
| 116 | 116 | fn dumpRecursive(s: *std.io.OutStream(Error), optional_node: ?*Node, indent: usize) Error!void { |
| 117 | 117 | try s.writeByteNTimes(' ', indent); |
| 118 | 118 | 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 }); | |
| 120 | 120 | try dumpRecursive(s, node.next, indent + 1); |
| 121 | 121 | } else { |
| 122 | try s.print("(null)\n"); | |
| 122 | try s.print("(null)\n", .{}); | |
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | }; |
| 126 | 126 | const held = self.mutex.acquire(); |
| 127 | 127 | defer held.release(); |
| 128 | 128 | |
| 129 | try stream.print("head: "); | |
| 129 | try stream.print("head: ", .{}); | |
| 130 | 130 | try S.dumpRecursive(stream, self.head, 0); |
| 131 | try stream.print("tail: "); | |
| 131 | try stream.print("tail: ", .{}); | |
| 132 | 132 | try S.dumpRecursive(stream, self.tail, 0); |
| 133 | 133 | } |
| 134 | 134 | }; |
| ... | ... | @@ -207,16 +207,15 @@ test "std.atomic.Queue" { |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | 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 }); | |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | 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:{}", .{ | |
| 216 | 215 | context.get_count, |
| 217 | 216 | @as(u32, puts_per_thread), |
| 218 | 217 | @as(u32, put_thread_count), |
| 219 | ); | |
| 218 | }); | |
| 220 | 219 | } |
| 221 | 220 | } |
| 222 | 221 | |
| ... | ... | @@ -351,7 +350,7 @@ test "std.atomic.Queue dump" { |
| 351 | 350 | \\tail: 0x{x}=1 |
| 352 | 351 | \\ (null) |
| 353 | 352 | \\ |
| 354 | , @ptrToInt(queue.head), @ptrToInt(queue.tail)); | |
| 353 | , .{ @ptrToInt(queue.head), @ptrToInt(queue.tail) }); | |
| 355 | 354 | expect(mem.eql(u8, buffer[0..sos.pos], expected)); |
| 356 | 355 | |
| 357 | 356 | // Test a stream with two elements |
| ... | ... | @@ -372,6 +371,6 @@ test "std.atomic.Queue dump" { |
| 372 | 371 | \\tail: 0x{x}=2 |
| 373 | 372 | \\ (null) |
| 374 | 373 | \\ |
| 375 | , @ptrToInt(queue.head), @ptrToInt(queue.head.?.next), @ptrToInt(queue.tail)); | |
| 374 | , .{ @ptrToInt(queue.head), @ptrToInt(queue.head.?.next), @ptrToInt(queue.tail) }); | |
| 376 | 375 | expect(mem.eql(u8, buffer[0..sos.pos], expected)); |
| 377 | 376 | } |
lib/std/atomic/stack.zig+3-4| ... | ... | @@ -134,16 +134,15 @@ test "std.atomic.stack" { |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | 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 }); | |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | 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:{}", .{ | |
| 143 | 142 | context.get_count, |
| 144 | 143 | @as(u32, puts_per_thread), |
| 145 | 144 | @as(u32, put_thread_count), |
| 146 | ); | |
| 145 | }); | |
| 147 | 146 | } |
| 148 | 147 | } |
| 149 | 148 |
lib/std/buffer.zig+4-4| ... | ... | @@ -16,7 +16,7 @@ pub const Buffer = struct { |
| 16 | 16 | mem.copy(u8, self.list.items, m); |
| 17 | 17 | return self; |
| 18 | 18 | } |
| 19 | ||
| 19 | ||
| 20 | 20 | /// Initialize memory to size bytes of undefined values. |
| 21 | 21 | /// Must deinitialize with deinit. |
| 22 | 22 | pub fn initSize(allocator: *Allocator, size: usize) !Buffer { |
| ... | ... | @@ -24,7 +24,7 @@ pub const Buffer = struct { |
| 24 | 24 | try self.resize(size); |
| 25 | 25 | return self; |
| 26 | 26 | } |
| 27 | ||
| 27 | ||
| 28 | 28 | /// Initialize with capacity to hold at least num bytes. |
| 29 | 29 | /// Must deinitialize with deinit. |
| 30 | 30 | pub fn initCapacity(allocator: *Allocator, num: usize) !Buffer { |
| ... | ... | @@ -64,7 +64,7 @@ pub const Buffer = struct { |
| 64 | 64 | return result; |
| 65 | 65 | } |
| 66 | 66 | |
| 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 { | |
| 68 | 68 | const countSize = struct { |
| 69 | 69 | fn countSize(size: *usize, bytes: []const u8) (error{}!void) { |
| 70 | 70 | size.* += bytes.len; |
| ... | ... | @@ -107,7 +107,7 @@ pub const Buffer = struct { |
| 107 | 107 | pub fn len(self: Buffer) usize { |
| 108 | 108 | return self.list.len - 1; |
| 109 | 109 | } |
| 110 | ||
| 110 | ||
| 111 | 111 | pub fn capacity(self: Buffer) usize { |
| 112 | 112 | return if (self.list.items.len > 0) |
| 113 | 113 | self.list.items.len - 1 |
lib/std/build.zig+104-82| ... | ... | @@ -232,7 +232,7 @@ pub const Builder = struct { |
| 232 | 232 | /// To run an executable built with zig build, see `LibExeObjStep.run`. |
| 233 | 233 | pub fn addSystemCommand(self: *Builder, argv: []const []const u8) *RunStep { |
| 234 | 234 | 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]})); | |
| 236 | 236 | run_step.addArgs(argv); |
| 237 | 237 | return run_step; |
| 238 | 238 | } |
| ... | ... | @@ -258,7 +258,7 @@ pub const Builder = struct { |
| 258 | 258 | return write_file_step; |
| 259 | 259 | } |
| 260 | 260 | |
| 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 { | |
| 262 | 262 | const data = self.fmt(format, args); |
| 263 | 263 | const log_step = self.allocator.create(LogStep) catch unreachable; |
| 264 | 264 | log_step.* = LogStep.init(self, data); |
| ... | ... | @@ -330,7 +330,7 @@ pub const Builder = struct { |
| 330 | 330 | for (self.installed_files.toSliceConst()) |installed_file| { |
| 331 | 331 | const full_path = self.getInstallPath(installed_file.dir, installed_file.path); |
| 332 | 332 | if (self.verbose) { |
| 333 | warn("rm {}\n", full_path); | |
| 333 | warn("rm {}\n", .{full_path}); | |
| 334 | 334 | } |
| 335 | 335 | fs.deleteTree(full_path) catch {}; |
| 336 | 336 | } |
| ... | ... | @@ -340,7 +340,7 @@ pub const Builder = struct { |
| 340 | 340 | |
| 341 | 341 | fn makeOneStep(self: *Builder, s: *Step) anyerror!void { |
| 342 | 342 | if (s.loop_flag) { |
| 343 | warn("Dependency loop detected:\n {}\n", s.name); | |
| 343 | warn("Dependency loop detected:\n {}\n", .{s.name}); | |
| 344 | 344 | return error.DependencyLoopDetected; |
| 345 | 345 | } |
| 346 | 346 | s.loop_flag = true; |
| ... | ... | @@ -348,7 +348,7 @@ pub const Builder = struct { |
| 348 | 348 | for (s.dependencies.toSlice()) |dep| { |
| 349 | 349 | self.makeOneStep(dep) catch |err| { |
| 350 | 350 | if (err == error.DependencyLoopDetected) { |
| 351 | warn(" {}\n", s.name); | |
| 351 | warn(" {}\n", .{s.name}); | |
| 352 | 352 | } |
| 353 | 353 | return err; |
| 354 | 354 | }; |
| ... | ... | @@ -365,7 +365,7 @@ pub const Builder = struct { |
| 365 | 365 | return &top_level_step.step; |
| 366 | 366 | } |
| 367 | 367 | } |
| 368 | warn("Cannot run step '{}' because it does not exist\n", name); | |
| 368 | warn("Cannot run step '{}' because it does not exist\n", .{name}); | |
| 369 | 369 | return error.InvalidStepName; |
| 370 | 370 | } |
| 371 | 371 | |
| ... | ... | @@ -378,12 +378,12 @@ pub const Builder = struct { |
| 378 | 378 | const word = it.next() orelse break; |
| 379 | 379 | if (mem.eql(u8, word, "-isystem")) { |
| 380 | 380 | 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", .{}); | |
| 382 | 382 | break; |
| 383 | 383 | }; |
| 384 | 384 | self.addNativeSystemIncludeDir(include_path); |
| 385 | 385 | } else { |
| 386 | warn("Unrecognized C flag from NIX_CFLAGS_COMPILE: {}\n", word); | |
| 386 | warn("Unrecognized C flag from NIX_CFLAGS_COMPILE: {}\n", .{word}); | |
| 387 | 387 | break; |
| 388 | 388 | } |
| 389 | 389 | } |
| ... | ... | @@ -397,7 +397,7 @@ pub const Builder = struct { |
| 397 | 397 | const word = it.next() orelse break; |
| 398 | 398 | if (mem.eql(u8, word, "-rpath")) { |
| 399 | 399 | 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", .{}); | |
| 401 | 401 | break; |
| 402 | 402 | }; |
| 403 | 403 | self.addNativeSystemRPath(rpath); |
| ... | ... | @@ -405,7 +405,7 @@ pub const Builder = struct { |
| 405 | 405 | const lib_path = word[2..]; |
| 406 | 406 | self.addNativeSystemLibPath(lib_path); |
| 407 | 407 | } else { |
| 408 | warn("Unrecognized C flag from NIX_LDFLAGS: {}\n", word); | |
| 408 | warn("Unrecognized C flag from NIX_LDFLAGS: {}\n", .{word}); | |
| 409 | 409 | break; |
| 410 | 410 | } |
| 411 | 411 | } |
| ... | ... | @@ -431,8 +431,8 @@ pub const Builder = struct { |
| 431 | 431 | self.addNativeSystemIncludeDir("/usr/local/include"); |
| 432 | 432 | self.addNativeSystemLibPath("/usr/local/lib"); |
| 433 | 433 | |
| 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})); | |
| 436 | 436 | |
| 437 | 437 | self.addNativeSystemIncludeDir("/usr/include"); |
| 438 | 438 | self.addNativeSystemLibPath("/usr/lib"); |
| ... | ... | @@ -440,7 +440,7 @@ pub const Builder = struct { |
| 440 | 440 | // example: on a 64-bit debian-based linux distro, with zlib installed from apt: |
| 441 | 441 | // zlib.h is in /usr/include (added above) |
| 442 | 442 | // 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})); | |
| 444 | 444 | }, |
| 445 | 445 | } |
| 446 | 446 | } |
| ... | ... | @@ -453,7 +453,7 @@ pub const Builder = struct { |
| 453 | 453 | .description = description, |
| 454 | 454 | }; |
| 455 | 455 | if ((self.available_options_map.put(name, available_option) catch unreachable) != null) { |
| 456 | panic("Option '{}' declared twice", name); | |
| 456 | panic("Option '{}' declared twice", .{name}); | |
| 457 | 457 | } |
| 458 | 458 | self.available_options_list.append(available_option) catch unreachable; |
| 459 | 459 | |
| ... | ... | @@ -468,33 +468,33 @@ pub const Builder = struct { |
| 468 | 468 | } else if (mem.eql(u8, s, "false")) { |
| 469 | 469 | return false; |
| 470 | 470 | } 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 }); | |
| 472 | 472 | self.markInvalidUserInput(); |
| 473 | 473 | return null; |
| 474 | 474 | } |
| 475 | 475 | }, |
| 476 | 476 | 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}); | |
| 478 | 478 | self.markInvalidUserInput(); |
| 479 | 479 | return null; |
| 480 | 480 | }, |
| 481 | 481 | }, |
| 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", .{}), | |
| 484 | 484 | TypeId.String => switch (entry.value.value) { |
| 485 | 485 | 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}); | |
| 487 | 487 | self.markInvalidUserInput(); |
| 488 | 488 | return null; |
| 489 | 489 | }, |
| 490 | 490 | 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}); | |
| 492 | 492 | self.markInvalidUserInput(); |
| 493 | 493 | return null; |
| 494 | 494 | }, |
| 495 | 495 | UserValue.Scalar => |s| return s, |
| 496 | 496 | }, |
| 497 | TypeId.List => panic("TODO list options to build script"), | |
| 497 | TypeId.List => panic("TODO list options to build script", .{}), | |
| 498 | 498 | } |
| 499 | 499 | } |
| 500 | 500 | |
| ... | ... | @@ -513,7 +513,7 @@ pub const Builder = struct { |
| 513 | 513 | if (self.release_mode != null) { |
| 514 | 514 | @panic("setPreferredReleaseMode must be called before standardReleaseOptions and may not be called twice"); |
| 515 | 515 | } |
| 516 | const description = self.fmt("create a release build ({})", @tagName(mode)); | |
| 516 | const description = self.fmt("create a release build ({})", .{@tagName(mode)}); | |
| 517 | 517 | self.is_release = self.option(bool, "release", description) orelse false; |
| 518 | 518 | self.release_mode = if (self.is_release) mode else builtin.Mode.Debug; |
| 519 | 519 | } |
| ... | ... | @@ -536,7 +536,7 @@ pub const Builder = struct { |
| 536 | 536 | else if (!release_fast and !release_safe and !release_small) |
| 537 | 537 | builtin.Mode.Debug |
| 538 | 538 | 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)", .{}); | |
| 540 | 540 | self.markInvalidUserInput(); |
| 541 | 541 | break :x builtin.Mode.Debug; |
| 542 | 542 | }; |
| ... | ... | @@ -599,7 +599,7 @@ pub const Builder = struct { |
| 599 | 599 | }) catch unreachable; |
| 600 | 600 | }, |
| 601 | 601 | 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 }); | |
| 603 | 603 | return true; |
| 604 | 604 | }, |
| 605 | 605 | } |
| ... | ... | @@ -620,11 +620,11 @@ pub const Builder = struct { |
| 620 | 620 | // option already exists |
| 621 | 621 | switch (gop.kv.value.value) { |
| 622 | 622 | 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 }); | |
| 624 | 624 | return true; |
| 625 | 625 | }, |
| 626 | 626 | 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}); | |
| 628 | 628 | return true; |
| 629 | 629 | }, |
| 630 | 630 | UserValue.Flag => {}, |
| ... | ... | @@ -665,7 +665,7 @@ pub const Builder = struct { |
| 665 | 665 | while (true) { |
| 666 | 666 | const entry = it.next() orelse break; |
| 667 | 667 | if (!entry.value.used) { |
| 668 | warn("Invalid option: -D{}\n\n", entry.key); | |
| 668 | warn("Invalid option: -D{}\n\n", .{entry.key}); | |
| 669 | 669 | self.markInvalidUserInput(); |
| 670 | 670 | } |
| 671 | 671 | } |
| ... | ... | @@ -678,11 +678,11 @@ pub const Builder = struct { |
| 678 | 678 | } |
| 679 | 679 | |
| 680 | 680 | 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}); | |
| 682 | 682 | for (argv) |arg| { |
| 683 | warn("{} ", arg); | |
| 683 | warn("{} ", .{arg}); | |
| 684 | 684 | } |
| 685 | warn("\n"); | |
| 685 | warn("\n", .{}); | |
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | fn spawnChildEnvMap(self: *Builder, cwd: ?[]const u8, env_map: *const BufMap, argv: []const []const u8) !void { |
| ... | ... | @@ -697,20 +697,20 @@ pub const Builder = struct { |
| 697 | 697 | child.env_map = env_map; |
| 698 | 698 | |
| 699 | 699 | 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) }); | |
| 701 | 701 | return err; |
| 702 | 702 | }; |
| 703 | 703 | |
| 704 | 704 | switch (term) { |
| 705 | 705 | .Exited => |code| { |
| 706 | 706 | 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}); | |
| 708 | 708 | printCmd(cwd, argv); |
| 709 | 709 | return error.UncleanExit; |
| 710 | 710 | } |
| 711 | 711 | }, |
| 712 | 712 | else => { |
| 713 | warn("The following command terminated unexpectedly:\n"); | |
| 713 | warn("The following command terminated unexpectedly:\n", .{}); | |
| 714 | 714 | printCmd(cwd, argv); |
| 715 | 715 | |
| 716 | 716 | return error.UncleanExit; |
| ... | ... | @@ -720,7 +720,7 @@ pub const Builder = struct { |
| 720 | 720 | |
| 721 | 721 | pub fn makePath(self: *Builder, path: []const u8) !void { |
| 722 | 722 | 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) }); | |
| 724 | 724 | return err; |
| 725 | 725 | }; |
| 726 | 726 | } |
| ... | ... | @@ -793,12 +793,12 @@ pub const Builder = struct { |
| 793 | 793 | |
| 794 | 794 | fn updateFile(self: *Builder, source_path: []const u8, dest_path: []const u8) !void { |
| 795 | 795 | if (self.verbose) { |
| 796 | warn("cp {} {} ", source_path, dest_path); | |
| 796 | warn("cp {} {} ", .{ source_path, dest_path }); | |
| 797 | 797 | } |
| 798 | 798 | const prev_status = try fs.updateFile(source_path, dest_path); |
| 799 | 799 | 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", .{}), | |
| 802 | 802 | }; |
| 803 | 803 | } |
| 804 | 804 | |
| ... | ... | @@ -806,7 +806,7 @@ pub const Builder = struct { |
| 806 | 806 | return fs.path.resolve(self.allocator, &[_][]const u8{ self.build_root, rel_path }) catch unreachable; |
| 807 | 807 | } |
| 808 | 808 | |
| 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 { | |
| 810 | 810 | return fmt_lib.allocPrint(self.allocator, format, args) catch unreachable; |
| 811 | 811 | } |
| 812 | 812 | |
| ... | ... | @@ -818,7 +818,11 @@ pub const Builder = struct { |
| 818 | 818 | if (fs.path.isAbsolute(name)) { |
| 819 | 819 | return name; |
| 820 | 820 | } |
| 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 | }); | |
| 822 | 826 | return fs.realpathAlloc(self.allocator, full_path) catch continue; |
| 823 | 827 | } |
| 824 | 828 | } |
| ... | ... | @@ -829,7 +833,10 @@ pub const Builder = struct { |
| 829 | 833 | } |
| 830 | 834 | var it = mem.tokenize(PATH, &[_]u8{fs.path.delimiter}); |
| 831 | 835 | 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 | }); | |
| 833 | 840 | return fs.realpathAlloc(self.allocator, full_path) catch continue; |
| 834 | 841 | } |
| 835 | 842 | } |
| ... | ... | @@ -839,7 +846,10 @@ pub const Builder = struct { |
| 839 | 846 | return name; |
| 840 | 847 | } |
| 841 | 848 | 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 | }); | |
| 843 | 853 | return fs.realpathAlloc(self.allocator, full_path) catch continue; |
| 844 | 854 | } |
| 845 | 855 | } |
| ... | ... | @@ -896,17 +906,17 @@ pub const Builder = struct { |
| 896 | 906 | var code: u8 = undefined; |
| 897 | 907 | return self.execAllowFail(argv, &code, .Inherit) catch |err| switch (err) { |
| 898 | 908 | 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", .{}); | |
| 900 | 910 | printCmd(null, argv); |
| 901 | 911 | std.os.exit(@truncate(u8, code)); |
| 902 | 912 | }, |
| 903 | 913 | error.ExitCodeFailure => { |
| 904 | warn("The following command exited with error code {}:\n", code); | |
| 914 | warn("The following command exited with error code {}:\n", .{code}); | |
| 905 | 915 | printCmd(null, argv); |
| 906 | 916 | std.os.exit(@truncate(u8, code)); |
| 907 | 917 | }, |
| 908 | 918 | error.ProcessTerminated => { |
| 909 | warn("The following command terminated unexpectedly:\n"); | |
| 919 | warn("The following command terminated unexpectedly:\n", .{}); | |
| 910 | 920 | printCmd(null, argv); |
| 911 | 921 | std.os.exit(@truncate(u8, code)); |
| 912 | 922 | }, |
| ... | ... | @@ -1133,7 +1143,7 @@ pub const LibExeObjStep = struct { |
| 1133 | 1143 | |
| 1134 | 1144 | fn initExtraArgs(builder: *Builder, name: []const u8, root_src: ?[]const u8, kind: Kind, is_dynamic: bool, ver: Version) LibExeObjStep { |
| 1135 | 1145 | 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}); | |
| 1137 | 1147 | } |
| 1138 | 1148 | var self = LibExeObjStep{ |
| 1139 | 1149 | .strip = false, |
| ... | ... | @@ -1150,9 +1160,9 @@ pub const LibExeObjStep = struct { |
| 1150 | 1160 | .step = Step.init(name, builder.allocator, make), |
| 1151 | 1161 | .version = ver, |
| 1152 | 1162 | .out_filename = undefined, |
| 1153 | .out_h_filename = builder.fmt("{}.h", name), | |
| 1163 | .out_h_filename = builder.fmt("{}.h", .{name}), | |
| 1154 | 1164 | .out_lib_filename = undefined, |
| 1155 | .out_pdb_filename = builder.fmt("{}.pdb", name), | |
| 1165 | .out_pdb_filename = builder.fmt("{}.pdb", .{name}), | |
| 1156 | 1166 | .major_only_filename = undefined, |
| 1157 | 1167 | .name_only_filename = undefined, |
| 1158 | 1168 | .packages = ArrayList(Pkg).init(builder.allocator), |
| ... | ... | @@ -1186,36 +1196,48 @@ pub const LibExeObjStep = struct { |
| 1186 | 1196 | fn computeOutFileNames(self: *LibExeObjStep) void { |
| 1187 | 1197 | switch (self.kind) { |
| 1188 | 1198 | .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() }); | |
| 1190 | 1200 | }, |
| 1191 | 1201 | .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() }); | |
| 1193 | 1203 | }, |
| 1194 | 1204 | .Test => { |
| 1195 | self.out_filename = self.builder.fmt("test{}", self.target.exeFileExt()); | |
| 1205 | self.out_filename = self.builder.fmt("test{}", .{self.target.exeFileExt()}); | |
| 1196 | 1206 | }, |
| 1197 | 1207 | .Lib => { |
| 1198 | 1208 | if (!self.is_dynamic) { |
| 1199 | self.out_filename = self.builder.fmt( | |
| 1200 | "{}{}{}", | |
| 1209 | self.out_filename = self.builder.fmt("{}{}{}", .{ | |
| 1201 | 1210 | self.target.libPrefix(), |
| 1202 | 1211 | self.name, |
| 1203 | 1212 | self.target.staticLibSuffix(), |
| 1204 | ); | |
| 1213 | }); | |
| 1205 | 1214 | self.out_lib_filename = self.out_filename; |
| 1206 | 1215 | } else { |
| 1207 | 1216 | 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}); | |
| 1211 | 1228 | self.out_lib_filename = self.out_filename; |
| 1212 | 1229 | } 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}); | |
| 1215 | 1232 | } 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}); | |
| 1219 | 1241 | self.out_lib_filename = self.out_filename; |
| 1220 | 1242 | } |
| 1221 | 1243 | } |
| ... | ... | @@ -1268,7 +1290,7 @@ pub const LibExeObjStep = struct { |
| 1268 | 1290 | // It doesn't have to be native. We catch that if you actually try to run it. |
| 1269 | 1291 | // Consider that this is declarative; the run step may not be run unless a user |
| 1270 | 1292 | // 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})); | |
| 1272 | 1294 | run_step.addArtifactArg(exe); |
| 1273 | 1295 | |
| 1274 | 1296 | if (exe.vcpkg_bin_path) |path| { |
| ... | ... | @@ -1420,7 +1442,7 @@ pub const LibExeObjStep = struct { |
| 1420 | 1442 | } else if (mem.eql(u8, tok, "-pthread")) { |
| 1421 | 1443 | self.linkLibC(); |
| 1422 | 1444 | } else if (self.builder.verbose) { |
| 1423 | warn("Ignoring pkg-config flag '{}'\n", tok); | |
| 1445 | warn("Ignoring pkg-config flag '{}'\n", .{tok}); | |
| 1424 | 1446 | } |
| 1425 | 1447 | } |
| 1426 | 1448 | } |
| ... | ... | @@ -1653,7 +1675,7 @@ pub const LibExeObjStep = struct { |
| 1653 | 1675 | const builder = self.builder; |
| 1654 | 1676 | |
| 1655 | 1677 | 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}); | |
| 1657 | 1679 | return error.NeedAnObject; |
| 1658 | 1680 | } |
| 1659 | 1681 | |
| ... | ... | @@ -1725,7 +1747,7 @@ pub const LibExeObjStep = struct { |
| 1725 | 1747 | if (self.build_options_contents.len() > 0) { |
| 1726 | 1748 | const build_options_file = try fs.path.join( |
| 1727 | 1749 | 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}) }, | |
| 1729 | 1751 | ); |
| 1730 | 1752 | try std.io.writeFile(build_options_file, self.build_options_contents.toSliceConst()); |
| 1731 | 1753 | try zig_args.append("--pkg-begin"); |
| ... | ... | @@ -1780,13 +1802,13 @@ pub const LibExeObjStep = struct { |
| 1780 | 1802 | |
| 1781 | 1803 | if (self.kind == Kind.Lib and self.is_dynamic) { |
| 1782 | 1804 | 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; | |
| 1784 | 1806 | |
| 1785 | 1807 | 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; | |
| 1787 | 1809 | |
| 1788 | 1810 | 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; | |
| 1790 | 1812 | } |
| 1791 | 1813 | if (self.is_dynamic) { |
| 1792 | 1814 | try zig_args.append("-dynamic"); |
| ... | ... | @@ -1811,7 +1833,7 @@ pub const LibExeObjStep = struct { |
| 1811 | 1833 | |
| 1812 | 1834 | if (self.target_glibc) |ver| { |
| 1813 | 1835 | 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 })); | |
| 1815 | 1837 | } |
| 1816 | 1838 | |
| 1817 | 1839 | if (self.linker_script) |linker_script| { |
| ... | ... | @@ -2079,7 +2101,7 @@ pub const RunStep = struct { |
| 2079 | 2101 | } |
| 2080 | 2102 | |
| 2081 | 2103 | 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 }); | |
| 2083 | 2105 | env_map.set(key, new_path) catch unreachable; |
| 2084 | 2106 | } else { |
| 2085 | 2107 | env_map.set(key, search_path) catch unreachable; |
| ... | ... | @@ -2153,7 +2175,7 @@ const InstallArtifactStep = struct { |
| 2153 | 2175 | const self = builder.allocator.create(Self) catch unreachable; |
| 2154 | 2176 | self.* = Self{ |
| 2155 | 2177 | .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), | |
| 2157 | 2179 | .artifact = artifact, |
| 2158 | 2180 | .dest_dir = switch (artifact.kind) { |
| 2159 | 2181 | .Obj => unreachable, |
| ... | ... | @@ -2219,7 +2241,7 @@ pub const InstallFileStep = struct { |
| 2219 | 2241 | builder.pushInstalledFile(dir, dest_rel_path); |
| 2220 | 2242 | return InstallFileStep{ |
| 2221 | 2243 | .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), | |
| 2223 | 2245 | .src_path = src_path, |
| 2224 | 2246 | .dir = dir, |
| 2225 | 2247 | .dest_rel_path = dest_rel_path, |
| ... | ... | @@ -2253,7 +2275,7 @@ pub const InstallDirStep = struct { |
| 2253 | 2275 | builder.pushInstalledFile(options.install_dir, options.install_subdir); |
| 2254 | 2276 | return InstallDirStep{ |
| 2255 | 2277 | .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), | |
| 2257 | 2279 | .options = options, |
| 2258 | 2280 | }; |
| 2259 | 2281 | } |
| ... | ... | @@ -2290,7 +2312,7 @@ pub const WriteFileStep = struct { |
| 2290 | 2312 | pub fn init(builder: *Builder, file_path: []const u8, data: []const u8) WriteFileStep { |
| 2291 | 2313 | return WriteFileStep{ |
| 2292 | 2314 | .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), | |
| 2294 | 2316 | .file_path = file_path, |
| 2295 | 2317 | .data = data, |
| 2296 | 2318 | }; |
| ... | ... | @@ -2301,11 +2323,11 @@ pub const WriteFileStep = struct { |
| 2301 | 2323 | const full_path = self.builder.pathFromRoot(self.file_path); |
| 2302 | 2324 | const full_path_dir = fs.path.dirname(full_path) orelse "."; |
| 2303 | 2325 | 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) }); | |
| 2305 | 2327 | return err; |
| 2306 | 2328 | }; |
| 2307 | 2329 | 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) }); | |
| 2309 | 2331 | return err; |
| 2310 | 2332 | }; |
| 2311 | 2333 | } |
| ... | ... | @@ -2319,14 +2341,14 @@ pub const LogStep = struct { |
| 2319 | 2341 | pub fn init(builder: *Builder, data: []const u8) LogStep { |
| 2320 | 2342 | return LogStep{ |
| 2321 | 2343 | .builder = builder, |
| 2322 | .step = Step.init(builder.fmt("log {}", data), builder.allocator, make), | |
| 2344 | .step = Step.init(builder.fmt("log {}", .{data}), builder.allocator, make), | |
| 2323 | 2345 | .data = data, |
| 2324 | 2346 | }; |
| 2325 | 2347 | } |
| 2326 | 2348 | |
| 2327 | 2349 | fn make(step: *Step) anyerror!void { |
| 2328 | 2350 | const self = @fieldParentPtr(LogStep, "step", step); |
| 2329 | warn("{}", self.data); | |
| 2351 | warn("{}", .{self.data}); | |
| 2330 | 2352 | } |
| 2331 | 2353 | }; |
| 2332 | 2354 | |
| ... | ... | @@ -2338,7 +2360,7 @@ pub const RemoveDirStep = struct { |
| 2338 | 2360 | pub fn init(builder: *Builder, dir_path: []const u8) RemoveDirStep { |
| 2339 | 2361 | return RemoveDirStep{ |
| 2340 | 2362 | .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), | |
| 2342 | 2364 | .dir_path = dir_path, |
| 2343 | 2365 | }; |
| 2344 | 2366 | } |
| ... | ... | @@ -2348,7 +2370,7 @@ pub const RemoveDirStep = struct { |
| 2348 | 2370 | |
| 2349 | 2371 | const full_path = self.builder.pathFromRoot(self.dir_path); |
| 2350 | 2372 | 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) }); | |
| 2352 | 2374 | return err; |
| 2353 | 2375 | }; |
| 2354 | 2376 | } |
| ... | ... | @@ -2397,7 +2419,7 @@ fn doAtomicSymLinks(allocator: *Allocator, output_path: []const u8, filename_maj |
| 2397 | 2419 | &[_][]const u8{ out_dir, filename_major_only }, |
| 2398 | 2420 | ) catch unreachable; |
| 2399 | 2421 | 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 }); | |
| 2401 | 2423 | return err; |
| 2402 | 2424 | }; |
| 2403 | 2425 | // sym link for libfoo.so to libfoo.so.1 |
| ... | ... | @@ -2406,7 +2428,7 @@ fn doAtomicSymLinks(allocator: *Allocator, output_path: []const u8, filename_maj |
| 2406 | 2428 | &[_][]const u8{ out_dir, filename_name_only }, |
| 2407 | 2429 | ) catch unreachable; |
| 2408 | 2430 | 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 }); | |
| 2410 | 2432 | return err; |
| 2411 | 2433 | }; |
| 2412 | 2434 | } |
lib/std/builtin.zig+2-2| ... | ... | @@ -429,7 +429,7 @@ pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace) noreturn |
| 429 | 429 | } |
| 430 | 430 | }, |
| 431 | 431 | .wasi => { |
| 432 | std.debug.warn("{}", msg); | |
| 432 | std.debug.warn("{}", .{msg}); | |
| 433 | 433 | _ = std.os.wasi.proc_raise(std.os.wasi.SIGABRT); |
| 434 | 434 | unreachable; |
| 435 | 435 | }, |
| ... | ... | @@ -439,7 +439,7 @@ pub fn default_panic(msg: []const u8, error_return_trace: ?*StackTrace) noreturn |
| 439 | 439 | }, |
| 440 | 440 | else => { |
| 441 | 441 | 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}); | |
| 443 | 443 | }, |
| 444 | 444 | } |
| 445 | 445 | } |
lib/std/crypto/benchmark.zig+1-1| ... | ... | @@ -114,7 +114,7 @@ fn usage() void { |
| 114 | 114 | \\ --seed [int] |
| 115 | 115 | \\ --help |
| 116 | 116 | \\ |
| 117 | ); | |
| 117 | , .{}); | |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | fn 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; |
| 46 | 46 | var stderr_stream: ?*io.OutStream(File.WriteError) = null; |
| 47 | 47 | var stderr_mutex = std.Mutex.init(); |
| 48 | 48 | |
| 49 | pub fn warn(comptime fmt: []const u8, args: ...) void { | |
| 49 | pub fn warn(comptime fmt: []const u8, args: var) void { | |
| 50 | 50 | const held = stderr_mutex.acquire(); |
| 51 | 51 | defer held.release(); |
| 52 | 52 | const stderr = getStderrStream(); |
| ... | ... | @@ -92,15 +92,15 @@ fn wantTtyColor() bool { |
| 92 | 92 | pub fn dumpCurrentStackTrace(start_addr: ?usize) void { |
| 93 | 93 | const stderr = getStderrStream(); |
| 94 | 94 | 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; | |
| 96 | 96 | return; |
| 97 | 97 | } |
| 98 | 98 | 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; | |
| 100 | 100 | return; |
| 101 | 101 | }; |
| 102 | 102 | 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; | |
| 104 | 104 | return; |
| 105 | 105 | }; |
| 106 | 106 | } |
| ... | ... | @@ -111,11 +111,11 @@ pub fn dumpCurrentStackTrace(start_addr: ?usize) void { |
| 111 | 111 | pub fn dumpStackTraceFromBase(bp: usize, ip: usize) void { |
| 112 | 112 | const stderr = getStderrStream(); |
| 113 | 113 | 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; | |
| 115 | 115 | return; |
| 116 | 116 | } |
| 117 | 117 | 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; | |
| 119 | 119 | return; |
| 120 | 120 | }; |
| 121 | 121 | const tty_color = wantTtyColor(); |
| ... | ... | @@ -184,15 +184,15 @@ pub fn captureStackTrace(first_address: ?usize, stack_trace: *builtin.StackTrace |
| 184 | 184 | pub fn dumpStackTrace(stack_trace: builtin.StackTrace) void { |
| 185 | 185 | const stderr = getStderrStream(); |
| 186 | 186 | 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; | |
| 188 | 188 | return; |
| 189 | 189 | } |
| 190 | 190 | 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; | |
| 192 | 192 | return; |
| 193 | 193 | }; |
| 194 | 194 | 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; | |
| 196 | 196 | return; |
| 197 | 197 | }; |
| 198 | 198 | } |
| ... | ... | @@ -211,7 +211,7 @@ pub fn assert(ok: bool) void { |
| 211 | 211 | if (!ok) unreachable; // assertion failure |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | pub fn panic(comptime format: []const u8, args: ...) noreturn { | |
| 214 | pub fn panic(comptime format: []const u8, args: var) noreturn { | |
| 215 | 215 | @setCold(true); |
| 216 | 216 | // TODO: remove conditional once wasi / LLVM defines __builtin_return_address |
| 217 | 217 | const first_trace_addr = if (builtin.os == .wasi) null else @returnAddress(); |
| ... | ... | @@ -221,7 +221,7 @@ pub fn panic(comptime format: []const u8, args: ...) noreturn { |
| 221 | 221 | /// TODO multithreaded awareness |
| 222 | 222 | var panicking: u8 = 0; // TODO make this a bool |
| 223 | 223 | |
| 224 | pub fn panicExtra(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, comptime format: []const u8, args: ...) noreturn { | |
| 224 | pub fn panicExtra(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, comptime format: []const u8, args: var) noreturn { | |
| 225 | 225 | @setCold(true); |
| 226 | 226 | |
| 227 | 227 | if (enable_segfault_handler) { |
| ... | ... | @@ -376,13 +376,13 @@ fn printSourceAtAddressWindows(di: *DebugInfo, out_stream: var, relocated_addres |
| 376 | 376 | } else { |
| 377 | 377 | // we have no information to add to the address |
| 378 | 378 | if (tty_color) { |
| 379 | try out_stream.print("???:?:?: "); | |
| 379 | try out_stream.print("???:?:?: ", .{}); | |
| 380 | 380 | setTtyColor(TtyColor.Dim); |
| 381 | try out_stream.print("0x{x} in ??? (???)", relocated_address); | |
| 381 | try out_stream.print("0x{x} in ??? (???)", .{relocated_address}); | |
| 382 | 382 | setTtyColor(TtyColor.Reset); |
| 383 | try out_stream.print("\n\n\n"); | |
| 383 | try out_stream.print("\n\n\n", .{}); | |
| 384 | 384 | } 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}); | |
| 386 | 386 | } |
| 387 | 387 | return; |
| 388 | 388 | }; |
| ... | ... | @@ -509,18 +509,18 @@ fn printSourceAtAddressWindows(di: *DebugInfo, out_stream: var, relocated_addres |
| 509 | 509 | if (tty_color) { |
| 510 | 510 | setTtyColor(TtyColor.White); |
| 511 | 511 | 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 }); | |
| 513 | 513 | } else { |
| 514 | try out_stream.print("???:?:?"); | |
| 514 | try out_stream.print("???:?:?", .{}); | |
| 515 | 515 | } |
| 516 | 516 | setTtyColor(TtyColor.Reset); |
| 517 | try out_stream.print(": "); | |
| 517 | try out_stream.print(": ", .{}); | |
| 518 | 518 | 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 }); | |
| 520 | 520 | setTtyColor(TtyColor.Reset); |
| 521 | 521 | |
| 522 | 522 | if (opt_line_info) |line_info| { |
| 523 | try out_stream.print("\n"); | |
| 523 | try out_stream.print("\n", .{}); | |
| 524 | 524 | if (printLineFromFileAnyOs(out_stream, line_info)) { |
| 525 | 525 | if (line_info.column == 0) { |
| 526 | 526 | try out_stream.write("\n"); |
| ... | ... | @@ -546,13 +546,24 @@ fn printSourceAtAddressWindows(di: *DebugInfo, out_stream: var, relocated_addres |
| 546 | 546 | else => return err, |
| 547 | 547 | } |
| 548 | 548 | } else { |
| 549 | try out_stream.print("\n\n\n"); | |
| 549 | try out_stream.print("\n\n\n", .{}); | |
| 550 | 550 | } |
| 551 | 551 | } else { |
| 552 | 552 | 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 | }); | |
| 554 | 561 | } 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 | }); | |
| 556 | 567 | } |
| 557 | 568 | } |
| 558 | 569 | } |
| ... | ... | @@ -697,9 +708,9 @@ fn printSourceAtAddressMacOs(di: *DebugInfo, out_stream: var, address: usize, tt |
| 697 | 708 | |
| 698 | 709 | const symbol = machoSearchSymbols(di.symbols, adjusted_addr) orelse { |
| 699 | 710 | 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}); | |
| 701 | 712 | } 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}); | |
| 703 | 714 | } |
| 704 | 715 | return; |
| 705 | 716 | }; |
| ... | ... | @@ -723,9 +734,11 @@ fn printSourceAtAddressMacOs(di: *DebugInfo, out_stream: var, address: usize, tt |
| 723 | 734 | } else |err| switch (err) { |
| 724 | 735 | error.MissingDebugInfo, error.InvalidDebugInfo => { |
| 725 | 736 | 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 | }); | |
| 727 | 740 | } 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 }); | |
| 729 | 742 | } |
| 730 | 743 | }, |
| 731 | 744 | else => return err, |
| ... | ... | @@ -746,15 +759,14 @@ fn printLineInfo( |
| 746 | 759 | comptime printLineFromFile: var, |
| 747 | 760 | ) !void { |
| 748 | 761 | 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", .{ | |
| 751 | 763 | line_info.file_name, |
| 752 | 764 | line_info.line, |
| 753 | 765 | line_info.column, |
| 754 | 766 | address, |
| 755 | 767 | symbol_name, |
| 756 | 768 | compile_unit_name, |
| 757 | ); | |
| 769 | }); | |
| 758 | 770 | if (printLineFromFile(out_stream, line_info)) { |
| 759 | 771 | if (line_info.column == 0) { |
| 760 | 772 | try out_stream.write("\n"); |
| ... | ... | @@ -772,15 +784,14 @@ fn printLineInfo( |
| 772 | 784 | else => return err, |
| 773 | 785 | } |
| 774 | 786 | } else { |
| 775 | try out_stream.print( | |
| 776 | "{}:{}:{}: 0x{x} in {} ({})\n", | |
| 787 | try out_stream.print("{}:{}:{}: 0x{x} in {} ({})\n", .{ | |
| 777 | 788 | line_info.file_name, |
| 778 | 789 | line_info.line, |
| 779 | 790 | line_info.column, |
| 780 | 791 | address, |
| 781 | 792 | symbol_name, |
| 782 | 793 | compile_unit_name, |
| 783 | ); | |
| 794 | }); | |
| 784 | 795 | } |
| 785 | 796 | } |
| 786 | 797 | |
| ... | ... | @@ -1226,9 +1237,9 @@ pub const DwarfInfo = struct { |
| 1226 | 1237 | ) !void { |
| 1227 | 1238 | const compile_unit = self.findCompileUnit(address) catch { |
| 1228 | 1239 | 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}); | |
| 1230 | 1241 | } 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}); | |
| 1232 | 1243 | } |
| 1233 | 1244 | return; |
| 1234 | 1245 | }; |
| ... | ... | @@ -1248,9 +1259,11 @@ pub const DwarfInfo = struct { |
| 1248 | 1259 | } else |err| switch (err) { |
| 1249 | 1260 | error.MissingDebugInfo, error.InvalidDebugInfo => { |
| 1250 | 1261 | 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 | }); | |
| 1252 | 1265 | } 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 }); | |
| 1254 | 1267 | } |
| 1255 | 1268 | }, |
| 1256 | 1269 | else => return err, |
| ... | ... | @@ -2416,7 +2429,7 @@ extern fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: *con |
| 2416 | 2429 | resetSegfaultHandler(); |
| 2417 | 2430 | |
| 2418 | 2431 | 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}); | |
| 2420 | 2433 | |
| 2421 | 2434 | switch (builtin.arch) { |
| 2422 | 2435 | .i386 => { |
| ... | ... | @@ -2456,10 +2469,10 @@ extern fn handleSegfaultLinux(sig: i32, info: *const os.siginfo_t, ctx_ptr: *con |
| 2456 | 2469 | stdcallcc fn handleSegfaultWindows(info: *windows.EXCEPTION_POINTERS) c_long { |
| 2457 | 2470 | const exception_address = @ptrToInt(info.ExceptionRecord.ExceptionAddress); |
| 2458 | 2471 | 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", .{}), | |
| 2463 | 2476 | else => return windows.EXCEPTION_CONTINUE_SEARCH, |
| 2464 | 2477 | } |
| 2465 | 2478 | } |
| ... | ... | @@ -2468,7 +2481,7 @@ pub fn dumpStackPointerAddr(prefix: []const u8) void { |
| 2468 | 2481 | const sp = asm ("" |
| 2469 | 2482 | : [argc] "={rsp}" (-> usize) |
| 2470 | 2483 | ); |
| 2471 | std.debug.warn("{} sp = 0x{x}\n", prefix, sp); | |
| 2484 | std.debug.warn("{} sp = 0x{x}\n", .{ prefix, sp }); | |
| 2472 | 2485 | } |
| 2473 | 2486 | |
| 2474 | 2487 | // Reference everything so it gets tested. |
lib/std/event/channel.zig+2-2| ... | ... | @@ -294,14 +294,14 @@ test "std.event.Channel wraparound" { |
| 294 | 294 | |
| 295 | 295 | const channel_size = 2; |
| 296 | 296 | |
| 297 | var buf : [channel_size]i32 = undefined; | |
| 297 | var buf: [channel_size]i32 = undefined; | |
| 298 | 298 | var channel: Channel(i32) = undefined; |
| 299 | 299 | channel.init(&buf); |
| 300 | 300 | defer channel.deinit(); |
| 301 | 301 | |
| 302 | 302 | // add items to channel and pull them out until |
| 303 | 303 | // the buffer wraps around, make sure it doesn't crash. |
| 304 | var result : i32 = undefined; | |
| 304 | var result: i32 = undefined; | |
| 305 | 305 | channel.put(5); |
| 306 | 306 | testing.expectEqual(@as(i32, 5), channel.get()); |
| 307 | 307 | channel.put(6); |
lib/std/fifo.zig+2-2| ... | ... | @@ -293,7 +293,7 @@ pub fn LinearFifo( |
| 293 | 293 | |
| 294 | 294 | pub usingnamespace if (T == u8) |
| 295 | 295 | 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 { | |
| 297 | 297 | return std.fmt.format(self, error{OutOfMemory}, Self.write, format, args); |
| 298 | 298 | } |
| 299 | 299 | } |
| ... | ... | @@ -407,7 +407,7 @@ test "LinearFifo(u8, .Dynamic)" { |
| 407 | 407 | fifo.shrink(0); |
| 408 | 408 | |
| 409 | 409 | { |
| 410 | try fifo.print("{}, {}!", "Hello", "World"); | |
| 410 | try fifo.print("{}, {}!", .{ "Hello", "World" }); | |
| 411 | 411 | var result: [30]u8 = undefined; |
| 412 | 412 | testing.expectEqualSlices(u8, "Hello, World!", result[0..fifo.read(&result)]); |
| 413 | 413 | testing.expectEqual(@as(usize, 0), fifo.readableLength()); |
lib/std/fmt.zig+111-109| ... | ... | @@ -91,10 +91,12 @@ pub fn format( |
| 91 | 91 | comptime Errors: type, |
| 92 | 92 | output: fn (@typeOf(context), []const u8) Errors!void, |
| 93 | 93 | comptime fmt: []const u8, |
| 94 | args: ..., | |
| 94 | args: var, | |
| 95 | 95 | ) Errors!void { |
| 96 | 96 | 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) { | |
| 98 | 100 | @compileError("32 arguments max are supported per format call"); |
| 99 | 101 | } |
| 100 | 102 | |
| ... | ... | @@ -158,14 +160,14 @@ pub fn format( |
| 158 | 160 | maybe_pos_arg.? += c - '0'; |
| 159 | 161 | specifier_start = i + 1; |
| 160 | 162 | |
| 161 | if (maybe_pos_arg.? >= args.len) { | |
| 163 | if (maybe_pos_arg.? >= args_len) { | |
| 162 | 164 | @compileError("Positional value refers to non-existent argument"); |
| 163 | 165 | } |
| 164 | 166 | }, |
| 165 | 167 | '}' => { |
| 166 | 168 | const arg_to_print = comptime nextArg(&used_pos_args, maybe_pos_arg, &next_arg); |
| 167 | 169 | |
| 168 | if (arg_to_print >= args.len) { | |
| 170 | if (arg_to_print >= args_len) { | |
| 169 | 171 | @compileError("Too few arguments"); |
| 170 | 172 | } |
| 171 | 173 | |
| ... | ... | @@ -302,7 +304,7 @@ pub fn format( |
| 302 | 304 | used_pos_args |= 1 << i; |
| 303 | 305 | } |
| 304 | 306 | |
| 305 | if (@popCount(ArgSetType, used_pos_args) != args.len) { | |
| 307 | if (@popCount(ArgSetType, used_pos_args) != args_len) { | |
| 306 | 308 | @compileError("Unused arguments"); |
| 307 | 309 | } |
| 308 | 310 | if (state != State.Start) { |
| ... | ... | @@ -389,7 +391,7 @@ pub fn formatType( |
| 389 | 391 | } |
| 390 | 392 | try output(context, " }"); |
| 391 | 393 | } else { |
| 392 | try format(context, Errors, output, "@{x}", @ptrToInt(&value)); | |
| 394 | try format(context, Errors, output, "@{x}", .{@ptrToInt(&value)}); | |
| 393 | 395 | } |
| 394 | 396 | }, |
| 395 | 397 | .Struct => { |
| ... | ... | @@ -421,12 +423,12 @@ pub fn formatType( |
| 421 | 423 | if (info.child == u8) { |
| 422 | 424 | return formatText(value, fmt, options, context, Errors, output); |
| 423 | 425 | } |
| 424 | return format(context, Errors, output, "{}@{x}", @typeName(T.Child), @ptrToInt(value)); | |
| 426 | return format(context, Errors, output, "{}@{x}", .{ @typeName(T.Child), @ptrToInt(value) }); | |
| 425 | 427 | }, |
| 426 | 428 | builtin.TypeId.Enum, builtin.TypeId.Union, builtin.TypeId.Struct => { |
| 427 | 429 | return formatType(value.*, fmt, options, context, Errors, output, max_depth); |
| 428 | 430 | }, |
| 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) }), | |
| 430 | 432 | }, |
| 431 | 433 | .Many => { |
| 432 | 434 | if (ptr_info.child == u8) { |
| ... | ... | @@ -435,7 +437,7 @@ pub fn formatType( |
| 435 | 437 | return formatText(value[0..len], fmt, options, context, Errors, output); |
| 436 | 438 | } |
| 437 | 439 | } |
| 438 | return format(context, Errors, output, "{}@{x}", @typeName(T.Child), @ptrToInt(value)); | |
| 440 | return format(context, Errors, output, "{}@{x}", .{ @typeName(T.Child), @ptrToInt(value) }); | |
| 439 | 441 | }, |
| 440 | 442 | .Slice => { |
| 441 | 443 | if (fmt.len > 0 and ((fmt[0] == 'x') or (fmt[0] == 'X'))) { |
| ... | ... | @@ -444,10 +446,10 @@ pub fn formatType( |
| 444 | 446 | if (ptr_info.child == u8) { |
| 445 | 447 | return formatText(value, fmt, options, context, Errors, output); |
| 446 | 448 | } |
| 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) }); | |
| 448 | 450 | }, |
| 449 | 451 | .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) }); | |
| 451 | 453 | }, |
| 452 | 454 | }, |
| 453 | 455 | .Array => |info| { |
| ... | ... | @@ -465,7 +467,7 @@ pub fn formatType( |
| 465 | 467 | return formatType(@as(Slice, &value), fmt, options, context, Errors, output, max_depth); |
| 466 | 468 | }, |
| 467 | 469 | .Fn => { |
| 468 | return format(context, Errors, output, "{}@{x}", @typeName(T), @ptrToInt(value)); | |
| 470 | return format(context, Errors, output, "{}@{x}", .{ @typeName(T), @ptrToInt(value) }); | |
| 469 | 471 | }, |
| 470 | 472 | else => @compileError("Unable to format type '" ++ @typeName(T) ++ "'"), |
| 471 | 473 | } |
| ... | ... | @@ -1113,7 +1115,7 @@ pub const BufPrintError = error{ |
| 1113 | 1115 | /// As much as possible was written to the buffer, but it was too small to fit all the printed bytes. |
| 1114 | 1116 | BufferTooSmall, |
| 1115 | 1117 | }; |
| 1116 | pub fn bufPrint(buf: []u8, comptime fmt: []const u8, args: ...) BufPrintError![]u8 { | |
| 1118 | pub fn bufPrint(buf: []u8, comptime fmt: []const u8, args: var) BufPrintError![]u8 { | |
| 1117 | 1119 | var context = BufPrintContext{ .remaining = buf }; |
| 1118 | 1120 | try format(&context, BufPrintError, bufPrintWrite, fmt, args); |
| 1119 | 1121 | return buf[0 .. buf.len - context.remaining.len]; |
| ... | ... | @@ -1121,7 +1123,7 @@ pub fn bufPrint(buf: []u8, comptime fmt: []const u8, args: ...) BufPrintError![] |
| 1121 | 1123 | |
| 1122 | 1124 | pub const AllocPrintError = error{OutOfMemory}; |
| 1123 | 1125 | |
| 1124 | pub fn allocPrint(allocator: *mem.Allocator, comptime fmt: []const u8, args: ...) AllocPrintError![]u8 { | |
| 1126 | pub fn allocPrint(allocator: *mem.Allocator, comptime fmt: []const u8, args: var) AllocPrintError![]u8 { | |
| 1125 | 1127 | var size: usize = 0; |
| 1126 | 1128 | format(&size, error{}, countSize, fmt, args) catch |err| switch (err) {}; |
| 1127 | 1129 | const buf = try allocator.alloc(u8, size); |
| ... | ... | @@ -1173,46 +1175,46 @@ test "parse unsigned comptime" { |
| 1173 | 1175 | test "optional" { |
| 1174 | 1176 | { |
| 1175 | 1177 | const value: ?i32 = 1234; |
| 1176 | try testFmt("optional: 1234\n", "optional: {}\n", value); | |
| 1178 | try testFmt("optional: 1234\n", "optional: {}\n", .{value}); | |
| 1177 | 1179 | } |
| 1178 | 1180 | { |
| 1179 | 1181 | const value: ?i32 = null; |
| 1180 | try testFmt("optional: null\n", "optional: {}\n", value); | |
| 1182 | try testFmt("optional: null\n", "optional: {}\n", .{value}); | |
| 1181 | 1183 | } |
| 1182 | 1184 | } |
| 1183 | 1185 | |
| 1184 | 1186 | test "error" { |
| 1185 | 1187 | { |
| 1186 | 1188 | 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}); | |
| 1188 | 1190 | } |
| 1189 | 1191 | { |
| 1190 | 1192 | 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}); | |
| 1192 | 1194 | } |
| 1193 | 1195 | } |
| 1194 | 1196 | |
| 1195 | 1197 | test "int.small" { |
| 1196 | 1198 | { |
| 1197 | 1199 | const value: u3 = 0b101; |
| 1198 | try testFmt("u3: 5\n", "u3: {}\n", value); | |
| 1200 | try testFmt("u3: 5\n", "u3: {}\n", .{value}); | |
| 1199 | 1201 | } |
| 1200 | 1202 | } |
| 1201 | 1203 | |
| 1202 | 1204 | test "int.specifier" { |
| 1203 | 1205 | { |
| 1204 | 1206 | const value: u8 = 'a'; |
| 1205 | try testFmt("u8: a\n", "u8: {c}\n", value); | |
| 1207 | try testFmt("u8: a\n", "u8: {c}\n", .{value}); | |
| 1206 | 1208 | } |
| 1207 | 1209 | { |
| 1208 | 1210 | 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}); | |
| 1210 | 1212 | } |
| 1211 | 1213 | } |
| 1212 | 1214 | |
| 1213 | 1215 | test "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)}); | |
| 1216 | 1218 | } |
| 1217 | 1219 | |
| 1218 | 1220 | test "buffer" { |
| ... | ... | @@ -1238,14 +1240,14 @@ test "buffer" { |
| 1238 | 1240 | test "array" { |
| 1239 | 1241 | { |
| 1240 | 1242 | 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}); | |
| 1243 | 1245 | |
| 1244 | 1246 | var buf: [100]u8 = undefined; |
| 1245 | 1247 | 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)}), | |
| 1247 | 1249 | "array: {*}\n", |
| 1248 | &value, | |
| 1250 | .{&value}, | |
| 1249 | 1251 | ); |
| 1250 | 1252 | } |
| 1251 | 1253 | } |
| ... | ... | @@ -1253,36 +1255,36 @@ test "array" { |
| 1253 | 1255 | test "slice" { |
| 1254 | 1256 | { |
| 1255 | 1257 | const value: []const u8 = "abc"; |
| 1256 | try testFmt("slice: abc\n", "slice: {}\n", value); | |
| 1258 | try testFmt("slice: abc\n", "slice: {}\n", .{value}); | |
| 1257 | 1259 | } |
| 1258 | 1260 | { |
| 1259 | 1261 | 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}); | |
| 1261 | 1263 | } |
| 1262 | 1264 | |
| 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"}); | |
| 1265 | 1267 | } |
| 1266 | 1268 | |
| 1267 | 1269 | test "pointer" { |
| 1268 | 1270 | { |
| 1269 | 1271 | 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}); | |
| 1272 | 1274 | } |
| 1273 | 1275 | { |
| 1274 | 1276 | 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}); | |
| 1276 | 1278 | } |
| 1277 | 1279 | { |
| 1278 | 1280 | 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}); | |
| 1280 | 1282 | } |
| 1281 | 1283 | } |
| 1282 | 1284 | |
| 1283 | 1285 | test "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"}); | |
| 1286 | 1288 | } |
| 1287 | 1289 | |
| 1288 | 1290 | test "filesize" { |
| ... | ... | @@ -1290,8 +1292,8 @@ test "filesize" { |
| 1290 | 1292 | // TODO https://github.com/ziglang/zig/issues/3289 |
| 1291 | 1293 | return error.SkipZigTest; |
| 1292 | 1294 | } |
| 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)}); | |
| 1295 | 1297 | } |
| 1296 | 1298 | |
| 1297 | 1299 | test "struct" { |
| ... | ... | @@ -1300,8 +1302,8 @@ test "struct" { |
| 1300 | 1302 | field: u8, |
| 1301 | 1303 | }; |
| 1302 | 1304 | 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}); | |
| 1305 | 1307 | } |
| 1306 | 1308 | { |
| 1307 | 1309 | const Struct = struct { |
| ... | ... | @@ -1309,7 +1311,7 @@ test "struct" { |
| 1309 | 1311 | b: u1, |
| 1310 | 1312 | }; |
| 1311 | 1313 | 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}); | |
| 1313 | 1315 | } |
| 1314 | 1316 | } |
| 1315 | 1317 | |
| ... | ... | @@ -1319,8 +1321,8 @@ test "enum" { |
| 1319 | 1321 | Two, |
| 1320 | 1322 | }; |
| 1321 | 1323 | 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}); | |
| 1324 | 1326 | } |
| 1325 | 1327 | |
| 1326 | 1328 | test "float.scientific" { |
| ... | ... | @@ -1328,10 +1330,10 @@ test "float.scientific" { |
| 1328 | 1330 | // TODO https://github.com/ziglang/zig/issues/3289 |
| 1329 | 1331 | return error.SkipZigTest; |
| 1330 | 1332 | } |
| 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)}); | |
| 1335 | 1337 | } |
| 1336 | 1338 | |
| 1337 | 1339 | test "float.scientific.precision" { |
| ... | ... | @@ -1339,12 +1341,12 @@ test "float.scientific.precision" { |
| 1339 | 1341 | // TODO https://github.com/ziglang/zig/issues/3289 |
| 1340 | 1342 | return error.SkipZigTest; |
| 1341 | 1343 | } |
| 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)))}); | |
| 1345 | 1347 | // libc rounds 1.000005e+05 to 1.00000e+05 but zig does 1.00001e+05. |
| 1346 | 1348 | // 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)))}); | |
| 1348 | 1350 | } |
| 1349 | 1351 | |
| 1350 | 1352 | test "float.special" { |
| ... | ... | @@ -1352,14 +1354,14 @@ test "float.special" { |
| 1352 | 1354 | // TODO https://github.com/ziglang/zig/issues/3289 |
| 1353 | 1355 | return error.SkipZigTest; |
| 1354 | 1356 | } |
| 1355 | try testFmt("f64: nan", "f64: {}", math.nan_f64); | |
| 1357 | try testFmt("f64: nan", "f64: {}", .{math.nan_f64}); | |
| 1356 | 1358 | // negative nan is not defined by IEE 754, |
| 1357 | 1359 | // and ARM thus normalizes it to positive nan |
| 1358 | 1360 | if (builtin.arch != builtin.Arch.arm) { |
| 1359 | try testFmt("f64: -nan", "f64: {}", -math.nan_f64); | |
| 1361 | try testFmt("f64: -nan", "f64: {}", .{-math.nan_f64}); | |
| 1360 | 1362 | } |
| 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}); | |
| 1363 | 1365 | } |
| 1364 | 1366 | |
| 1365 | 1367 | test "float.decimal" { |
| ... | ... | @@ -1367,21 +1369,21 @@ test "float.decimal" { |
| 1367 | 1369 | // TODO https://github.com/ziglang/zig/issues/3289 |
| 1368 | 1370 | return error.SkipZigTest; |
| 1369 | 1371 | } |
| 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)}); | |
| 1373 | 1375 | // -11.1234 is converted to f64 -11.12339... internally (errol3() function takes f64). |
| 1374 | 1376 | // -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)}); | |
| 1385 | 1387 | } |
| 1386 | 1388 | |
| 1387 | 1389 | test "float.libc.sanity" { |
| ... | ... | @@ -1389,22 +1391,22 @@ test "float.libc.sanity" { |
| 1389 | 1391 | // TODO https://github.com/ziglang/zig/issues/3289 |
| 1390 | 1392 | return error.SkipZigTest; |
| 1391 | 1393 | } |
| 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)))}); | |
| 1397 | 1399 | |
| 1398 | 1400 | // libc differences |
| 1399 | 1401 | // |
| 1400 | 1402 | // This is 0.015625 exactly according to gdb. We thus round down, |
| 1401 | 1403 | // however glibc rounds up for some reason. This occurs for all |
| 1402 | 1404 | // 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)))}); | |
| 1404 | 1406 | // errol3 rounds to ... 630 but libc rounds to ...632. Grisu3 |
| 1405 | 1407 | // also rounds to 630 so I'm inclined to believe libc is not |
| 1406 | 1408 | // 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)))}); | |
| 1408 | 1410 | } |
| 1409 | 1411 | |
| 1410 | 1412 | test "custom" { |
| ... | ... | @@ -1422,9 +1424,9 @@ test "custom" { |
| 1422 | 1424 | output: fn (@typeOf(context), []const u8) Errors!void, |
| 1423 | 1425 | ) Errors!void { |
| 1424 | 1426 | 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 }); | |
| 1426 | 1428 | } 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 }); | |
| 1428 | 1430 | } else { |
| 1429 | 1431 | @compileError("Unknown format character: '" ++ fmt ++ "'"); |
| 1430 | 1432 | } |
| ... | ... | @@ -1436,12 +1438,12 @@ test "custom" { |
| 1436 | 1438 | .x = 10.2, |
| 1437 | 1439 | .y = 2.22, |
| 1438 | 1440 | }; |
| 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}); | |
| 1441 | 1443 | |
| 1442 | 1444 | // 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}); | |
| 1445 | 1447 | } |
| 1446 | 1448 | |
| 1447 | 1449 | test "struct" { |
| ... | ... | @@ -1455,7 +1457,7 @@ test "struct" { |
| 1455 | 1457 | .b = error.Unused, |
| 1456 | 1458 | }; |
| 1457 | 1459 | |
| 1458 | try testFmt("S{ .a = 456, .b = error.Unused }", "{}", inst); | |
| 1460 | try testFmt("S{ .a = 456, .b = error.Unused }", "{}", .{inst}); | |
| 1459 | 1461 | } |
| 1460 | 1462 | |
| 1461 | 1463 | test "union" { |
| ... | ... | @@ -1478,13 +1480,13 @@ test "union" { |
| 1478 | 1480 | const uu_inst = UU{ .int = 456 }; |
| 1479 | 1481 | const eu_inst = EU{ .float = 321.123 }; |
| 1480 | 1482 | |
| 1481 | try testFmt("TU{ .int = 123 }", "{}", tu_inst); | |
| 1483 | try testFmt("TU{ .int = 123 }", "{}", .{tu_inst}); | |
| 1482 | 1484 | |
| 1483 | 1485 | 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}); | |
| 1485 | 1487 | std.testing.expect(mem.eql(u8, uu_result[0..3], "UU@")); |
| 1486 | 1488 | |
| 1487 | const eu_result = try bufPrint(buf[0..], "{}", eu_inst); | |
| 1489 | const eu_result = try bufPrint(buf[0..], "{}", .{eu_inst}); | |
| 1488 | 1490 | std.testing.expect(mem.eql(u8, uu_result[0..3], "EU@")); |
| 1489 | 1491 | } |
| 1490 | 1492 | |
| ... | ... | @@ -1497,7 +1499,7 @@ test "enum" { |
| 1497 | 1499 | |
| 1498 | 1500 | const inst = E.Two; |
| 1499 | 1501 | |
| 1500 | try testFmt("E.Two", "{}", inst); | |
| 1502 | try testFmt("E.Two", "{}", .{inst}); | |
| 1501 | 1503 | } |
| 1502 | 1504 | |
| 1503 | 1505 | test "struct.self-referential" { |
| ... | ... | @@ -1511,7 +1513,7 @@ test "struct.self-referential" { |
| 1511 | 1513 | }; |
| 1512 | 1514 | inst.a = &inst; |
| 1513 | 1515 | |
| 1514 | try testFmt("S{ .a = S{ .a = S{ .a = S{ ... } } } }", "{}", inst); | |
| 1516 | try testFmt("S{ .a = S{ .a = S{ .a = S{ ... } } } }", "{}", .{inst}); | |
| 1515 | 1517 | } |
| 1516 | 1518 | |
| 1517 | 1519 | test "struct.zero-size" { |
| ... | ... | @@ -1526,30 +1528,30 @@ test "struct.zero-size" { |
| 1526 | 1528 | const a = A{}; |
| 1527 | 1529 | const b = B{ .a = a, .c = 0 }; |
| 1528 | 1530 | |
| 1529 | try testFmt("B{ .a = A{ }, .c = 0 }", "{}", b); | |
| 1531 | try testFmt("B{ .a = A{ }, .c = 0 }", "{}", .{b}); | |
| 1530 | 1532 | } |
| 1531 | 1533 | |
| 1532 | 1534 | test "bytes.hex" { |
| 1533 | 1535 | 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}); | |
| 1536 | 1538 | //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..]}); | |
| 1539 | 1541 | 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}); | |
| 1541 | 1543 | } |
| 1542 | 1544 | |
| 1543 | fn testFmt(expected: []const u8, comptime template: []const u8, args: ...) !void { | |
| 1545 | fn testFmt(expected: []const u8, comptime template: []const u8, args: var) !void { | |
| 1544 | 1546 | var buf: [100]u8 = undefined; |
| 1545 | 1547 | const result = try bufPrint(buf[0..], template, args); |
| 1546 | 1548 | if (mem.eql(u8, result, expected)) return; |
| 1547 | 1549 | |
| 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", .{}); | |
| 1553 | 1555 | return error.TestFailed; |
| 1554 | 1556 | } |
| 1555 | 1557 | |
| ... | ... | @@ -1602,7 +1604,7 @@ test "hexToBytes" { |
| 1602 | 1604 | const test_hex_str = "909A312BB12ED1F819B3521AC4C1E896F2160507FFC1C8381E3B07BB16BD1706"; |
| 1603 | 1605 | var pb: [32]u8 = undefined; |
| 1604 | 1606 | try hexToBytes(pb[0..], test_hex_str); |
| 1605 | try testFmt(test_hex_str, "{X}", pb); | |
| 1607 | try testFmt(test_hex_str, "{X}", .{pb}); | |
| 1606 | 1608 | } |
| 1607 | 1609 | |
| 1608 | 1610 | test "formatIntValue with comptime_int" { |
| ... | ... | @@ -1628,7 +1630,7 @@ test "formatType max_depth" { |
| 1628 | 1630 | output: fn (@typeOf(context), []const u8) Errors!void, |
| 1629 | 1631 | ) Errors!void { |
| 1630 | 1632 | 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 }); | |
| 1632 | 1634 | } else { |
| 1633 | 1635 | @compileError("Unknown format string: '" ++ fmt ++ "'"); |
| 1634 | 1636 | } |
| ... | ... | @@ -1680,17 +1682,17 @@ test "formatType max_depth" { |
| 1680 | 1682 | } |
| 1681 | 1683 | |
| 1682 | 1684 | test "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) }); | |
| 1688 | 1690 | } |
| 1689 | 1691 | |
| 1690 | 1692 | test "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)}); | |
| 1692 | 1694 | } |
| 1693 | 1695 | |
| 1694 | 1696 | test "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)}); | |
| 1696 | 1698 | } |
lib/std/hash/benchmark.zig+1-1| ... | ... | @@ -164,7 +164,7 @@ fn usage() void { |
| 164 | 164 | \\ --iterative-only |
| 165 | 165 | \\ --help |
| 166 | 166 | \\ |
| 167 | ); | |
| 167 | , .{}); | |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | fn mode(comptime x: comptime_int) comptime_int { |
lib/std/http/headers.zig+1-1| ... | ... | @@ -610,5 +610,5 @@ test "Headers.format" { |
| 610 | 610 | \\foo: bar |
| 611 | 611 | \\cookie: somevalue |
| 612 | 612 | \\ |
| 613 | , try std.fmt.bufPrint(buf[0..], "{}", h)); | |
| 613 | , try std.fmt.bufPrint(buf[0..], "{}", .{h})); | |
| 614 | 614 | } |
lib/std/io.zig+1-1| ... | ... | @@ -492,7 +492,7 @@ test "io.SliceOutStream" { |
| 492 | 492 | var slice_stream = SliceOutStream.init(buf[0..]); |
| 493 | 493 | const stream = &slice_stream.stream; |
| 494 | 494 | |
| 495 | try stream.print("{}{}!", "Hello", "World"); | |
| 495 | try stream.print("{}{}!", .{ "Hello", "World" }); | |
| 496 | 496 | testing.expectEqualSlices(u8, "HelloWorld!", slice_stream.getWritten()); |
| 497 | 497 | } |
| 498 | 498 |
lib/std/io/out_stream.zig+1-1| ... | ... | @@ -35,7 +35,7 @@ pub fn OutStream(comptime WriteError: type) type { |
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | |
| 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 { | |
| 39 | 39 | return std.fmt.format(self, Error, self.writeFn, format, args); |
| 40 | 40 | } |
| 41 | 41 |
lib/std/io/test.zig+4-4| ... | ... | @@ -27,9 +27,9 @@ test "write a file, read it, then delete it" { |
| 27 | 27 | var file_out_stream = file.outStream(); |
| 28 | 28 | var buf_stream = io.BufferedOutStream(File.WriteError).init(&file_out_stream.stream); |
| 29 | 29 | const st = &buf_stream.stream; |
| 30 | try st.print("begin"); | |
| 30 | try st.print("begin", .{}); | |
| 31 | 31 | try st.write(data[0..]); |
| 32 | try st.print("end"); | |
| 32 | try st.print("end", .{}); | |
| 33 | 33 | try buf_stream.flush(); |
| 34 | 34 | } |
| 35 | 35 | |
| ... | ... | @@ -72,7 +72,7 @@ test "BufferOutStream" { |
| 72 | 72 | |
| 73 | 73 | const x: i32 = 42; |
| 74 | 74 | const y: i32 = 1234; |
| 75 | try buf_stream.print("x: {}\ny: {}\n", x, y); | |
| 75 | try buf_stream.print("x: {}\ny: {}\n", .{ x, y }); | |
| 76 | 76 | |
| 77 | 77 | expect(mem.eql(u8, buffer.toSlice(), "x: 42\ny: 1234\n")); |
| 78 | 78 | } |
| ... | ... | @@ -605,7 +605,7 @@ test "c out stream" { |
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | 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)}); | |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | test "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 { |
| 158 | 158 | switch (@typeInfo(@typeOf(value))) { |
| 159 | 159 | .Int => |info| { |
| 160 | 160 | if (info.bits < 53) { |
| 161 | try self.stream.print("{}", value); | |
| 161 | try self.stream.print("{}", .{value}); | |
| 162 | 162 | self.popState(); |
| 163 | 163 | return; |
| 164 | 164 | } |
| 165 | 165 | if (value < 4503599627370496 and (!info.is_signed or value > -4503599627370496)) { |
| 166 | try self.stream.print("{}", value); | |
| 166 | try self.stream.print("{}", .{value}); | |
| 167 | 167 | self.popState(); |
| 168 | 168 | return; |
| 169 | 169 | } |
| 170 | 170 | }, |
| 171 | 171 | .Float => if (@floatCast(f64, value) == value) { |
| 172 | try self.stream.print("{}", value); | |
| 172 | try self.stream.print("{}", .{value}); | |
| 173 | 173 | self.popState(); |
| 174 | 174 | return; |
| 175 | 175 | }, |
| 176 | 176 | else => {}, |
| 177 | 177 | } |
| 178 | try self.stream.print("\"{}\"", value); | |
| 178 | try self.stream.print("\"{}\"", .{value}); | |
| 179 | 179 | self.popState(); |
| 180 | 180 | } |
| 181 | 181 |
lib/std/math/big/int.zig+2-2| ... | ... | @@ -180,9 +180,9 @@ pub const Int = struct { |
| 180 | 180 | |
| 181 | 181 | pub fn dump(self: Int) void { |
| 182 | 182 | for (self.limbs) |limb| { |
| 183 | debug.warn("{x} ", limb); | |
| 183 | debug.warn("{x} ", .{limb}); | |
| 184 | 184 | } |
| 185 | debug.warn("\n"); | |
| 185 | debug.warn("\n", .{}); | |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /// Negate the sign of an Int. |
lib/std/net.zig+8-16| ... | ... | @@ -277,32 +277,24 @@ pub const Address = extern union { |
| 277 | 277 | os.AF_INET => { |
| 278 | 278 | const port = mem.bigToNative(u16, self.in.port); |
| 279 | 279 | 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, "{}.{}.{}.{}:{}", .{ | |
| 285 | 281 | bytes[0], |
| 286 | 282 | bytes[1], |
| 287 | 283 | bytes[2], |
| 288 | 284 | bytes[3], |
| 289 | 285 | port, |
| 290 | ); | |
| 286 | }); | |
| 291 | 287 | }, |
| 292 | 288 | os.AF_INET6 => { |
| 293 | 289 | const port = mem.bigToNative(u16, self.in6.port); |
| 294 | 290 | 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:{}.{}.{}.{}]:{}", .{ | |
| 300 | 292 | self.in6.addr[12], |
| 301 | 293 | self.in6.addr[13], |
| 302 | 294 | self.in6.addr[14], |
| 303 | 295 | self.in6.addr[15], |
| 304 | 296 | port, |
| 305 | ); | |
| 297 | }); | |
| 306 | 298 | return; |
| 307 | 299 | } |
| 308 | 300 | const big_endian_parts = @ptrCast(*align(1) const [8]u16, &self.in6.addr); |
| ... | ... | @@ -327,19 +319,19 @@ pub const Address = extern union { |
| 327 | 319 | } |
| 328 | 320 | continue; |
| 329 | 321 | } |
| 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]}); | |
| 331 | 323 | if (i != native_endian_parts.len - 1) { |
| 332 | 324 | try output(context, ":"); |
| 333 | 325 | } |
| 334 | 326 | } |
| 335 | try std.fmt.format(context, Errors, output, "]:{}", port); | |
| 327 | try std.fmt.format(context, Errors, output, "]:{}", .{port}); | |
| 336 | 328 | }, |
| 337 | 329 | os.AF_UNIX => { |
| 338 | 330 | if (!has_unix_sockets) { |
| 339 | 331 | unreachable; |
| 340 | 332 | } |
| 341 | 333 | |
| 342 | try std.fmt.format(context, Errors, output, "{}", &self.un.path); | |
| 334 | try std.fmt.format(context, Errors, output, "{}", .{&self.un.path}); | |
| 343 | 335 | }, |
| 344 | 336 | else => unreachable, |
| 345 | 337 | } |
| ... | ... | @@ -445,7 +437,7 @@ pub fn getAddressList(allocator: *mem.Allocator, name: []const u8, port: u16) !* |
| 445 | 437 | const name_c = try std.cstr.addNullByte(allocator, name); |
| 446 | 438 | defer allocator.free(name_c); |
| 447 | 439 | |
| 448 | const port_c = try std.fmt.allocPrint(allocator, "{}\x00", port); | |
| 440 | const port_c = try std.fmt.allocPrint(allocator, "{}\x00", .{port}); | |
| 449 | 441 | defer allocator.free(port_c); |
| 450 | 442 | |
| 451 | 443 | const hints = os.addrinfo{ |
lib/std/net/test.zig+3-3| ... | ... | @@ -29,7 +29,7 @@ test "parse and render IPv6 addresses" { |
| 29 | 29 | }; |
| 30 | 30 | for (ips) |ip, i| { |
| 31 | 31 | 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; | |
| 33 | 33 | std.testing.expect(std.mem.eql(u8, printed[i], newIp[1 .. newIp.len - 3])); |
| 34 | 34 | } |
| 35 | 35 | |
| ... | ... | @@ -51,7 +51,7 @@ test "parse and render IPv4 addresses" { |
| 51 | 51 | "127.0.0.1", |
| 52 | 52 | }) |ip| { |
| 53 | 53 | 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; | |
| 55 | 55 | std.testing.expect(std.mem.eql(u8, ip, newIp[0 .. newIp.len - 2])); |
| 56 | 56 | } |
| 57 | 57 | |
| ... | ... | @@ -118,5 +118,5 @@ fn testServer(server: *net.StreamServer) anyerror!void { |
| 118 | 118 | var client = try server.accept(); |
| 119 | 119 | |
| 120 | 120 | const stream = &client.file.outStream().stream; |
| 121 | try stream.print("hello from server\n"); | |
| 121 | try stream.print("hello from server\n", .{}); | |
| 122 | 122 | } |
lib/std/os.zig+2-2| ... | ... | @@ -2603,7 +2603,7 @@ pub fn realpathC(pathname: [*:0]const u8, out_buffer: *[MAX_PATH_BYTES]u8) RealP |
| 2603 | 2603 | defer close(fd); |
| 2604 | 2604 | |
| 2605 | 2605 | 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; | |
| 2607 | 2607 | |
| 2608 | 2608 | return readlinkC(@ptrCast([*:0]const u8, proc_path.ptr), out_buffer); |
| 2609 | 2609 | } |
| ... | ... | @@ -2832,7 +2832,7 @@ pub const UnexpectedError = error{ |
| 2832 | 2832 | /// and you get an unexpected error. |
| 2833 | 2833 | pub fn unexpectedErrno(err: usize) UnexpectedError { |
| 2834 | 2834 | if (unexpected_error_tracing) { |
| 2835 | std.debug.warn("unexpected errno: {}\n", err); | |
| 2835 | std.debug.warn("unexpected errno: {}\n", .{err}); | |
| 2836 | 2836 | std.debug.dumpCurrentStackTrace(null); |
| 2837 | 2837 | } |
| 2838 | 2838 | return error.Unexpected; |
lib/std/os/windows.zig+3-3| ... | ... | @@ -323,7 +323,7 @@ pub fn GetQueuedCompletionStatus( |
| 323 | 323 | ERROR.HANDLE_EOF => return GetQueuedCompletionStatusResult.EOF, |
| 324 | 324 | else => |err| { |
| 325 | 325 | if (std.debug.runtime_safety) { |
| 326 | std.debug.panic("unexpected error: {}\n", err); | |
| 326 | std.debug.panic("unexpected error: {}\n", .{err}); | |
| 327 | 327 | } |
| 328 | 328 | }, |
| 329 | 329 | } |
| ... | ... | @@ -1039,7 +1039,7 @@ pub fn unexpectedError(err: DWORD) std.os.UnexpectedError { |
| 1039 | 1039 | var buf_u8: [614]u8 = undefined; |
| 1040 | 1040 | 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); |
| 1041 | 1041 | _ = 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] }); | |
| 1043 | 1043 | std.debug.dumpCurrentStackTrace(null); |
| 1044 | 1044 | } |
| 1045 | 1045 | return error.Unexpected; |
| ... | ... | @@ -1053,7 +1053,7 @@ pub fn unexpectedWSAError(err: c_int) std.os.UnexpectedError { |
| 1053 | 1053 | /// and you get an unexpected status. |
| 1054 | 1054 | pub fn unexpectedStatus(status: NTSTATUS) std.os.UnexpectedError { |
| 1055 | 1055 | 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}); | |
| 1057 | 1057 | std.debug.dumpCurrentStackTrace(null); |
| 1058 | 1058 | } |
| 1059 | 1059 | return error.Unexpected; |
lib/std/os/zen.zig deleted-260| ... | ... | @@ -1,260 +0,0 @@ |
| 1 | const std = @import("../std.zig"); | |
| 2 | const assert = std.debug.assert; | |
| 3 | ||
| 4 | ////////////////////////// | |
| 5 | //// IPC structures //// | |
| 6 | ////////////////////////// | |
| 7 | ||
| 8 | pub 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 | ||
| 56 | pub 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 | ||
| 68 | pub 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. | |
| 78 | pub const STDIN_FILENO = 0; | |
| 79 | pub const STDOUT_FILENO = 1; | |
| 80 | pub const STDERR_FILENO = 2; | |
| 81 | ||
| 82 | // FIXME: let's borrow Linux's error numbers for now. | |
| 83 | usingnamespace @import("bits/linux/errno-generic.zig"); | |
| 84 | // Get the errno from a syscall return value, or 0 for no error. | |
| 85 | pub 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. | |
| 91 | pub 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. | |
| 111 | pub 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 | ||
| 125 | pub 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 | ||
| 140 | pub fn exit(status: i32) noreturn { | |
| 141 | _ = syscall1(Syscall.exit, @bitCast(usize, @as(isize, status))); | |
| 142 | unreachable; | |
| 143 | } | |
| 144 | ||
| 145 | pub fn send(message: *const Message) void { | |
| 146 | _ = syscall1(Syscall.send, @ptrToInt(message)); | |
| 147 | } | |
| 148 | ||
| 149 | pub fn receive(destination: *Message) void { | |
| 150 | _ = syscall1(Syscall.receive, @ptrToInt(destination)); | |
| 151 | } | |
| 152 | ||
| 153 | pub fn subscribeIRQ(irq: u8, mailbox_id: *const MailboxId) void { | |
| 154 | _ = syscall2(Syscall.subscribeIRQ, irq, @ptrToInt(mailbox_id)); | |
| 155 | } | |
| 156 | ||
| 157 | pub fn inb(port: u16) u8 { | |
| 158 | return @intCast(u8, syscall1(Syscall.inb, port)); | |
| 159 | } | |
| 160 | ||
| 161 | pub fn outb(port: u16, value: u8) void { | |
| 162 | _ = syscall2(Syscall.outb, port, value); | |
| 163 | } | |
| 164 | ||
| 165 | pub 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 | ||
| 169 | pub fn createThread(function: fn () void) u16 { | |
| 170 | return @as(u16, syscall1(Syscall.createThread, @ptrToInt(function))); | |
| 171 | } | |
| 172 | ||
| 173 | ///////////////////////// | |
| 174 | //// Syscall stubs //// | |
| 175 | ///////////////////////// | |
| 176 | ||
| 177 | inline fn syscall0(number: Syscall) usize { | |
| 178 | return asm volatile ("int $0x80" | |
| 179 | : [ret] "={eax}" (-> usize) | |
| 180 | : [number] "{eax}" (number) | |
| 181 | ); | |
| 182 | } | |
| 183 | ||
| 184 | inline 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 | ||
| 192 | inline 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 | ||
| 201 | inline 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 | ||
| 211 | inline 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 | ||
| 222 | inline 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 | ||
| 241 | inline 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 { |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | fn dump(self: *Self) void { |
| 202 | warn("{{ "); | |
| 203 | warn("items: "); | |
| 202 | warn("{{ ", .{}); | |
| 203 | warn("items: ", .{}); | |
| 204 | 204 | for (self.items) |e, i| { |
| 205 | 205 | if (i >= self.len) break; |
| 206 | warn("{}, ", e); | |
| 206 | warn("{}, ", .{e}); | |
| 207 | 207 | } |
| 208 | warn("array: "); | |
| 208 | warn("array: ", .{}); | |
| 209 | 209 | for (self.items) |e, i| { |
| 210 | warn("{}, ", e); | |
| 210 | warn("{}, ", .{e}); | |
| 211 | 211 | } |
| 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", .{}); | |
| 215 | 215 | } |
| 216 | 216 | }; |
| 217 | 217 | } |
lib/std/progress.zig+11-11| ... | ... | @@ -130,11 +130,11 @@ pub const Progress = struct { |
| 130 | 130 | var end: usize = 0; |
| 131 | 131 | if (self.columns_written > 0) { |
| 132 | 132 | // 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; | |
| 134 | 134 | self.columns_written = 0; |
| 135 | 135 | |
| 136 | 136 | // 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; | |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | if (!self.done) { |
| ... | ... | @@ -142,28 +142,28 @@ pub const Progress = struct { |
| 142 | 142 | var maybe_node: ?*Node = &self.root; |
| 143 | 143 | while (maybe_node) |node| { |
| 144 | 144 | if (need_ellipse) { |
| 145 | self.bufWrite(&end, "..."); | |
| 145 | self.bufWrite(&end, "...", .{}); | |
| 146 | 146 | } |
| 147 | 147 | need_ellipse = false; |
| 148 | 148 | if (node.name.len != 0 or node.estimated_total_items != null) { |
| 149 | 149 | if (node.name.len != 0) { |
| 150 | self.bufWrite(&end, "{}", node.name); | |
| 150 | self.bufWrite(&end, "{}", .{node.name}); | |
| 151 | 151 | need_ellipse = true; |
| 152 | 152 | } |
| 153 | 153 | 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 }); | |
| 156 | 156 | need_ellipse = false; |
| 157 | 157 | } 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}); | |
| 160 | 160 | need_ellipse = false; |
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | maybe_node = node.recently_updated_child; |
| 164 | 164 | } |
| 165 | 165 | if (need_ellipse) { |
| 166 | self.bufWrite(&end, "..."); | |
| 166 | self.bufWrite(&end, "...", .{}); | |
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | |
| ... | ... | @@ -174,7 +174,7 @@ pub const Progress = struct { |
| 174 | 174 | self.prev_refresh_timestamp = self.timer.read(); |
| 175 | 175 | } |
| 176 | 176 | |
| 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 { | |
| 178 | 178 | const file = self.terminal orelse return; |
| 179 | 179 | self.refresh(); |
| 180 | 180 | file.outStream().stream.print(format, args) catch { |
| ... | ... | @@ -184,7 +184,7 @@ pub const Progress = struct { |
| 184 | 184 | self.columns_written = 0; |
| 185 | 185 | } |
| 186 | 186 | |
| 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 { | |
| 188 | 188 | if (std.fmt.bufPrint(self.output_buffer[end.*..], format, args)) |written| { |
| 189 | 189 | const amt = written.len; |
| 190 | 190 | end.* += amt; |
lib/std/special/build_runner.zig+18-15| ... | ... | @@ -26,15 +26,15 @@ pub fn main() !void { |
| 26 | 26 | _ = arg_it.skip(); |
| 27 | 27 | |
| 28 | 28 | 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", .{}); | |
| 30 | 30 | return error.InvalidArgs; |
| 31 | 31 | }); |
| 32 | 32 | 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", .{}); | |
| 34 | 34 | return error.InvalidArgs; |
| 35 | 35 | }); |
| 36 | 36 | 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", .{}); | |
| 38 | 38 | return error.InvalidArgs; |
| 39 | 39 | }); |
| 40 | 40 | |
| ... | ... | @@ -51,7 +51,7 @@ pub fn main() !void { |
| 51 | 51 | if (mem.startsWith(u8, arg, "-D")) { |
| 52 | 52 | const option_contents = arg[2..]; |
| 53 | 53 | if (option_contents.len == 0) { |
| 54 | warn("Expected option name after '-D'\n\n"); | |
| 54 | warn("Expected option name after '-D'\n\n", .{}); | |
| 55 | 55 | return usageAndErr(builder, false, stderr_stream); |
| 56 | 56 | } |
| 57 | 57 | if (mem.indexOfScalar(u8, option_contents, '=')) |name_end| { |
| ... | ... | @@ -70,18 +70,18 @@ pub fn main() !void { |
| 70 | 70 | return usage(builder, false, stdout_stream); |
| 71 | 71 | } else if (mem.eql(u8, arg, "--prefix")) { |
| 72 | 72 | 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", .{}); | |
| 74 | 74 | return usageAndErr(builder, false, stderr_stream); |
| 75 | 75 | }); |
| 76 | 76 | } else if (mem.eql(u8, arg, "--search-prefix")) { |
| 77 | 77 | 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", .{}); | |
| 79 | 79 | return usageAndErr(builder, false, stderr_stream); |
| 80 | 80 | }); |
| 81 | 81 | builder.addSearchPrefix(search_prefix); |
| 82 | 82 | } else if (mem.eql(u8, arg, "--override-lib-dir")) { |
| 83 | 83 | 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", .{}); | |
| 85 | 85 | return usageAndErr(builder, false, stderr_stream); |
| 86 | 86 | }); |
| 87 | 87 | } else if (mem.eql(u8, arg, "--verbose-tokenize")) { |
| ... | ... | @@ -99,7 +99,7 @@ pub fn main() !void { |
| 99 | 99 | } else if (mem.eql(u8, arg, "--verbose-cc")) { |
| 100 | 100 | builder.verbose_cc = true; |
| 101 | 101 | } else { |
| 102 | warn("Unrecognized argument: {}\n\n", arg); | |
| 102 | warn("Unrecognized argument: {}\n\n", .{arg}); | |
| 103 | 103 | return usageAndErr(builder, false, stderr_stream); |
| 104 | 104 | } |
| 105 | 105 | } else { |
| ... | ... | @@ -145,15 +145,15 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void { |
| 145 | 145 | \\ |
| 146 | 146 | \\Steps: |
| 147 | 147 | \\ |
| 148 | , builder.zig_exe); | |
| 148 | , .{builder.zig_exe}); | |
| 149 | 149 | |
| 150 | 150 | const allocator = builder.allocator; |
| 151 | 151 | for (builder.top_level_steps.toSliceConst()) |top_level_step| { |
| 152 | 152 | 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}) | |
| 154 | 154 | else |
| 155 | 155 | 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 }); | |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | try out_stream.write( |
| ... | ... | @@ -169,12 +169,15 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: var) !void { |
| 169 | 169 | ); |
| 170 | 170 | |
| 171 | 171 | if (builder.available_options_list.len == 0) { |
| 172 | try out_stream.print(" (none)\n"); | |
| 172 | try out_stream.print(" (none)\n", .{}); | |
| 173 | 173 | } else { |
| 174 | 174 | 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 | }); | |
| 176 | 179 | 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 }); | |
| 178 | 181 | } |
| 179 | 182 | } |
| 180 | 183 | |
| ... | ... | @@ -204,7 +207,7 @@ const UnwrapArgError = error{OutOfMemory}; |
| 204 | 207 | |
| 205 | 208 | fn unwrapArg(arg: UnwrapArgError![]u8) UnwrapArgError![]u8 { |
| 206 | 209 | return arg catch |err| { |
| 207 | warn("Unable to parse command line: {}\n", err); | |
| 210 | warn("Unable to parse command line: {}\n", .{err}); | |
| 208 | 211 | return err; |
| 209 | 212 | }; |
| 210 | 213 | } |
lib/std/special/compiler_rt/truncXfYf2_test.zig+1-1| ... | ... | @@ -217,7 +217,7 @@ fn test__truncdfsf2(a: f64, expected: u32) void { |
| 217 | 217 | } |
| 218 | 218 | } |
| 219 | 219 | |
| 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 }); | |
| 221 | 221 | |
| 222 | 222 | @panic("__trunctfsf2 test failure"); |
| 223 | 223 | } |
lib/std/special/init-exe/src/main.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | |
| 3 | 3 | pub 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", .{}); | |
| 5 | 5 | } |
lib/std/special/start.zig+2-2| ... | ... | @@ -217,7 +217,7 @@ inline fn initEventLoopAndCallMain() u8 { |
| 217 | 217 | if (std.event.Loop.instance) |loop| { |
| 218 | 218 | if (!@hasDecl(root, "event_loop")) { |
| 219 | 219 | loop.init() catch |err| { |
| 220 | std.debug.warn("error: {}\n", @errorName(err)); | |
| 220 | std.debug.warn("error: {}\n", .{@errorName(err)}); | |
| 221 | 221 | if (@errorReturnTrace()) |trace| { |
| 222 | 222 | std.debug.dumpStackTrace(trace.*); |
| 223 | 223 | } |
| ... | ... | @@ -264,7 +264,7 @@ fn callMain() u8 { |
| 264 | 264 | }, |
| 265 | 265 | .ErrorUnion => { |
| 266 | 266 | const result = root.main() catch |err| { |
| 267 | std.debug.warn("error: {}\n", @errorName(err)); | |
| 267 | std.debug.warn("error: {}\n", .{@errorName(err)}); | |
| 268 | 268 | if (@errorReturnTrace()) |trace| { |
| 269 | 269 | std.debug.dumpStackTrace(trace.*); |
| 270 | 270 | } |
lib/std/special/test_runner.zig+7-7| ... | ... | @@ -16,28 +16,28 @@ pub fn main() anyerror!void { |
| 16 | 16 | var test_node = root_node.start(test_fn.name, null); |
| 17 | 17 | test_node.activate(); |
| 18 | 18 | 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 }); | |
| 20 | 20 | if (test_fn.func()) |_| { |
| 21 | 21 | ok_count += 1; |
| 22 | 22 | test_node.end(); |
| 23 | if (progress.terminal == null) std.debug.warn("OK\n"); | |
| 23 | if (progress.terminal == null) std.debug.warn("OK\n", .{}); | |
| 24 | 24 | } else |err| switch (err) { |
| 25 | 25 | error.SkipZigTest => { |
| 26 | 26 | skip_count += 1; |
| 27 | 27 | 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", .{}); | |
| 30 | 30 | }, |
| 31 | 31 | else => { |
| 32 | progress.log(""); | |
| 32 | progress.log("", .{}); | |
| 33 | 33 | return err; |
| 34 | 34 | }, |
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | root_node.end(); |
| 38 | 38 | 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}); | |
| 40 | 40 | } else { |
| 41 | std.debug.warn("{} passed; {} skipped.\n", ok_count, skip_count); | |
| 41 | std.debug.warn("{} passed; {} skipped.\n", .{ ok_count, skip_count }); | |
| 42 | 42 | } |
| 43 | 43 | } |
lib/std/target.zig+6-12| ... | ... | @@ -321,14 +321,12 @@ pub const Target = union(enum) { |
| 321 | 321 | pub const stack_align = 16; |
| 322 | 322 | |
| 323 | 323 | pub fn zigTriple(self: Target, allocator: *mem.Allocator) ![]u8 { |
| 324 | return std.fmt.allocPrint( | |
| 325 | allocator, | |
| 326 | "{}{}-{}-{}", | |
| 324 | return std.fmt.allocPrint(allocator, "{}{}-{}-{}", .{ | |
| 327 | 325 | @tagName(self.getArch()), |
| 328 | 326 | Target.archSubArchName(self.getArch()), |
| 329 | 327 | @tagName(self.getOs()), |
| 330 | 328 | @tagName(self.getAbi()), |
| 331 | ); | |
| 329 | }); | |
| 332 | 330 | } |
| 333 | 331 | |
| 334 | 332 | /// Returned slice must be freed by the caller. |
| ... | ... | @@ -372,23 +370,19 @@ pub const Target = union(enum) { |
| 372 | 370 | } |
| 373 | 371 | |
| 374 | 372 | pub fn zigTripleNoSubArch(self: Target, allocator: *mem.Allocator) ![]u8 { |
| 375 | return std.fmt.allocPrint( | |
| 376 | allocator, | |
| 377 | "{}-{}-{}", | |
| 373 | return std.fmt.allocPrint(allocator, "{}-{}-{}", .{ | |
| 378 | 374 | @tagName(self.getArch()), |
| 379 | 375 | @tagName(self.getOs()), |
| 380 | 376 | @tagName(self.getAbi()), |
| 381 | ); | |
| 377 | }); | |
| 382 | 378 | } |
| 383 | 379 | |
| 384 | 380 | pub fn linuxTriple(self: Target, allocator: *mem.Allocator) ![]u8 { |
| 385 | return std.fmt.allocPrint( | |
| 386 | allocator, | |
| 387 | "{}-{}-{}", | |
| 381 | return std.fmt.allocPrint(allocator, "{}-{}-{}", .{ | |
| 388 | 382 | @tagName(self.getArch()), |
| 389 | 383 | @tagName(self.getOs()), |
| 390 | 384 | @tagName(self.getAbi()), |
| 391 | ); | |
| 385 | }); | |
| 392 | 386 | } |
| 393 | 387 | |
| 394 | 388 | 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 { |
| 8 | 8 | if (actual_error_union) |actual_payload| { |
| 9 | 9 | // TODO remove workaround here for https://github.com/ziglang/zig/issues/557 |
| 10 | 10 | 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 | }); | |
| 12 | 15 | } 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 }); | |
| 14 | 17 | } |
| 15 | 18 | } else |actual_error| { |
| 16 | 19 | 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 | }); | |
| 18 | 24 | } |
| 19 | 25 | } |
| 20 | 26 | } |
| ... | ... | @@ -51,7 +57,7 @@ pub fn expectEqual(expected: var, actual: @typeOf(expected)) void { |
| 51 | 57 | .ErrorSet, |
| 52 | 58 | => { |
| 53 | 59 | if (actual != expected) { |
| 54 | std.debug.panic("expected {}, found {}", expected, actual); | |
| 60 | std.debug.panic("expected {}, found {}", .{ expected, actual }); | |
| 55 | 61 | } |
| 56 | 62 | }, |
| 57 | 63 | |
| ... | ... | @@ -62,16 +68,16 @@ pub fn expectEqual(expected: var, actual: @typeOf(expected)) void { |
| 62 | 68 | builtin.TypeInfo.Pointer.Size.C, |
| 63 | 69 | => { |
| 64 | 70 | if (actual != expected) { |
| 65 | std.debug.panic("expected {*}, found {*}", expected, actual); | |
| 71 | std.debug.panic("expected {*}, found {*}", .{ expected, actual }); | |
| 66 | 72 | } |
| 67 | 73 | }, |
| 68 | 74 | |
| 69 | 75 | builtin.TypeInfo.Pointer.Size.Slice => { |
| 70 | 76 | 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 }); | |
| 72 | 78 | } |
| 73 | 79 | 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 }); | |
| 75 | 81 | } |
| 76 | 82 | }, |
| 77 | 83 | } |
| ... | ... | @@ -106,7 +112,7 @@ pub fn expectEqual(expected: var, actual: @typeOf(expected)) void { |
| 106 | 112 | } |
| 107 | 113 | |
| 108 | 114 | // 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 | |
| 110 | 116 | // including all possible values. |
| 111 | 117 | unreachable; |
| 112 | 118 | }, |
| ... | ... | @@ -116,11 +122,11 @@ pub fn expectEqual(expected: var, actual: @typeOf(expected)) void { |
| 116 | 122 | if (actual) |actual_payload| { |
| 117 | 123 | expectEqual(expected_payload, actual_payload); |
| 118 | 124 | } else { |
| 119 | std.debug.panic("expected {}, found null", expected_payload); | |
| 125 | std.debug.panic("expected {}, found null", .{expected_payload}); | |
| 120 | 126 | } |
| 121 | 127 | } else { |
| 122 | 128 | if (actual) |actual_payload| { |
| 123 | std.debug.panic("expected null, found {}", actual_payload); | |
| 129 | std.debug.panic("expected null, found {}", .{actual_payload}); | |
| 124 | 130 | } |
| 125 | 131 | } |
| 126 | 132 | }, |
| ... | ... | @@ -130,11 +136,11 @@ pub fn expectEqual(expected: var, actual: @typeOf(expected)) void { |
| 130 | 136 | if (actual) |actual_payload| { |
| 131 | 137 | expectEqual(expected_payload, actual_payload); |
| 132 | 138 | } else |actual_err| { |
| 133 | std.debug.panic("expected {}, found {}", expected_payload, actual_err); | |
| 139 | std.debug.panic("expected {}, found {}", .{ expected_payload, actual_err }); | |
| 134 | 140 | } |
| 135 | 141 | } else |expected_err| { |
| 136 | 142 | if (actual) |actual_payload| { |
| 137 | std.debug.panic("expected {}, found {}", expected_err, actual_payload); | |
| 143 | std.debug.panic("expected {}, found {}", .{ expected_err, actual_payload }); | |
| 138 | 144 | } else |actual_err| { |
| 139 | 145 | expectEqual(expected_err, actual_err); |
| 140 | 146 | } |
| ... | ... | @@ -143,15 +149,14 @@ pub fn expectEqual(expected: var, actual: @typeOf(expected)) void { |
| 143 | 149 | } |
| 144 | 150 | } |
| 145 | 151 | |
| 146 | test "expectEqual.union(enum)" | |
| 147 | { | |
| 152 | test "expectEqual.union(enum)" { | |
| 148 | 153 | const T = union(enum) { |
| 149 | 154 | a: i32, |
| 150 | 155 | b: f32, |
| 151 | 156 | }; |
| 152 | 157 | |
| 153 | const a10 = T { .a = 10 }; | |
| 154 | const a20 = T { .a = 20 }; | |
| 158 | const a10 = T{ .a = 10 }; | |
| 159 | const a20 = T{ .a = 20 }; | |
| 155 | 160 | |
| 156 | 161 | expectEqual(a10, a10); |
| 157 | 162 | } |
| ... | ... | @@ -165,12 +170,12 @@ pub fn expectEqualSlices(comptime T: type, expected: []const T, actual: []const |
| 165 | 170 | // If the child type is u8 and no weird bytes, we could print it as strings |
| 166 | 171 | // Even for the length difference, it would be useful to see the values of the slices probably. |
| 167 | 172 | 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 }); | |
| 169 | 174 | } |
| 170 | 175 | var i: usize = 0; |
| 171 | 176 | while (i < expected.len) : (i += 1) { |
| 172 | 177 | 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] }); | |
| 174 | 179 | } |
| 175 | 180 | } |
| 176 | 181 | } |
lib/std/unicode.zig+1-1| ... | ... | @@ -170,7 +170,7 @@ pub fn utf8ValidateSlice(s: []const u8) bool { |
| 170 | 170 | /// ``` |
| 171 | 171 | /// var utf8 = (try std.unicode.Utf8View.init("hi there")).iterator(); |
| 172 | 172 | /// while (utf8.nextCodepointSlice()) |codepoint| { |
| 173 | /// std.debug.warn("got codepoint {}\n", codepoint); | |
| 173 | /// std.debug.warn("got codepoint {}\n", .{codepoint}); | |
| 174 | 174 | /// } |
| 175 | 175 | /// ``` |
| 176 | 176 | pub const Utf8View = struct { |
lib/std/unicode/throughput_test.zig+6-2| ... | ... | @@ -24,8 +24,12 @@ pub fn main() !void { |
| 24 | 24 | const elapsed_ns_better = timer.lap(); |
| 25 | 25 | @fence(.SeqCst); |
| 26 | 26 | |
| 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 | }); | |
| 29 | 33 | asm volatile ("nop" |
| 30 | 34 | : |
| 31 | 35 | : [a] "r" (&buffer1), |
lib/std/valgrind.zig-14| ... | ... | @@ -114,20 +114,6 @@ pub fn innerThreads(qzz: [*]u8) void { |
| 114 | 114 | doClientRequestStmt(.InnerThreads, qzz, 0, 0, 0, 0); |
| 115 | 115 | } |
| 116 | 116 | |
| 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 | ||
| 131 | 117 | pub fn nonSIMDCall0(func: fn (usize) usize) usize { |
| 132 | 118 | return doClientRequestExpr(0, .ClientCall0, @ptrToInt(func), 0, 0, 0, 0); |
| 133 | 119 | } |
lib/std/zig/ast.zig+15-9| ... | ... | @@ -301,7 +301,9 @@ pub const Error = union(enum) { |
| 301 | 301 | node: *Node, |
| 302 | 302 | |
| 303 | 303 | 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 | }); | |
| 305 | 307 | } |
| 306 | 308 | }; |
| 307 | 309 | |
| ... | ... | @@ -309,7 +311,8 @@ pub const Error = union(enum) { |
| 309 | 311 | node: *Node, |
| 310 | 312 | |
| 311 | 313 | 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)}); | |
| 313 | 316 | } |
| 314 | 317 | }; |
| 315 | 318 | |
| ... | ... | @@ -321,14 +324,14 @@ pub const Error = union(enum) { |
| 321 | 324 | const found_token = tokens.at(self.token); |
| 322 | 325 | switch (found_token.id) { |
| 323 | 326 | .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.", .{}); | |
| 325 | 328 | }, |
| 326 | 329 | .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()}); | |
| 328 | 331 | }, |
| 329 | 332 | else => { |
| 330 | 333 | 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 }); | |
| 332 | 335 | }, |
| 333 | 336 | } |
| 334 | 337 | } |
| ... | ... | @@ -340,7 +343,10 @@ pub const Error = union(enum) { |
| 340 | 343 | |
| 341 | 344 | pub fn render(self: *const ExpectedCommaOrEnd, tokens: *Tree.TokenList, stream: var) !void { |
| 342 | 345 | 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 | }); | |
| 344 | 350 | } |
| 345 | 351 | }; |
| 346 | 352 | |
| ... | ... | @@ -352,7 +358,7 @@ pub const Error = union(enum) { |
| 352 | 358 | |
| 353 | 359 | pub fn render(self: *const ThisError, tokens: *Tree.TokenList, stream: var) !void { |
| 354 | 360 | 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()}); | |
| 356 | 362 | } |
| 357 | 363 | }; |
| 358 | 364 | } |
| ... | ... | @@ -563,10 +569,10 @@ pub const Node = struct { |
| 563 | 569 | { |
| 564 | 570 | var i: usize = 0; |
| 565 | 571 | while (i < indent) : (i += 1) { |
| 566 | std.debug.warn(" "); | |
| 572 | std.debug.warn(" ", .{}); | |
| 567 | 573 | } |
| 568 | 574 | } |
| 569 | std.debug.warn("{}\n", @tagName(self.id)); | |
| 575 | std.debug.warn("{}\n", .{@tagName(self.id)}); | |
| 570 | 576 | |
| 571 | 577 | var child_i: usize = 0; |
| 572 | 578 | 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" { |
| 642 | 642 | ); |
| 643 | 643 | } |
| 644 | 644 | |
| 645 | test "zig fmt: var_args with trailing comma" { | |
| 646 | try testCanonical( | |
| 647 | \\pub fn add( | |
| 648 | \\ a: ..., | |
| 649 | \\) void {} | |
| 650 | \\ | |
| 651 | ); | |
| 652 | } | |
| 653 | ||
| 654 | 645 | test "zig fmt: enum decl with no trailing comma" { |
| 655 | 646 | try testTransform( |
| 656 | 647 | \\const StrLitKind = enum {Normal, C}; |
| ... | ... | @@ -1750,13 +1741,6 @@ test "zig fmt: call expression" { |
| 1750 | 1741 | ); |
| 1751 | 1742 | } |
| 1752 | 1743 | |
| 1753 | test "zig fmt: var args" { | |
| 1754 | try testCanonical( | |
| 1755 | \\fn print(args: ...) void {} | |
| 1756 | \\ | |
| 1757 | ); | |
| 1758 | } | |
| 1759 | ||
| 1760 | 1744 | test "zig fmt: var type" { |
| 1761 | 1745 | try testCanonical( |
| 1762 | 1746 | \\fn print(args: var) var {} |
| ... | ... | @@ -2705,9 +2689,9 @@ fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *b |
| 2705 | 2689 | while (error_it.next()) |parse_error| { |
| 2706 | 2690 | const token = tree.tokens.at(parse_error.loc()); |
| 2707 | 2691 | 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 }); | |
| 2709 | 2693 | 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]}); | |
| 2711 | 2695 | { |
| 2712 | 2696 | var i: usize = 0; |
| 2713 | 2697 | while (i < loc.column) : (i += 1) { |
| ... | ... | @@ -2743,16 +2727,16 @@ fn testTransform(source: []const u8, expected_source: []const u8) !void { |
| 2743 | 2727 | var anything_changed: bool = undefined; |
| 2744 | 2728 | const result_source = try testParse(source, &failing_allocator.allocator, &anything_changed); |
| 2745 | 2729 | 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", .{}); | |
| 2751 | 2735 | return error.TestFailed; |
| 2752 | 2736 | } |
| 2753 | 2737 | const changes_expected = source.ptr != expected_source.ptr; |
| 2754 | 2738 | 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 }); | |
| 2756 | 2740 | return error.TestFailed; |
| 2757 | 2741 | } |
| 2758 | 2742 | std.testing.expect(anything_changed == changes_expected); |
| ... | ... | @@ -2772,12 +2756,14 @@ fn testTransform(source: []const u8, expected_source: []const u8) !void { |
| 2772 | 2756 | if (failing_allocator.allocated_bytes != failing_allocator.freed_bytes) { |
| 2773 | 2757 | warn( |
| 2774 | 2758 | "\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 | }, | |
| 2781 | 2767 | ); |
| 2782 | 2768 | return error.MemoryLeakDetected; |
| 2783 | 2769 | } |
lib/std/zig/render.zig+3-3| ... | ... | @@ -76,7 +76,7 @@ fn renderRoot( |
| 76 | 76 | // render all the line comments at the beginning of the file |
| 77 | 77 | while (tok_it.next()) |token| { |
| 78 | 78 | 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), " ")}); | |
| 80 | 80 | if (tok_it.peek()) |next_token| { |
| 81 | 81 | const loc = tree.tokenLocationPtr(token.end, next_token); |
| 82 | 82 | if (loc.line >= 2) { |
| ... | ... | @@ -1226,7 +1226,7 @@ fn renderExpression( |
| 1226 | 1226 | |
| 1227 | 1227 | var skip_first_indent = true; |
| 1228 | 1228 | if (tree.tokens.at(multiline_str_literal.firstToken() - 1).id != .LineComment) { |
| 1229 | try stream.print("\n"); | |
| 1229 | try stream.print("\n", .{}); | |
| 1230 | 1230 | skip_first_indent = false; |
| 1231 | 1231 | } |
| 1232 | 1232 | |
| ... | ... | @@ -2129,7 +2129,7 @@ fn renderTokenOffset( |
| 2129 | 2129 | |
| 2130 | 2130 | var loc = tree.tokenLocationPtr(token.end, next_token); |
| 2131 | 2131 | 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), " ")}); | |
| 2133 | 2133 | offset = 2; |
| 2134 | 2134 | token = next_token; |
| 2135 | 2135 | next_token = tree.tokens.at(token_index + offset); |
lib/std/zig/tokenizer.zig+2-2| ... | ... | @@ -330,7 +330,7 @@ pub const Tokenizer = struct { |
| 330 | 330 | |
| 331 | 331 | /// For debugging purposes |
| 332 | 332 | 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] }); | |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | pub fn init(buffer: []const u8) Tokenizer { |
| ... | ... | @@ -1576,7 +1576,7 @@ fn testTokenize(source: []const u8, expected_tokens: []const Token.Id) void { |
| 1576 | 1576 | for (expected_tokens) |expected_token_id| { |
| 1577 | 1577 | const token = tokenizer.next(); |
| 1578 | 1578 | 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) }); | |
| 1580 | 1580 | } |
| 1581 | 1581 | } |
| 1582 | 1582 | const last_token = tokenizer.next(); |
src-self-hosted/arg.zig+6-6| ... | ... | @@ -98,15 +98,15 @@ pub const Args = struct { |
| 98 | 98 | const flag_args = readFlagArguments(allocator, args, flag.required, flag.allowed_set, &i) catch |err| { |
| 99 | 99 | switch (err) { |
| 100 | 100 | 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 ", .{}); | |
| 103 | 103 | for (flag.allowed_set.?) |possible| { |
| 104 | std.debug.warn("'{}' ", possible); | |
| 104 | std.debug.warn("'{}' ", .{possible}); | |
| 105 | 105 | } |
| 106 | std.debug.warn("\n"); | |
| 106 | std.debug.warn("\n", .{}); | |
| 107 | 107 | }, |
| 108 | 108 | error.MissingFlagArguments => { |
| 109 | std.debug.warn("missing argument for flag: {}\n", arg); | |
| 109 | std.debug.warn("missing argument for flag: {}\n", .{arg}); | |
| 110 | 110 | }, |
| 111 | 111 | else => {}, |
| 112 | 112 | } |
| ... | ... | @@ -134,7 +134,7 @@ pub const Args = struct { |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // 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}); | |
| 138 | 138 | return error.UnknownFlag; |
| 139 | 139 | } else { |
| 140 | 140 | 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) |
| 45 | 45 | |
| 46 | 46 | // Don't use ZIG_VERSION_STRING here. LLVM misparses it when it includes |
| 47 | 47 | // 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 {}.{}.{}", .{ | |
| 51 | 49 | @as(u32, c.ZIG_VERSION_MAJOR), |
| 52 | 50 | @as(u32, c.ZIG_VERSION_MINOR), |
| 53 | 51 | @as(u32, c.ZIG_VERSION_PATCH), |
| 54 | ); | |
| 52 | }); | |
| 55 | 53 | const flags = ""; |
| 56 | 54 | const runtime_version = 0; |
| 57 | 55 | const compile_unit_file = llvm.CreateFile( |
| ... | ... | @@ -93,7 +91,7 @@ pub async fn renderToLlvm(comp: *Compilation, fn_val: *Value.Fn, code: *ir.Code) |
| 93 | 91 | llvm.DIBuilderFinalize(dibuilder); |
| 94 | 92 | |
| 95 | 93 | if (comp.verbose_llvm_ir) { |
| 96 | std.debug.warn("raw module:\n"); | |
| 94 | std.debug.warn("raw module:\n", .{}); | |
| 97 | 95 | llvm.DumpModule(ofile.module); |
| 98 | 96 | } |
| 99 | 97 | |
| ... | ... | @@ -120,18 +118,18 @@ pub async fn renderToLlvm(comp: *Compilation, fn_val: *Value.Fn, code: *ir.Code) |
| 120 | 118 | is_small, |
| 121 | 119 | )) { |
| 122 | 120 | 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 }); | |
| 124 | 122 | } |
| 125 | 123 | return error.WritingObjectFileFailed; |
| 126 | 124 | } |
| 127 | 125 | //validate_inline_fns(g); TODO |
| 128 | 126 | fn_val.containing_object = output_path; |
| 129 | 127 | if (comp.verbose_llvm_ir) { |
| 130 | std.debug.warn("optimized module:\n"); | |
| 128 | std.debug.warn("optimized module:\n", .{}); | |
| 131 | 129 | llvm.DumpModule(ofile.module); |
| 132 | 130 | } |
| 133 | 131 | if (comp.verbose_link) { |
| 134 | std.debug.warn("created {}\n", output_path.toSliceConst()); | |
| 132 | std.debug.warn("created {}\n", .{output_path.toSliceConst()}); | |
| 135 | 133 | } |
| 136 | 134 | } |
| 137 | 135 |
src-self-hosted/compilation.zig+12-15| ... | ... | @@ -807,7 +807,7 @@ pub const Compilation = struct { |
| 807 | 807 | root_scope.realpath, |
| 808 | 808 | max_src_size, |
| 809 | 809 | ) 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)}); | |
| 811 | 811 | return; |
| 812 | 812 | }; |
| 813 | 813 | errdefer self.gpa().free(source_code); |
| ... | ... | @@ -878,7 +878,7 @@ pub const Compilation = struct { |
| 878 | 878 | try self.addCompileError(tree_scope, Span{ |
| 879 | 879 | .first = fn_proto.fn_token, |
| 880 | 880 | .last = fn_proto.fn_token + 1, |
| 881 | }, "missing function name"); | |
| 881 | }, "missing function name", .{}); | |
| 882 | 882 | continue; |
| 883 | 883 | }; |
| 884 | 884 | |
| ... | ... | @@ -942,7 +942,7 @@ pub const Compilation = struct { |
| 942 | 942 | const root_scope = blk: { |
| 943 | 943 | // TODO async/await std.fs.realpath |
| 944 | 944 | 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)}); | |
| 946 | 946 | return; |
| 947 | 947 | }; |
| 948 | 948 | errdefer self.gpa().free(root_src_real_path); |
| ... | ... | @@ -991,7 +991,7 @@ pub const Compilation = struct { |
| 991 | 991 | defer unanalyzed_code.destroy(comp.gpa()); |
| 992 | 992 | |
| 993 | 993 | if (comp.verbose_ir) { |
| 994 | std.debug.warn("unanalyzed:\n"); | |
| 994 | std.debug.warn("unanalyzed:\n", .{}); | |
| 995 | 995 | unanalyzed_code.dump(); |
| 996 | 996 | } |
| 997 | 997 | |
| ... | ... | @@ -1003,7 +1003,7 @@ pub const Compilation = struct { |
| 1003 | 1003 | errdefer analyzed_code.destroy(comp.gpa()); |
| 1004 | 1004 | |
| 1005 | 1005 | if (comp.verbose_ir) { |
| 1006 | std.debug.warn("analyzed:\n"); | |
| 1006 | std.debug.warn("analyzed:\n", .{}); | |
| 1007 | 1007 | analyzed_code.dump(); |
| 1008 | 1008 | } |
| 1009 | 1009 | |
| ... | ... | @@ -1048,14 +1048,14 @@ pub const Compilation = struct { |
| 1048 | 1048 | |
| 1049 | 1049 | const gop = try locked_table.getOrPut(decl.name); |
| 1050 | 1050 | 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}); | |
| 1052 | 1052 | // TODO note: other definition here |
| 1053 | 1053 | } else { |
| 1054 | 1054 | gop.kv.value = decl; |
| 1055 | 1055 | } |
| 1056 | 1056 | } |
| 1057 | 1057 | |
| 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 { | |
| 1059 | 1059 | const text = try std.fmt.allocPrint(self.gpa(), fmt, args); |
| 1060 | 1060 | errdefer self.gpa().free(text); |
| 1061 | 1061 | |
| ... | ... | @@ -1065,7 +1065,7 @@ pub const Compilation = struct { |
| 1065 | 1065 | try self.prelink_group.call(addCompileErrorAsync, self, msg); |
| 1066 | 1066 | } |
| 1067 | 1067 | |
| 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 { | |
| 1069 | 1069 | const text = try std.fmt.allocPrint(self.gpa(), fmt, args); |
| 1070 | 1070 | errdefer self.gpa().free(text); |
| 1071 | 1071 | |
| ... | ... | @@ -1092,12 +1092,9 @@ pub const Compilation = struct { |
| 1092 | 1092 | defer exported_symbol_names.release(); |
| 1093 | 1093 | |
| 1094 | 1094 | 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: '{}'", .{ | |
| 1099 | 1096 | decl.name, |
| 1100 | ); | |
| 1097 | }); | |
| 1101 | 1098 | // TODO add error note showing location of other symbol |
| 1102 | 1099 | } |
| 1103 | 1100 | } |
| ... | ... | @@ -1162,7 +1159,7 @@ pub const Compilation = struct { |
| 1162 | 1159 | const tmp_dir = try self.getTmpDir(); |
| 1163 | 1160 | const file_prefix = self.getRandomFileName(); |
| 1164 | 1161 | |
| 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 }); | |
| 1166 | 1163 | defer self.gpa().free(file_name); |
| 1167 | 1164 | |
| 1168 | 1165 | 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 { |
| 1303 | 1300 | try comp.addCompileError(tree_scope, Span{ |
| 1304 | 1301 | .first = param_decl.firstToken(), |
| 1305 | 1302 | .last = param_decl.type_node.firstToken(), |
| 1306 | }, "missing parameter name"); | |
| 1303 | }, "missing parameter name", .{}); | |
| 1307 | 1304 | return error.SemanticAnalysisFailed; |
| 1308 | 1305 | }; |
| 1309 | 1306 | 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 { |
| 38 | 38 | }, |
| 39 | 39 | .target => |*target| switch (char) { |
| 40 | 40 | '\t', '\n', '\r', ' ' => { |
| 41 | return self.errorIllegalChar(self.index, char, "invalid target"); | |
| 41 | return self.errorIllegalChar(self.index, char, "invalid target", .{}); | |
| 42 | 42 | }, |
| 43 | 43 | '$' => { |
| 44 | 44 | self.state = State{ .target_dollar_sign = target.* }; |
| ... | ... | @@ -59,7 +59,7 @@ pub const Tokenizer = struct { |
| 59 | 59 | }, |
| 60 | 60 | .target_reverse_solidus => |*target| switch (char) { |
| 61 | 61 | '\t', '\n', '\r' => { |
| 62 | return self.errorIllegalChar(self.index, char, "bad target escape"); | |
| 62 | return self.errorIllegalChar(self.index, char, "bad target escape", .{}); | |
| 63 | 63 | }, |
| 64 | 64 | ' ', '#', '\\' => { |
| 65 | 65 | try target.appendByte(char); |
| ... | ... | @@ -84,7 +84,7 @@ pub const Tokenizer = struct { |
| 84 | 84 | break; // advance |
| 85 | 85 | }, |
| 86 | 86 | else => { |
| 87 | return self.errorIllegalChar(self.index, char, "expecting '$'"); | |
| 87 | return self.errorIllegalChar(self.index, char, "expecting '$'", .{}); | |
| 88 | 88 | }, |
| 89 | 89 | }, |
| 90 | 90 | .target_colon => |*target| switch (char) { |
| ... | ... | @@ -161,7 +161,7 @@ pub const Tokenizer = struct { |
| 161 | 161 | break; // advance |
| 162 | 162 | }, |
| 163 | 163 | 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", .{}); | |
| 165 | 165 | }, |
| 166 | 166 | }, |
| 167 | 167 | .rhs_continuation_linefeed => switch (char) { |
| ... | ... | @@ -170,7 +170,7 @@ pub const Tokenizer = struct { |
| 170 | 170 | break; // advance |
| 171 | 171 | }, |
| 172 | 172 | 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", .{}); | |
| 174 | 174 | }, |
| 175 | 175 | }, |
| 176 | 176 | .prereq_quote => |*prereq| switch (char) { |
| ... | ... | @@ -231,7 +231,7 @@ pub const Tokenizer = struct { |
| 231 | 231 | return Token{ .id = .prereq, .bytes = bytes }; |
| 232 | 232 | }, |
| 233 | 233 | 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", .{}); | |
| 235 | 235 | }, |
| 236 | 236 | }, |
| 237 | 237 | } |
| ... | ... | @@ -249,13 +249,13 @@ pub const Tokenizer = struct { |
| 249 | 249 | .rhs_continuation_linefeed, |
| 250 | 250 | => {}, |
| 251 | 251 | .target => |target| { |
| 252 | return self.errorPosition(idx, target.toSlice(), "incomplete target"); | |
| 252 | return self.errorPosition(idx, target.toSlice(), "incomplete target", .{}); | |
| 253 | 253 | }, |
| 254 | 254 | .target_reverse_solidus, |
| 255 | 255 | .target_dollar_sign, |
| 256 | 256 | => { |
| 257 | 257 | 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", .{}); | |
| 259 | 259 | }, |
| 260 | 260 | .target_colon => |target| { |
| 261 | 261 | const bytes = target.toSlice(); |
| ... | ... | @@ -278,7 +278,7 @@ pub const Tokenizer = struct { |
| 278 | 278 | self.state = State{ .lhs = {} }; |
| 279 | 279 | }, |
| 280 | 280 | .prereq_quote => |prereq| { |
| 281 | return self.errorPosition(idx, prereq.toSlice(), "incomplete quoted prerequisite"); | |
| 281 | return self.errorPosition(idx, prereq.toSlice(), "incomplete quoted prerequisite", .{}); | |
| 282 | 282 | }, |
| 283 | 283 | .prereq => |prereq| { |
| 284 | 284 | const bytes = prereq.toSlice(); |
| ... | ... | @@ -299,29 +299,29 @@ pub const Tokenizer = struct { |
| 299 | 299 | return null; |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | fn errorf(self: *Tokenizer, comptime fmt: []const u8, args: ...) Error { | |
| 302 | fn errorf(self: *Tokenizer, comptime fmt: []const u8, args: var) Error { | |
| 303 | 303 | self.error_text = (try std.Buffer.allocPrint(&self.arena.allocator, fmt, args)).toSlice(); |
| 304 | 304 | return Error.InvalidInput; |
| 305 | 305 | } |
| 306 | 306 | |
| 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 { | |
| 308 | 308 | var buffer = try std.Buffer.initSize(&self.arena.allocator, 0); |
| 309 | 309 | std.fmt.format(&buffer, anyerror, std.Buffer.append, fmt, args) catch {}; |
| 310 | 310 | try buffer.append(" '"); |
| 311 | 311 | var out = makeOutput(std.Buffer.append, &buffer); |
| 312 | 312 | try printCharValues(&out, bytes); |
| 313 | 313 | 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 {}; | |
| 315 | 315 | self.error_text = buffer.toSlice(); |
| 316 | 316 | return Error.InvalidInput; |
| 317 | 317 | } |
| 318 | 318 | |
| 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 { | |
| 320 | 320 | var buffer = try std.Buffer.initSize(&self.arena.allocator, 0); |
| 321 | 321 | try buffer.append("illegal char "); |
| 322 | 322 | var out = makeOutput(std.Buffer.append, &buffer); |
| 323 | 323 | 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 {}; | |
| 325 | 325 | if (fmt.len != 0) std.fmt.format(&buffer, anyerror, std.Buffer.append, ": " ++ fmt, args) catch {}; |
| 326 | 326 | self.error_text = buffer.toSlice(); |
| 327 | 327 | return Error.InvalidInput; |
| ... | ... | @@ -998,7 +998,7 @@ fn printCharValues(out: var, bytes: []const u8) !void { |
| 998 | 998 | |
| 999 | 999 | fn printUnderstandableChar(out: var, char: u8) !void { |
| 1000 | 1000 | 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 {}; | |
| 1002 | 1002 | } else { |
| 1003 | 1003 | try out.write("'"); |
| 1004 | 1004 | try out.write(&[_]u8{printable_char_tab[char]}); |
src-self-hosted/errmsg.zig+5-7| ... | ... | @@ -231,7 +231,7 @@ pub const Msg = struct { |
| 231 | 231 | pub fn printToStream(msg: *const Msg, stream: var, color_on: bool) !void { |
| 232 | 232 | switch (msg.data) { |
| 233 | 233 | .Cli => { |
| 234 | try stream.print("{}:-:-: error: {}\n", msg.realpath, msg.text); | |
| 234 | try stream.print("{}:-:-: error: {}\n", .{ msg.realpath, msg.text }); | |
| 235 | 235 | return; |
| 236 | 236 | }, |
| 237 | 237 | else => {}, |
| ... | ... | @@ -254,24 +254,22 @@ pub const Msg = struct { |
| 254 | 254 | const start_loc = tree.tokenLocationPtr(0, first_token); |
| 255 | 255 | const end_loc = tree.tokenLocationPtr(first_token.end, last_token); |
| 256 | 256 | if (!color_on) { |
| 257 | try stream.print( | |
| 258 | "{}:{}:{}: error: {}\n", | |
| 257 | try stream.print("{}:{}:{}: error: {}\n", .{ | |
| 259 | 258 | path, |
| 260 | 259 | start_loc.line + 1, |
| 261 | 260 | start_loc.column + 1, |
| 262 | 261 | msg.text, |
| 263 | ); | |
| 262 | }); | |
| 264 | 263 | return; |
| 265 | 264 | } |
| 266 | 265 | |
| 267 | try stream.print( | |
| 268 | "{}:{}:{}: error: {}\n{}\n", | |
| 266 | try stream.print("{}:{}:{}: error: {}\n{}\n", .{ | |
| 269 | 267 | path, |
| 270 | 268 | start_loc.line + 1, |
| 271 | 269 | start_loc.column + 1, |
| 272 | 270 | msg.text, |
| 273 | 271 | tree.source[start_loc.line_start..start_loc.line_end], |
| 274 | ); | |
| 272 | }); | |
| 275 | 273 | try stream.writeByteNTimes(' ', start_loc.column); |
| 276 | 274 | try stream.writeByteNTimes('~', last_token.end - first_token.start); |
| 277 | 275 | try stream.write("\n"); |
src-self-hosted/introspect.zig+1-1| ... | ... | @@ -48,7 +48,7 @@ pub fn resolveZigLibDir(allocator: *mem.Allocator) ![]u8 { |
| 48 | 48 | \\Unable to find zig lib directory: {}. |
| 49 | 49 | \\Reinstall Zig or use --zig-install-prefix. |
| 50 | 50 | \\ |
| 51 | , @errorName(err)); | |
| 51 | , .{@errorName(err)}); | |
| 52 | 52 | |
| 53 | 53 | return error.ZigLibDirNotFound; |
| 54 | 54 | }; |
src-self-hosted/ir.zig+38-40| ... | ... | @@ -32,16 +32,16 @@ pub const IrVal = union(enum) { |
| 32 | 32 | |
| 33 | 33 | pub fn dump(self: IrVal) void { |
| 34 | 34 | switch (self) { |
| 35 | .Unknown => std.debug.warn("Unknown"), | |
| 35 | .Unknown => std.debug.warn("Unknown", .{}), | |
| 36 | 36 | .KnownType => |typ| { |
| 37 | std.debug.warn("KnownType("); | |
| 37 | std.debug.warn("KnownType(", .{}); | |
| 38 | 38 | typ.dump(); |
| 39 | std.debug.warn(")"); | |
| 39 | std.debug.warn(")", .{}); | |
| 40 | 40 | }, |
| 41 | 41 | .KnownValue => |value| { |
| 42 | std.debug.warn("KnownValue("); | |
| 42 | std.debug.warn("KnownValue(", .{}); | |
| 43 | 43 | value.dump(); |
| 44 | std.debug.warn(")"); | |
| 44 | std.debug.warn(")", .{}); | |
| 45 | 45 | }, |
| 46 | 46 | } |
| 47 | 47 | } |
| ... | ... | @@ -90,9 +90,9 @@ pub const Inst = struct { |
| 90 | 90 | inline while (i < @memberCount(Id)) : (i += 1) { |
| 91 | 91 | if (base.id == @field(Id, @memberName(Id, i))) { |
| 92 | 92 | 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) }); | |
| 94 | 94 | @fieldParentPtr(T, "base", base).dump(); |
| 95 | std.debug.warn(")"); | |
| 95 | std.debug.warn(")", .{}); | |
| 96 | 96 | return; |
| 97 | 97 | } |
| 98 | 98 | } |
| ... | ... | @@ -173,7 +173,7 @@ pub const Inst = struct { |
| 173 | 173 | if (self.isCompTime()) { |
| 174 | 174 | return self.val.KnownValue; |
| 175 | 175 | } else { |
| 176 | try ira.addCompileError(self.span, "unable to evaluate constant expression"); | |
| 176 | try ira.addCompileError(self.span, "unable to evaluate constant expression", .{}); | |
| 177 | 177 | return error.SemanticAnalysisFailed; |
| 178 | 178 | } |
| 179 | 179 | } |
| ... | ... | @@ -269,11 +269,11 @@ pub const Inst = struct { |
| 269 | 269 | const ir_val_init = IrVal.Init.Unknown; |
| 270 | 270 | |
| 271 | 271 | 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}); | |
| 273 | 273 | for (self.params.args) |arg| { |
| 274 | std.debug.warn("#{},", arg.debug_id); | |
| 274 | std.debug.warn("#{},", .{arg.debug_id}); | |
| 275 | 275 | } |
| 276 | std.debug.warn(")"); | |
| 276 | std.debug.warn(")", .{}); | |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | pub fn hasSideEffects(self: *const Call) bool { |
| ... | ... | @@ -284,19 +284,17 @@ pub const Inst = struct { |
| 284 | 284 | const fn_ref = try self.params.fn_ref.getAsParam(); |
| 285 | 285 | const fn_ref_type = fn_ref.getKnownType(); |
| 286 | 286 | 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}); | |
| 288 | 288 | return error.SemanticAnalysisFailed; |
| 289 | 289 | }; |
| 290 | 290 | |
| 291 | 291 | const fn_type_param_count = fn_type.paramCount(); |
| 292 | 292 | |
| 293 | 293 | 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 {}", .{ | |
| 297 | 295 | fn_type_param_count, |
| 298 | 296 | self.params.args.len, |
| 299 | ); | |
| 297 | }); | |
| 300 | 298 | return error.SemanticAnalysisFailed; |
| 301 | 299 | } |
| 302 | 300 | |
| ... | ... | @@ -375,7 +373,7 @@ pub const Inst = struct { |
| 375 | 373 | const ir_val_init = IrVal.Init.NoReturn; |
| 376 | 374 | |
| 377 | 375 | 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}); | |
| 379 | 377 | } |
| 380 | 378 | |
| 381 | 379 | pub fn hasSideEffects(self: *const Return) bool { |
| ... | ... | @@ -509,7 +507,7 @@ pub const Inst = struct { |
| 509 | 507 | const ir_val_init = IrVal.Init.Unknown; |
| 510 | 508 | |
| 511 | 509 | 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}); | |
| 513 | 511 | } |
| 514 | 512 | |
| 515 | 513 | pub fn hasSideEffects(inst: *const VarPtr) bool { |
| ... | ... | @@ -567,7 +565,7 @@ pub const Inst = struct { |
| 567 | 565 | const target = try self.params.target.getAsParam(); |
| 568 | 566 | const target_type = target.getKnownType(); |
| 569 | 567 | 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}); | |
| 571 | 569 | return error.SemanticAnalysisFailed; |
| 572 | 570 | } |
| 573 | 571 | const ptr_type = @fieldParentPtr(Type.Pointer, "base", target_type); |
| ... | ... | @@ -705,7 +703,7 @@ pub const Inst = struct { |
| 705 | 703 | const ir_val_init = IrVal.Init.Unknown; |
| 706 | 704 | |
| 707 | 705 | 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}); | |
| 709 | 707 | } |
| 710 | 708 | |
| 711 | 709 | pub fn hasSideEffects(inst: *const CheckVoidStmt) bool { |
| ... | ... | @@ -715,7 +713,7 @@ pub const Inst = struct { |
| 715 | 713 | pub fn analyze(self: *const CheckVoidStmt, ira: *Analyze) !*Inst { |
| 716 | 714 | const target = try self.params.target.getAsParam(); |
| 717 | 715 | 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", .{}); | |
| 719 | 717 | return error.SemanticAnalysisFailed; |
| 720 | 718 | } |
| 721 | 719 | return ira.irb.buildConstVoid(self.base.scope, self.base.span, true); |
| ... | ... | @@ -801,7 +799,7 @@ pub const Inst = struct { |
| 801 | 799 | const ir_val_init = IrVal.Init.Unknown; |
| 802 | 800 | |
| 803 | 801 | 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}); | |
| 805 | 803 | } |
| 806 | 804 | |
| 807 | 805 | pub fn hasSideEffects(inst: *const AddImplicitReturnType) bool { |
| ... | ... | @@ -826,7 +824,7 @@ pub const Inst = struct { |
| 826 | 824 | const ir_val_init = IrVal.Init.Unknown; |
| 827 | 825 | |
| 828 | 826 | 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}); | |
| 830 | 828 | } |
| 831 | 829 | |
| 832 | 830 | pub fn hasSideEffects(inst: *const TestErr) bool { |
| ... | ... | @@ -888,7 +886,7 @@ pub const Inst = struct { |
| 888 | 886 | const ir_val_init = IrVal.Init.Unknown; |
| 889 | 887 | |
| 890 | 888 | 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}); | |
| 892 | 890 | } |
| 893 | 891 | |
| 894 | 892 | pub fn hasSideEffects(inst: *const TestCompTime) bool { |
| ... | ... | @@ -971,11 +969,11 @@ pub const Code = struct { |
| 971 | 969 | pub fn dump(self: *Code) void { |
| 972 | 970 | var bb_i: usize = 0; |
| 973 | 971 | 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 }); | |
| 975 | 973 | for (bb.instruction_list.toSliceConst()) |instr| { |
| 976 | std.debug.warn(" "); | |
| 974 | std.debug.warn(" ", .{}); | |
| 977 | 975 | instr.dump(); |
| 978 | std.debug.warn("\n"); | |
| 976 | std.debug.warn("\n", .{}); | |
| 979 | 977 | } |
| 980 | 978 | } |
| 981 | 979 | } |
| ... | ... | @@ -993,6 +991,7 @@ pub const Code = struct { |
| 993 | 991 | self.tree_scope, |
| 994 | 992 | ret_value.span, |
| 995 | 993 | "unable to evaluate constant expression", |
| 994 | .{}, | |
| 996 | 995 | ); |
| 997 | 996 | return error.SemanticAnalysisFailed; |
| 998 | 997 | } else if (inst.hasSideEffects()) { |
| ... | ... | @@ -1000,6 +999,7 @@ pub const Code = struct { |
| 1000 | 999 | self.tree_scope, |
| 1001 | 1000 | inst.span, |
| 1002 | 1001 | "unable to evaluate constant expression", |
| 1002 | .{}, | |
| 1003 | 1003 | ); |
| 1004 | 1004 | return error.SemanticAnalysisFailed; |
| 1005 | 1005 | } |
| ... | ... | @@ -1359,7 +1359,7 @@ pub const Builder = struct { |
| 1359 | 1359 | irb.code.tree_scope, |
| 1360 | 1360 | src_span, |
| 1361 | 1361 | "invalid character in string literal: '{c}'", |
| 1362 | str_token[bad_index], | |
| 1362 | .{str_token[bad_index]}, | |
| 1363 | 1363 | ); |
| 1364 | 1364 | return error.SemanticAnalysisFailed; |
| 1365 | 1365 | }, |
| ... | ... | @@ -1523,6 +1523,7 @@ pub const Builder = struct { |
| 1523 | 1523 | irb.code.tree_scope, |
| 1524 | 1524 | src_span, |
| 1525 | 1525 | "return expression outside function definition", |
| 1526 | .{}, | |
| 1526 | 1527 | ); |
| 1527 | 1528 | return error.SemanticAnalysisFailed; |
| 1528 | 1529 | } |
| ... | ... | @@ -1533,6 +1534,7 @@ pub const Builder = struct { |
| 1533 | 1534 | irb.code.tree_scope, |
| 1534 | 1535 | src_span, |
| 1535 | 1536 | "cannot return from defer expression", |
| 1537 | .{}, | |
| 1536 | 1538 | ); |
| 1537 | 1539 | scope_defer_expr.reported_err = true; |
| 1538 | 1540 | } |
| ... | ... | @@ -1629,7 +1631,7 @@ pub const Builder = struct { |
| 1629 | 1631 | } |
| 1630 | 1632 | } else |err| switch (err) { |
| 1631 | 1633 | 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", .{}); | |
| 1633 | 1635 | return error.SemanticAnalysisFailed; |
| 1634 | 1636 | }, |
| 1635 | 1637 | error.OutOfMemory => return error.OutOfMemory, |
| ... | ... | @@ -1663,7 +1665,7 @@ pub const Builder = struct { |
| 1663 | 1665 | // TODO put a variable of same name with invalid type in global scope |
| 1664 | 1666 | // so that future references to this same name will find a variable with an invalid type |
| 1665 | 1667 | |
| 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}); | |
| 1667 | 1669 | return error.SemanticAnalysisFailed; |
| 1668 | 1670 | } |
| 1669 | 1671 | |
| ... | ... | @@ -2008,7 +2010,7 @@ const Analyze = struct { |
| 2008 | 2010 | const next_instruction = ira.parent_basic_block.instruction_list.at(ira.instruction_index); |
| 2009 | 2011 | |
| 2010 | 2012 | if (!next_instruction.is_generated) { |
| 2011 | try ira.addCompileError(next_instruction.span, "unreachable code"); | |
| 2013 | try ira.addCompileError(next_instruction.span, "unreachable code", .{}); | |
| 2012 | 2014 | break; |
| 2013 | 2015 | } |
| 2014 | 2016 | ira.instruction_index += 1; |
| ... | ... | @@ -2041,7 +2043,7 @@ const Analyze = struct { |
| 2041 | 2043 | } |
| 2042 | 2044 | } |
| 2043 | 2045 | |
| 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 { | |
| 2045 | 2047 | return self.irb.comp.addCompileError(self.irb.code.tree_scope, span, fmt, args); |
| 2046 | 2048 | } |
| 2047 | 2049 | |
| ... | ... | @@ -2330,12 +2332,10 @@ const Analyze = struct { |
| 2330 | 2332 | break :cast; |
| 2331 | 2333 | }; |
| 2332 | 2334 | 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 '{}'", .{ | |
| 2336 | 2336 | from_int, |
| 2337 | 2337 | dest_type.name, |
| 2338 | ); | |
| 2338 | }); | |
| 2339 | 2339 | return error.SemanticAnalysisFailed; |
| 2340 | 2340 | } |
| 2341 | 2341 | |
| ... | ... | @@ -2498,12 +2498,10 @@ const Analyze = struct { |
| 2498 | 2498 | // } |
| 2499 | 2499 | //} |
| 2500 | 2500 | |
| 2501 | try ira.addCompileError( | |
| 2502 | source_instr.span, | |
| 2503 | "expected type '{}', found '{}'", | |
| 2501 | try ira.addCompileError(source_instr.span, "expected type '{}', found '{}'", .{ | |
| 2504 | 2502 | dest_type.name, |
| 2505 | 2503 | from_type.name, |
| 2506 | ); | |
| 2504 | }); | |
| 2507 | 2505 | //ErrorMsg *parent_msg = ir_add_error_node(ira, source_instr->source_node, |
| 2508 | 2506 | // buf_sprintf("expected type '%s', found '%s'", |
| 2509 | 2507 | // buf_ptr(&wanted_type->name), |
src-self-hosted/libc_installation.zig+13-15| ... | ... | @@ -65,7 +65,7 @@ pub const LibCInstallation = struct { |
| 65 | 65 | if (line.len == 0 or line[0] == '#') continue; |
| 66 | 66 | var line_it = std.mem.separate(line, "="); |
| 67 | 67 | 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", .{}); | |
| 69 | 69 | return error.ParseError; |
| 70 | 70 | }; |
| 71 | 71 | const value = line_it.rest(); |
| ... | ... | @@ -83,7 +83,7 @@ pub const LibCInstallation = struct { |
| 83 | 83 | }, |
| 84 | 84 | else => { |
| 85 | 85 | if (value.len == 0) { |
| 86 | try stderr.print("field cannot be empty: {}\n", key); | |
| 86 | try stderr.print("field cannot be empty: {}\n", .{key}); | |
| 87 | 87 | return error.ParseError; |
| 88 | 88 | } |
| 89 | 89 | const dupe = try std.mem.dupe(allocator, u8, value); |
| ... | ... | @@ -97,7 +97,7 @@ pub const LibCInstallation = struct { |
| 97 | 97 | } |
| 98 | 98 | for (found_keys) |found_key, i| { |
| 99 | 99 | if (!found_key.found) { |
| 100 | try stderr.print("missing field: {}\n", keys[i]); | |
| 100 | try stderr.print("missing field: {}\n", .{keys[i]}); | |
| 101 | 101 | return error.ParseError; |
| 102 | 102 | } |
| 103 | 103 | } |
| ... | ... | @@ -105,6 +105,11 @@ pub const LibCInstallation = struct { |
| 105 | 105 | |
| 106 | 106 | pub fn render(self: *const LibCInstallation, out: *std.io.OutStream(fs.File.WriteError)) !void { |
| 107 | 107 | @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 = {} }); | |
| 108 | 113 | try out.print( |
| 109 | 114 | \\# The directory that contains `stdlib.h`. |
| 110 | 115 | \\# On Linux, can be found with: `cc -E -Wp,-v -xc /dev/null` |
| ... | ... | @@ -132,14 +137,7 @@ pub const LibCInstallation = struct { |
| 132 | 137 | \\# Only needed when targeting Linux. |
| 133 | 138 | \\dynamic_linker_path={} |
| 134 | 139 | \\ |
| 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 }); | |
| 143 | 141 | } |
| 144 | 142 | |
| 145 | 143 | /// Finds the default, native libc. |
| ... | ... | @@ -255,7 +253,7 @@ pub const LibCInstallation = struct { |
| 255 | 253 | for (searches) |search| { |
| 256 | 254 | result_buf.shrink(0); |
| 257 | 255 | 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 }); | |
| 259 | 257 | |
| 260 | 258 | const stdlib_path = try fs.path.join( |
| 261 | 259 | allocator, |
| ... | ... | @@ -282,7 +280,7 @@ pub const LibCInstallation = struct { |
| 282 | 280 | for (searches) |search| { |
| 283 | 281 | result_buf.shrink(0); |
| 284 | 282 | 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 }); | |
| 286 | 284 | switch (builtin.arch) { |
| 287 | 285 | .i386 => try stream.write("x86"), |
| 288 | 286 | .x86_64 => try stream.write("x64"), |
| ... | ... | @@ -360,7 +358,7 @@ pub const LibCInstallation = struct { |
| 360 | 358 | for (searches) |search| { |
| 361 | 359 | result_buf.shrink(0); |
| 362 | 360 | 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 }); | |
| 364 | 362 | switch (builtin.arch) { |
| 365 | 363 | .i386 => try stream.write("x86\\"), |
| 366 | 364 | .x86_64 => try stream.write("x64\\"), |
| ... | ... | @@ -395,7 +393,7 @@ pub const LibCInstallation = struct { |
| 395 | 393 | /// caller owns returned memory |
| 396 | 394 | fn ccPrintFileName(allocator: *Allocator, o_file: []const u8, want_dirname: bool) ![]u8 { |
| 397 | 395 | 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}); | |
| 399 | 397 | defer allocator.free(arg1); |
| 400 | 398 | const argv = [_][]const u8{ cc_exe, arg1 }; |
| 401 | 399 |
src-self-hosted/link.zig+20-13| ... | ... | @@ -75,9 +75,9 @@ pub fn link(comp: *Compilation) !void { |
| 75 | 75 | if (comp.verbose_link) { |
| 76 | 76 | for (ctx.args.toSliceConst()) |arg, i| { |
| 77 | 77 | const space = if (i == 0) "" else " "; |
| 78 | std.debug.warn("{}{s}", space, arg); | |
| 78 | std.debug.warn("{}{s}", .{ space, arg }); | |
| 79 | 79 | } |
| 80 | std.debug.warn("\n"); | |
| 80 | std.debug.warn("\n", .{}); | |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | const extern_ofmt = toExternObjectFormatType(util.getObjectFormat(comp.target)); |
| ... | ... | @@ -94,7 +94,7 @@ pub fn link(comp: *Compilation) !void { |
| 94 | 94 | // TODO capture these messages and pass them through the system, reporting them through the |
| 95 | 95 | // event system instead of printing them directly here. |
| 96 | 96 | // 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()}); | |
| 98 | 98 | } |
| 99 | 99 | return error.LinkFailed; |
| 100 | 100 | } |
| ... | ... | @@ -334,13 +334,13 @@ fn constructLinkerArgsCoff(ctx: *Context) !void { |
| 334 | 334 | |
| 335 | 335 | const is_library = ctx.comp.kind == .Lib; |
| 336 | 336 | |
| 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()}); | |
| 338 | 338 | try ctx.args.append(@ptrCast([*:0]const u8, out_arg.ptr)); |
| 339 | 339 | |
| 340 | 340 | 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)); | |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | if (ctx.link_in_crt) { |
| ... | ... | @@ -348,17 +348,20 @@ fn constructLinkerArgsCoff(ctx: *Context) !void { |
| 348 | 348 | const d_str = if (ctx.comp.build_mode == .Debug) "d" else ""; |
| 349 | 349 | |
| 350 | 350 | 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}); | |
| 352 | 352 | try ctx.args.append(@ptrCast([*:0]const u8, cmt_lib_name.ptr)); |
| 353 | 353 | } 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}); | |
| 355 | 355 | try ctx.args.append(@ptrCast([*:0]const u8, msvcrt_lib_name.ptr)); |
| 356 | 356 | } |
| 357 | 357 | |
| 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 | }); | |
| 359 | 362 | try ctx.args.append(@ptrCast([*:0]const u8, vcruntime_lib_name.ptr)); |
| 360 | 363 | |
| 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 }); | |
| 362 | 365 | try ctx.args.append(@ptrCast([*:0]const u8, crt_lib_name.ptr)); |
| 363 | 366 | |
| 364 | 367 | // Visual C++ 2015 Conformance Changes |
| ... | ... | @@ -508,7 +511,11 @@ fn constructLinkerArgsMachO(ctx: *Context) !void { |
| 508 | 511 | .IPhoneOS => try ctx.args.append("-iphoneos_version_min"), |
| 509 | 512 | .IPhoneOSSimulator => try ctx.args.append("-ios_simulator_version_min"), |
| 510 | 513 | } |
| 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 | }); | |
| 512 | 519 | try ctx.args.append(@ptrCast([*:0]const u8, ver_str.ptr)); |
| 513 | 520 | |
| 514 | 521 | if (ctx.comp.kind == .Exe) { |
| ... | ... | @@ -584,7 +591,7 @@ fn constructLinkerArgsMachO(ctx: *Context) !void { |
| 584 | 591 | try ctx.args.append("-lSystem"); |
| 585 | 592 | } else { |
| 586 | 593 | 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}); | |
| 588 | 595 | try ctx.args.append(@ptrCast([*:0]const u8, arg.ptr)); |
| 589 | 596 | } else { |
| 590 | 597 | 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 { |
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | try stderr.print("unknown command: {}\n\n", args[1]); | |
| 131 | try stderr.print("unknown command: {}\n\n", .{args[1]}); | |
| 132 | 132 | try stderr.write(usage); |
| 133 | 133 | process.argsFree(allocator, args); |
| 134 | 134 | process.exit(1); |
| ... | ... | @@ -329,14 +329,14 @@ fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Co |
| 329 | 329 | if (cur_pkg.parent) |parent| { |
| 330 | 330 | cur_pkg = parent; |
| 331 | 331 | } 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", .{}); | |
| 333 | 333 | process.exit(1); |
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | if (cur_pkg.parent != null) { |
| 339 | try stderr.print("unmatched --pkg-begin\n"); | |
| 339 | try stderr.print("unmatched --pkg-begin\n", .{}); | |
| 340 | 340 | process.exit(1); |
| 341 | 341 | } |
| 342 | 342 | |
| ... | ... | @@ -345,7 +345,7 @@ fn buildOutputType(allocator: *Allocator, args: []const []const u8, out_type: Co |
| 345 | 345 | 0 => null, |
| 346 | 346 | 1 => flags.positionals.at(0), |
| 347 | 347 | 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)}); | |
| 349 | 349 | process.exit(1); |
| 350 | 350 | }, |
| 351 | 351 | }; |
| ... | ... | @@ -477,13 +477,13 @@ fn processBuildEvents(comp: *Compilation, color: errmsg.Color) void { |
| 477 | 477 | |
| 478 | 478 | switch (build_event) { |
| 479 | 479 | .Ok => { |
| 480 | stderr.print("Build {} succeeded\n", count) catch process.exit(1); | |
| 480 | stderr.print("Build {} succeeded\n", .{count}) catch process.exit(1); | |
| 481 | 481 | }, |
| 482 | 482 | .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); | |
| 484 | 484 | }, |
| 485 | 485 | .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); | |
| 487 | 487 | for (msgs) |msg| { |
| 488 | 488 | defer msg.destroy(); |
| 489 | 489 | msg.printToFile(stderr_file, color) catch process.exit(1); |
| ... | ... | @@ -544,12 +544,11 @@ const Fmt = struct { |
| 544 | 544 | |
| 545 | 545 | fn parseLibcPaths(allocator: *Allocator, libc: *LibCInstallation, libc_paths_file: []const u8) void { |
| 546 | 546 | 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", .{ | |
| 550 | 549 | libc_paths_file, |
| 551 | 550 | @errorName(err), |
| 552 | ) catch {}; | |
| 551 | }) catch {}; | |
| 553 | 552 | process.exit(1); |
| 554 | 553 | }; |
| 555 | 554 | } |
| ... | ... | @@ -563,7 +562,7 @@ fn cmdLibC(allocator: *Allocator, args: []const []const u8) !void { |
| 563 | 562 | return; |
| 564 | 563 | }, |
| 565 | 564 | else => { |
| 566 | try stderr.print("unexpected extra parameter: {}\n", args[1]); | |
| 565 | try stderr.print("unexpected extra parameter: {}\n", .{args[1]}); | |
| 567 | 566 | process.exit(1); |
| 568 | 567 | }, |
| 569 | 568 | } |
| ... | ... | @@ -572,7 +571,7 @@ fn cmdLibC(allocator: *Allocator, args: []const []const u8) !void { |
| 572 | 571 | defer zig_compiler.deinit(); |
| 573 | 572 | |
| 574 | 573 | 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 {}; | |
| 576 | 575 | process.exit(1); |
| 577 | 576 | }; |
| 578 | 577 | libc.render(stdout) catch process.exit(1); |
| ... | ... | @@ -614,7 +613,7 @@ fn cmdFmt(allocator: *Allocator, args: []const []const u8) !void { |
| 614 | 613 | defer allocator.free(source_code); |
| 615 | 614 | |
| 616 | 615 | 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}); | |
| 618 | 617 | process.exit(1); |
| 619 | 618 | }; |
| 620 | 619 | defer tree.deinit(); |
| ... | ... | @@ -718,7 +717,7 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtErro |
| 718 | 717 | }, |
| 719 | 718 | else => { |
| 720 | 719 | // 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 }); | |
| 722 | 721 | fmt.any_error = true; |
| 723 | 722 | return; |
| 724 | 723 | }, |
| ... | ... | @@ -726,7 +725,7 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtErro |
| 726 | 725 | defer fmt.allocator.free(source_code); |
| 727 | 726 | |
| 728 | 727 | 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 }); | |
| 730 | 729 | fmt.any_error = true; |
| 731 | 730 | return; |
| 732 | 731 | }; |
| ... | ... | @@ -747,7 +746,7 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtErro |
| 747 | 746 | if (check_mode) { |
| 748 | 747 | const anything_changed = try std.zig.render(fmt.allocator, io.null_out_stream, tree); |
| 749 | 748 | if (anything_changed) { |
| 750 | try stderr.print("{}\n", file_path); | |
| 749 | try stderr.print("{}\n", .{file_path}); | |
| 751 | 750 | fmt.any_error = true; |
| 752 | 751 | } |
| 753 | 752 | } else { |
| ... | ... | @@ -757,7 +756,7 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtErro |
| 757 | 756 | |
| 758 | 757 | const anything_changed = try std.zig.render(fmt.allocator, baf.stream(), tree); |
| 759 | 758 | if (anything_changed) { |
| 760 | try stderr.print("{}\n", file_path); | |
| 759 | try stderr.print("{}\n", .{file_path}); | |
| 761 | 760 | try baf.finish(); |
| 762 | 761 | } |
| 763 | 762 | } |
| ... | ... | @@ -774,7 +773,7 @@ fn cmdTargets(allocator: *Allocator, args: []const []const u8) !void { |
| 774 | 773 | // NOTE: Cannot use empty string, see #918. |
| 775 | 774 | comptime const native_str = if (comptime mem.eql(u8, arch_tag, @tagName(builtin.arch))) " (native)\n" else "\n"; |
| 776 | 775 | |
| 777 | try stdout.print(" {}{}", arch_tag, native_str); | |
| 776 | try stdout.print(" {}{}", .{ arch_tag, native_str }); | |
| 778 | 777 | } |
| 779 | 778 | } |
| 780 | 779 | try stdout.write("\n"); |
| ... | ... | @@ -787,7 +786,7 @@ fn cmdTargets(allocator: *Allocator, args: []const []const u8) !void { |
| 787 | 786 | // NOTE: Cannot use empty string, see #918. |
| 788 | 787 | comptime const native_str = if (comptime mem.eql(u8, os_tag, @tagName(builtin.os))) " (native)\n" else "\n"; |
| 789 | 788 | |
| 790 | try stdout.print(" {}{}", os_tag, native_str); | |
| 789 | try stdout.print(" {}{}", .{ os_tag, native_str }); | |
| 791 | 790 | } |
| 792 | 791 | } |
| 793 | 792 | try stdout.write("\n"); |
| ... | ... | @@ -800,13 +799,13 @@ fn cmdTargets(allocator: *Allocator, args: []const []const u8) !void { |
| 800 | 799 | // NOTE: Cannot use empty string, see #918. |
| 801 | 800 | comptime const native_str = if (comptime mem.eql(u8, abi_tag, @tagName(builtin.abi))) " (native)\n" else "\n"; |
| 802 | 801 | |
| 803 | try stdout.print(" {}{}", abi_tag, native_str); | |
| 802 | try stdout.print(" {}{}", .{ abi_tag, native_str }); | |
| 804 | 803 | } |
| 805 | 804 | } |
| 806 | 805 | } |
| 807 | 806 | |
| 808 | 807 | fn 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)}); | |
| 810 | 809 | } |
| 811 | 810 | |
| 812 | 811 | const args_test_spec = [_]Flag{Flag.Bool("--help")}; |
| ... | ... | @@ -865,7 +864,7 @@ fn cmdInternal(allocator: *Allocator, args: []const []const u8) !void { |
| 865 | 864 | } |
| 866 | 865 | } |
| 867 | 866 | |
| 868 | try stderr.print("unknown sub command: {}\n\n", args[0]); | |
| 867 | try stderr.print("unknown sub command: {}\n\n", .{args[0]}); | |
| 869 | 868 | try stderr.write(usage_internal); |
| 870 | 869 | } |
| 871 | 870 | |
| ... | ... | @@ -878,14 +877,14 @@ fn cmdInternalBuildInfo(allocator: *Allocator, args: []const []const u8) !void { |
| 878 | 877 | \\ZIG_LLVM_CONFIG_EXE {} |
| 879 | 878 | \\ZIG_DIA_GUIDS_LIB {} |
| 880 | 879 | \\ |
| 881 | , | |
| 880 | , .{ | |
| 882 | 881 | std.mem.toSliceConst(u8, c.ZIG_CMAKE_BINARY_DIR), |
| 883 | 882 | std.mem.toSliceConst(u8, c.ZIG_CXX_COMPILER), |
| 884 | 883 | std.mem.toSliceConst(u8, c.ZIG_LLD_INCLUDE_PATH), |
| 885 | 884 | std.mem.toSliceConst(u8, c.ZIG_LLD_LIBRARIES), |
| 886 | 885 | std.mem.toSliceConst(u8, c.ZIG_LLVM_CONFIG_EXE), |
| 887 | 886 | std.mem.toSliceConst(u8, c.ZIG_DIA_GUIDS_LIB), |
| 888 | ); | |
| 887 | }); | |
| 889 | 888 | } |
| 890 | 889 | |
| 891 | 890 | const 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 { |
| 149 | 149 | fmtMain(argc, argv) catch unreachable; |
| 150 | 150 | } else { |
| 151 | 151 | fmtMain(argc, argv) catch |e| { |
| 152 | std.debug.warn("{}\n", @errorName(e)); | |
| 152 | std.debug.warn("{}\n", .{@errorName(e)}); | |
| 153 | 153 | return -1; |
| 154 | 154 | }; |
| 155 | 155 | } |
| ... | ... | @@ -205,7 +205,7 @@ fn fmtMain(argc: c_int, argv: [*]const [*:0]const u8) !void { |
| 205 | 205 | defer allocator.free(source_code); |
| 206 | 206 | |
| 207 | 207 | 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}); | |
| 209 | 209 | process.exit(1); |
| 210 | 210 | }; |
| 211 | 211 | defer tree.deinit(); |
| ... | ... | @@ -294,7 +294,7 @@ fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtError!void |
| 294 | 294 | }, |
| 295 | 295 | else => { |
| 296 | 296 | // 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 }); | |
| 298 | 298 | fmt.any_error = true; |
| 299 | 299 | return; |
| 300 | 300 | }, |
| ... | ... | @@ -302,7 +302,7 @@ fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtError!void |
| 302 | 302 | defer fmt.allocator.free(source_code); |
| 303 | 303 | |
| 304 | 304 | 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 }); | |
| 306 | 306 | fmt.any_error = true; |
| 307 | 307 | return; |
| 308 | 308 | }; |
| ... | ... | @@ -320,7 +320,7 @@ fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtError!void |
| 320 | 320 | if (check_mode) { |
| 321 | 321 | const anything_changed = try std.zig.render(fmt.allocator, io.null_out_stream, tree); |
| 322 | 322 | if (anything_changed) { |
| 323 | try stderr.print("{}\n", file_path); | |
| 323 | try stderr.print("{}\n", .{file_path}); | |
| 324 | 324 | fmt.any_error = true; |
| 325 | 325 | } |
| 326 | 326 | } else { |
| ... | ... | @@ -329,7 +329,7 @@ fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtError!void |
| 329 | 329 | |
| 330 | 330 | const anything_changed = try std.zig.render(fmt.allocator, baf.stream(), tree); |
| 331 | 331 | if (anything_changed) { |
| 332 | try stderr.print("{}\n", file_path); | |
| 332 | try stderr.print("{}\n", .{file_path}); | |
| 333 | 333 | try baf.finish(); |
| 334 | 334 | } |
| 335 | 335 | } |
| ... | ... | @@ -374,7 +374,7 @@ fn printErrMsgToFile( |
| 374 | 374 | const text = text_buf.toOwnedSlice(); |
| 375 | 375 | |
| 376 | 376 | 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 }); | |
| 378 | 378 | |
| 379 | 379 | if (!color_on) return; |
| 380 | 380 |
src-self-hosted/translate_c.zig+49-30| ... | ... | @@ -125,7 +125,7 @@ const Context = struct { |
| 125 | 125 | |
| 126 | 126 | const line = ZigClangSourceManager_getSpellingLineNumber(c.source_manager, spelling_loc); |
| 127 | 127 | 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 }); | |
| 129 | 129 | } |
| 130 | 130 | }; |
| 131 | 131 | |
| ... | ... | @@ -228,20 +228,20 @@ fn declVisitor(c: *Context, decl: *const ZigClangDecl) Error!void { |
| 228 | 228 | return visitFnDecl(c, @ptrCast(*const ZigClangFunctionDecl, decl)); |
| 229 | 229 | }, |
| 230 | 230 | .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", .{}); | |
| 232 | 232 | }, |
| 233 | 233 | .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", .{}); | |
| 235 | 235 | }, |
| 236 | 236 | .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", .{}); | |
| 238 | 238 | }, |
| 239 | 239 | .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", .{}); | |
| 241 | 241 | }, |
| 242 | 242 | else => { |
| 243 | 243 | 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}); | |
| 245 | 245 | }, |
| 246 | 246 | } |
| 247 | 247 | } |
| ... | ... | @@ -264,7 +264,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void { |
| 264 | 264 | .is_export = switch (storage_class) { |
| 265 | 265 | .None => has_body and c.mode != .import, |
| 266 | 266 | .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", .{}), | |
| 268 | 268 | .Auto => unreachable, // Not legal on functions |
| 269 | 269 | .Register => unreachable, // Not legal on functions |
| 270 | 270 | }, |
| ... | ... | @@ -274,7 +274,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void { |
| 274 | 274 | const fn_proto_type = @ptrCast(*const ZigClangFunctionProtoType, fn_type); |
| 275 | 275 | break :blk transFnProto(rp, fn_proto_type, fn_decl_loc, decl_ctx, true) catch |err| switch (err) { |
| 276 | 276 | 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", .{}); | |
| 278 | 278 | }, |
| 279 | 279 | error.OutOfMemory => |e| return e, |
| 280 | 280 | }; |
| ... | ... | @@ -283,7 +283,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void { |
| 283 | 283 | const fn_no_proto_type = @ptrCast(*const ZigClangFunctionType, fn_type); |
| 284 | 284 | break :blk transFnNoProto(rp, fn_no_proto_type, fn_decl_loc, decl_ctx, true) catch |err| switch (err) { |
| 285 | 285 | 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", .{}); | |
| 287 | 287 | }, |
| 288 | 288 | error.OutOfMemory => |e| return e, |
| 289 | 289 | }; |
| ... | ... | @@ -302,7 +302,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const ZigClangFunctionDecl) Error!void { |
| 302 | 302 | error.OutOfMemory => |e| return e, |
| 303 | 303 | error.UnsupportedTranslation, |
| 304 | 304 | 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", .{}), | |
| 306 | 306 | }; |
| 307 | 307 | assert(result.node.id == ast.Node.Id.Block); |
| 308 | 308 | proto_node.body_node = result.node; |
| ... | ... | @@ -344,7 +344,7 @@ fn transStmt( |
| 344 | 344 | error.UnsupportedTranslation, |
| 345 | 345 | ZigClangStmt_getBeginLoc(stmt), |
| 346 | 346 | "TODO implement translation of stmt class {}", |
| 347 | @tagName(sc), | |
| 347 | .{@tagName(sc)}, | |
| 348 | 348 | ); |
| 349 | 349 | }, |
| 350 | 350 | } |
| ... | ... | @@ -364,7 +364,7 @@ fn transBinaryOperator( |
| 364 | 364 | error.UnsupportedTranslation, |
| 365 | 365 | ZigClangBinaryOperator_getBeginLoc(stmt), |
| 366 | 366 | "TODO: handle more C binary operators: {}", |
| 367 | op, | |
| 367 | .{op}, | |
| 368 | 368 | ), |
| 369 | 369 | .Assign => return TransResult{ |
| 370 | 370 | .node = &(try transCreateNodeAssign(rp, scope, result_used, ZigClangBinaryOperator_getLHS(stmt), ZigClangBinaryOperator_getRHS(stmt))).base, |
| ... | ... | @@ -415,7 +415,7 @@ fn transBinaryOperator( |
| 415 | 415 | error.UnsupportedTranslation, |
| 416 | 416 | ZigClangBinaryOperator_getBeginLoc(stmt), |
| 417 | 417 | "TODO: handle more C binary operators: {}", |
| 418 | op, | |
| 418 | .{op}, | |
| 419 | 419 | ), |
| 420 | 420 | .MulAssign, |
| 421 | 421 | .DivAssign, |
| ... | ... | @@ -567,7 +567,7 @@ fn transDeclStmt(rp: RestorePoint, parent_scope: *Scope, stmt: *const ZigClangDe |
| 567 | 567 | error.UnsupportedTranslation, |
| 568 | 568 | ZigClangStmt_getBeginLoc(@ptrCast(*const ZigClangStmt, stmt)), |
| 569 | 569 | "TODO implement translation of DeclStmt kind {}", |
| 570 | @tagName(kind), | |
| 570 | .{@tagName(kind)}, | |
| 571 | 571 | ), |
| 572 | 572 | } |
| 573 | 573 | } |
| ... | ... | @@ -636,7 +636,7 @@ fn transImplicitCastExpr( |
| 636 | 636 | error.UnsupportedTranslation, |
| 637 | 637 | ZigClangStmt_getBeginLoc(@ptrCast(*const ZigClangStmt, expr)), |
| 638 | 638 | "TODO implement translation of CastKind {}", |
| 639 | @tagName(kind), | |
| 639 | .{@tagName(kind)}, | |
| 640 | 640 | ), |
| 641 | 641 | } |
| 642 | 642 | } |
| ... | ... | @@ -650,7 +650,7 @@ fn transIntegerLiteral( |
| 650 | 650 | var eval_result: ZigClangExprEvalResult = undefined; |
| 651 | 651 | if (!ZigClangIntegerLiteral_EvaluateAsInt(expr, &eval_result, rp.c.clang_context)) { |
| 652 | 652 | 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", .{}); | |
| 654 | 654 | } |
| 655 | 655 | const node = try transCreateNodeAPInt(rp.c, ZigClangAPValue_getInt(&eval_result.Val)); |
| 656 | 656 | const res = TransResult{ |
| ... | ... | @@ -719,7 +719,7 @@ fn transStringLiteral( |
| 719 | 719 | error.UnsupportedTranslation, |
| 720 | 720 | ZigClangStmt_getBeginLoc(@ptrCast(*const ZigClangStmt, stmt)), |
| 721 | 721 | "TODO: support string literal kind {}", |
| 722 | kind, | |
| 722 | .{kind}, | |
| 723 | 723 | ), |
| 724 | 724 | } |
| 725 | 725 | } |
| ... | ... | @@ -751,7 +751,7 @@ fn escapeChar(c: u8, char_buf: *[4]u8) []const u8 { |
| 751 | 751 | '\n' => return "\\n"[0..], |
| 752 | 752 | '\r' => return "\\r"[0..], |
| 753 | 753 | '\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, | |
| 755 | 755 | }; |
| 756 | 756 | std.mem.copy(u8, char_buf, escaped); |
| 757 | 757 | return char_buf[0..escaped.len]; |
| ... | ... | @@ -1016,7 +1016,13 @@ fn transCreateNodeAssign( |
| 1016 | 1016 | // zig: lhs = _tmp; |
| 1017 | 1017 | // zig: break :x _tmp |
| 1018 | 1018 | // 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 | ); | |
| 1020 | 1026 | } |
| 1021 | 1027 | |
| 1022 | 1028 | fn transCreateNodeBuiltinFnCall(c: *Context, name: []const u8) !*ast.Node.BuiltinCall { |
| ... | ... | @@ -1211,7 +1217,7 @@ fn transType(rp: RestorePoint, ty: *const ZigClangType, source_loc: ZigClangSour |
| 1211 | 1217 | .Float128 => return appendIdentifier(rp.c, "f128"), |
| 1212 | 1218 | .Float16 => return appendIdentifier(rp.c, "f16"), |
| 1213 | 1219 | .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", .{}), | |
| 1215 | 1221 | } |
| 1216 | 1222 | }, |
| 1217 | 1223 | .FunctionProto => { |
| ... | ... | @@ -1253,7 +1259,7 @@ fn transType(rp: RestorePoint, ty: *const ZigClangType, source_loc: ZigClangSour |
| 1253 | 1259 | }, |
| 1254 | 1260 | else => { |
| 1255 | 1261 | 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}); | |
| 1257 | 1263 | }, |
| 1258 | 1264 | } |
| 1259 | 1265 | } |
| ... | ... | @@ -1275,7 +1281,13 @@ fn transCC( |
| 1275 | 1281 | switch (clang_cc) { |
| 1276 | 1282 | .C => return CallingConvention.C, |
| 1277 | 1283 | .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 | ), | |
| 1279 | 1291 | } |
| 1280 | 1292 | } |
| 1281 | 1293 | |
| ... | ... | @@ -1292,7 +1304,13 @@ fn transFnProto( |
| 1292 | 1304 | const param_count: usize = ZigClangFunctionProtoType_getNumParams(fn_proto_ty); |
| 1293 | 1305 | var i: usize = 0; |
| 1294 | 1306 | 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 | ); | |
| 1296 | 1314 | } |
| 1297 | 1315 | |
| 1298 | 1316 | return finishTransFnProto(rp, fn_ty, source_loc, fn_decl_context, is_var_args, cc, is_pub); |
| ... | ... | @@ -1350,7 +1368,7 @@ fn finishTransFnProto( |
| 1350 | 1368 | } else { |
| 1351 | 1369 | break :blk transQualType(rp, return_qt, source_loc) catch |err| switch (err) { |
| 1352 | 1370 | 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", .{}); | |
| 1354 | 1372 | return err; |
| 1355 | 1373 | }, |
| 1356 | 1374 | error.OutOfMemory => |e| return e, |
| ... | ... | @@ -1397,18 +1415,19 @@ fn revertAndWarn( |
| 1397 | 1415 | err: var, |
| 1398 | 1416 | source_loc: ZigClangSourceLocation, |
| 1399 | 1417 | comptime format: []const u8, |
| 1400 | args: ..., | |
| 1418 | args: var, | |
| 1401 | 1419 | ) (@typeOf(err) || error{OutOfMemory}) { |
| 1402 | 1420 | rp.activate(); |
| 1403 | 1421 | try emitWarning(rp.c, source_loc, format, args); |
| 1404 | 1422 | return err; |
| 1405 | 1423 | } |
| 1406 | 1424 | |
| 1407 | fn emitWarning(c: *Context, loc: ZigClangSourceLocation, comptime format: []const u8, args: ...) !void { | |
| 1408 | _ = try appendTokenFmt(c, .LineComment, "// {}: warning: " ++ format, c.locStr(loc), args); | |
| 1425 | fn 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); | |
| 1409 | 1428 | } |
| 1410 | 1429 | |
| 1411 | fn failDecl(c: *Context, loc: ZigClangSourceLocation, name: []const u8, comptime format: []const u8, args: ...) !void { | |
| 1430 | fn failDecl(c: *Context, loc: ZigClangSourceLocation, name: []const u8, comptime format: []const u8, args: var) !void { | |
| 1412 | 1431 | // const name = @compileError(msg); |
| 1413 | 1432 | const const_tok = try appendToken(c, .Keyword_const, "const"); |
| 1414 | 1433 | const name_tok = try appendToken(c, .Identifier, name); |
| ... | ... | @@ -1456,10 +1475,10 @@ fn failDecl(c: *Context, loc: ZigClangSourceLocation, name: []const u8, comptime |
| 1456 | 1475 | } |
| 1457 | 1476 | |
| 1458 | 1477 | fn 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}); | |
| 1460 | 1479 | } |
| 1461 | 1480 | |
| 1462 | fn appendTokenFmt(c: *Context, token_id: Token.Id, comptime format: []const u8, args: ...) !ast.TokenIndex { | |
| 1481 | fn appendTokenFmt(c: *Context, token_id: Token.Id, comptime format: []const u8, args: var) !ast.TokenIndex { | |
| 1463 | 1482 | const S = struct { |
| 1464 | 1483 | fn callback(context: *Context, bytes: []const u8) error{OutOfMemory}!void { |
| 1465 | 1484 | return context.source_buffer.append(bytes); |
src-self-hosted/type.zig+11-15| ... | ... | @@ -399,7 +399,7 @@ pub const Type = struct { |
| 399 | 399 | .Generic => |generic| { |
| 400 | 400 | self.non_key = NonKey{ .Generic = {} }; |
| 401 | 401 | const cc_str = ccFnTypeStr(generic.cc); |
| 402 | try name_stream.print("{}fn(", cc_str); | |
| 402 | try name_stream.print("{}fn(", .{cc_str}); | |
| 403 | 403 | var param_i: usize = 0; |
| 404 | 404 | while (param_i < generic.param_count) : (param_i += 1) { |
| 405 | 405 | const arg = if (param_i == 0) "var" else ", var"; |
| ... | ... | @@ -407,7 +407,7 @@ pub const Type = struct { |
| 407 | 407 | } |
| 408 | 408 | try name_stream.write(")"); |
| 409 | 409 | if (key.alignment) |alignment| { |
| 410 | try name_stream.print(" align({})", alignment); | |
| 410 | try name_stream.print(" align({})", .{alignment}); | |
| 411 | 411 | } |
| 412 | 412 | try name_stream.write(" var"); |
| 413 | 413 | }, |
| ... | ... | @@ -416,7 +416,7 @@ pub const Type = struct { |
| 416 | 416 | .Normal = NonKey.Normal{ .variable_list = std.ArrayList(*Scope.Var).init(comp.gpa()) }, |
| 417 | 417 | }; |
| 418 | 418 | const cc_str = ccFnTypeStr(normal.cc); |
| 419 | try name_stream.print("{}fn(", cc_str); | |
| 419 | try name_stream.print("{}fn(", .{cc_str}); | |
| 420 | 420 | for (normal.params) |param, i| { |
| 421 | 421 | if (i != 0) try name_stream.write(", "); |
| 422 | 422 | if (param.is_noalias) try name_stream.write("noalias "); |
| ... | ... | @@ -428,9 +428,9 @@ pub const Type = struct { |
| 428 | 428 | } |
| 429 | 429 | try name_stream.write(")"); |
| 430 | 430 | if (key.alignment) |alignment| { |
| 431 | try name_stream.print(" align({})", alignment); | |
| 431 | try name_stream.print(" align({})", .{alignment}); | |
| 432 | 432 | } |
| 433 | try name_stream.print(" {}", normal.return_type.name); | |
| 433 | try name_stream.print(" {}", .{normal.return_type.name}); | |
| 434 | 434 | }, |
| 435 | 435 | } |
| 436 | 436 | |
| ... | ... | @@ -584,7 +584,7 @@ pub const Type = struct { |
| 584 | 584 | errdefer comp.gpa().destroy(self); |
| 585 | 585 | |
| 586 | 586 | 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 }); | |
| 588 | 588 | errdefer comp.gpa().free(name); |
| 589 | 589 | |
| 590 | 590 | self.base.init(comp, .Int, name); |
| ... | ... | @@ -767,23 +767,19 @@ pub const Type = struct { |
| 767 | 767 | .Non => "", |
| 768 | 768 | }; |
| 769 | 769 | const name = switch (self.key.alignment) { |
| 770 | .Abi => try std.fmt.allocPrint( | |
| 771 | comp.gpa(), | |
| 772 | "{}{}{}{}", | |
| 770 | .Abi => try std.fmt.allocPrint(comp.gpa(), "{}{}{}{}", .{ | |
| 773 | 771 | size_str, |
| 774 | 772 | mut_str, |
| 775 | 773 | vol_str, |
| 776 | 774 | 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<{}> {}{}{}", .{ | |
| 781 | 777 | size_str, |
| 782 | 778 | alignment, |
| 783 | 779 | mut_str, |
| 784 | 780 | vol_str, |
| 785 | 781 | self.key.child_type.name, |
| 786 | ), | |
| 782 | }), | |
| 787 | 783 | }; |
| 788 | 784 | errdefer comp.gpa().free(name); |
| 789 | 785 | |
| ... | ... | @@ -852,7 +848,7 @@ pub const Type = struct { |
| 852 | 848 | }; |
| 853 | 849 | errdefer comp.gpa().destroy(self); |
| 854 | 850 | |
| 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 }); | |
| 856 | 852 | errdefer comp.gpa().free(name); |
| 857 | 853 | |
| 858 | 854 | 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 { |
| 175 | 175 | var result: *llvm.Target = undefined; |
| 176 | 176 | var err_msg: [*:0]u8 = undefined; |
| 177 | 177 | 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 }); | |
| 179 | 179 | return error.UnsupportedTarget; |
| 180 | 180 | } |
| 181 | 181 | return result; |
| ... | ... | @@ -206,7 +206,7 @@ pub fn getTriple(allocator: *std.mem.Allocator, self: std.Target) !std.Buffer { |
| 206 | 206 | const env_name = if (self.isWasm()) "wasm" else @tagName(self.getAbi()); |
| 207 | 207 | |
| 208 | 208 | 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 }); | |
| 210 | 210 | |
| 211 | 211 | return result; |
| 212 | 212 | } |
src-self-hosted/value.zig+1-1| ... | ... | @@ -53,7 +53,7 @@ pub const Value = struct { |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | pub fn dump(base: *const Value) void { |
| 56 | std.debug.warn("{}", @tagName(base.id)); | |
| 56 | std.debug.warn("{}", .{@tagName(base.id)}); | |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | 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 |
| 17025 | 17025 | { |
| 17026 | 17026 | result_loc_pass1 = no_result_loc(); |
| 17027 | 17027 | } |
| 17028 | bool was_written = result_loc_pass1->written; | |
| 17028 | bool was_already_resolved = result_loc_pass1->resolved_loc != nullptr; | |
| 17029 | 17029 | IrInstruction *result_loc = ir_resolve_result_raw(ira, suspend_source_instr, result_loc_pass1, value_type, |
| 17030 | 17030 | value, force_runtime, non_null_comptime, allow_discard); |
| 17031 | 17031 | 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 |
| 17038 | 17038 | } |
| 17039 | 17039 | |
| 17040 | 17040 | InferredStructField *isf = result_loc->value->type->data.pointer.inferred_struct_field; |
| 17041 | if (!was_written && isf != nullptr) { | |
| 17041 | if (!was_already_resolved && isf != nullptr) { | |
| 17042 | 17042 | // Now it's time to add the field to the struct type. |
| 17043 | 17043 | uint32_t old_field_count = isf->inferred_struct_type->data.structure.src_field_count; |
| 17044 | 17044 | uint32_t new_field_count = old_field_count + 1; |
| ... | ... | @@ -18077,7 +18077,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18077 | 18077 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { |
| 18078 | 18078 | return result_loc; |
| 18079 | 18079 | } |
| 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)) { | |
| 18081 | 18085 | ir_reset_result(call_result_loc); |
| 18082 | 18086 | result_loc = nullptr; |
| 18083 | 18087 | } |
| ... | ... | @@ -18240,7 +18244,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstruction *source_i |
| 18240 | 18244 | if (type_is_invalid(result_loc->value->type) || instr_is_unreachable(result_loc)) { |
| 18241 | 18245 | return result_loc; |
| 18242 | 18246 | } |
| 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)) { | |
| 18244 | 18252 | ir_reset_result(call_result_loc); |
| 18245 | 18253 | result_loc = nullptr; |
| 18246 | 18254 | } |
test/cli.zig+11-11| ... | ... | @@ -19,11 +19,11 @@ pub fn main() !void { |
| 19 | 19 | a = &arena.allocator; |
| 20 | 20 | |
| 21 | 21 | 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", .{}); | |
| 23 | 23 | return error.InvalidArgs; |
| 24 | 24 | }); |
| 25 | 25 | 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", .{}); | |
| 27 | 27 | return error.InvalidArgs; |
| 28 | 28 | }); |
| 29 | 29 | const zig_exe = try fs.path.resolve(a, &[_][]const u8{zig_exe_rel}); |
| ... | ... | @@ -45,39 +45,39 @@ pub fn main() !void { |
| 45 | 45 | |
| 46 | 46 | fn unwrapArg(arg: UnwrapArgError![]u8) UnwrapArgError![]u8 { |
| 47 | 47 | return arg catch |err| { |
| 48 | warn("Unable to parse command line: {}\n", err); | |
| 48 | warn("Unable to parse command line: {}\n", .{err}); | |
| 49 | 49 | return err; |
| 50 | 50 | }; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | fn printCmd(cwd: []const u8, argv: []const []const u8) void { |
| 54 | std.debug.warn("cd {} && ", cwd); | |
| 54 | std.debug.warn("cd {} && ", .{cwd}); | |
| 55 | 55 | for (argv) |arg| { |
| 56 | std.debug.warn("{} ", arg); | |
| 56 | std.debug.warn("{} ", .{arg}); | |
| 57 | 57 | } |
| 58 | std.debug.warn("\n"); | |
| 58 | std.debug.warn("\n", .{}); | |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | fn exec(cwd: []const u8, argv: []const []const u8) !ChildProcess.ExecResult { |
| 62 | 62 | const max_output_size = 100 * 1024; |
| 63 | 63 | 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", .{}); | |
| 65 | 65 | printCmd(cwd, argv); |
| 66 | 66 | return err; |
| 67 | 67 | }; |
| 68 | 68 | switch (result.term) { |
| 69 | 69 | .Exited => |code| { |
| 70 | 70 | 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}); | |
| 72 | 72 | printCmd(cwd, argv); |
| 73 | std.debug.warn("stderr:\n{}\n", result.stderr); | |
| 73 | std.debug.warn("stderr:\n{}\n", .{result.stderr}); | |
| 74 | 74 | return error.CommandFailed; |
| 75 | 75 | } |
| 76 | 76 | }, |
| 77 | 77 | else => { |
| 78 | std.debug.warn("The following command terminated unexpectedly:\n"); | |
| 78 | std.debug.warn("The following command terminated unexpectedly:\n", .{}); | |
| 79 | 79 | printCmd(cwd, argv); |
| 80 | std.debug.warn("stderr:\n{}\n", result.stderr); | |
| 80 | std.debug.warn("stderr:\n{}\n", .{result.stderr}); | |
| 81 | 81 | return error.CommandFailed; |
| 82 | 82 | }, |
| 83 | 83 | } |
test/compare_output.zig+33-33| ... | ... | @@ -20,7 +20,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 20 | 20 | \\pub fn main() void { |
| 21 | 21 | \\ privateFunction(); |
| 22 | 22 | \\ const stdout = &getStdOut().outStream().stream; |
| 23 | \\ stdout.print("OK 2\n") catch unreachable; | |
| 23 | \\ stdout.print("OK 2\n", .{}) catch unreachable; | |
| 24 | 24 | \\} |
| 25 | 25 | \\ |
| 26 | 26 | \\fn privateFunction() void { |
| ... | ... | @@ -35,7 +35,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 35 | 35 | \\// but it's private so it should be OK |
| 36 | 36 | \\fn privateFunction() void { |
| 37 | 37 | \\ const stdout = &getStdOut().outStream().stream; |
| 38 | \\ stdout.print("OK 1\n") catch unreachable; | |
| 38 | \\ stdout.print("OK 1\n", .{}) catch unreachable; | |
| 39 | 39 | \\} |
| 40 | 40 | \\ |
| 41 | 41 | \\pub fn printText() void { |
| ... | ... | @@ -61,7 +61,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 61 | 61 | \\usingnamespace @import("std").io; |
| 62 | 62 | \\pub fn foo_function() void { |
| 63 | 63 | \\ const stdout = &getStdOut().outStream().stream; |
| 64 | \\ stdout.print("OK\n") catch unreachable; | |
| 64 | \\ stdout.print("OK\n", .{}) catch unreachable; | |
| 65 | 65 | \\} |
| 66 | 66 | ); |
| 67 | 67 | |
| ... | ... | @@ -72,7 +72,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 72 | 72 | \\pub fn bar_function() void { |
| 73 | 73 | \\ if (foo_function()) { |
| 74 | 74 | \\ const stdout = &getStdOut().outStream().stream; |
| 75 | \\ stdout.print("OK\n") catch unreachable; | |
| 75 | \\ stdout.print("OK\n", .{}) catch unreachable; | |
| 76 | 76 | \\ } |
| 77 | 77 | \\} |
| 78 | 78 | ); |
| ... | ... | @@ -104,7 +104,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 104 | 104 | \\ |
| 105 | 105 | \\pub fn ok() void { |
| 106 | 106 | \\ const stdout = &io.getStdOut().outStream().stream; |
| 107 | \\ stdout.print(b_text) catch unreachable; | |
| 107 | \\ stdout.print(b_text, .{}) catch unreachable; | |
| 108 | 108 | \\} |
| 109 | 109 | ); |
| 110 | 110 | |
| ... | ... | @@ -122,7 +122,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 122 | 122 | \\ |
| 123 | 123 | \\pub fn main() void { |
| 124 | 124 | \\ 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; | |
| 126 | 126 | \\} |
| 127 | 127 | , "Hello, world!\n 12 12 a\n"); |
| 128 | 128 | |
| ... | ... | @@ -265,7 +265,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 265 | 265 | \\} |
| 266 | 266 | \\fn print_ok(val: @typeOf(x)) @typeOf(foo) { |
| 267 | 267 | \\ const stdout = &io.getStdOut().outStream().stream; |
| 268 | \\ stdout.print("OK\n") catch unreachable; | |
| 268 | \\ stdout.print("OK\n", .{}) catch unreachable; | |
| 269 | 269 | \\ return 0; |
| 270 | 270 | \\} |
| 271 | 271 | \\const foo : i32 = 0; |
| ... | ... | @@ -348,12 +348,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 348 | 348 | \\ const foo = Foo {.field1 = bar,}; |
| 349 | 349 | \\ const stdout = &io.getStdOut().outStream().stream; |
| 350 | 350 | \\ if (!foo.method()) { |
| 351 | \\ stdout.print("BAD\n") catch unreachable; | |
| 351 | \\ stdout.print("BAD\n", .{}) catch unreachable; | |
| 352 | 352 | \\ } |
| 353 | 353 | \\ if (!bar.method()) { |
| 354 | \\ stdout.print("BAD\n") catch unreachable; | |
| 354 | \\ stdout.print("BAD\n", .{}) catch unreachable; | |
| 355 | 355 | \\ } |
| 356 | \\ stdout.print("OK\n") catch unreachable; | |
| 356 | \\ stdout.print("OK\n", .{}) catch unreachable; | |
| 357 | 357 | \\} |
| 358 | 358 | , "OK\n"); |
| 359 | 359 | |
| ... | ... | @@ -361,11 +361,11 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 361 | 361 | \\const io = @import("std").io; |
| 362 | 362 | \\pub fn main() void { |
| 363 | 363 | \\ 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; | |
| 369 | 369 | \\} |
| 370 | 370 | , "before\nafter\ndefer3\ndefer2\ndefer1\n"); |
| 371 | 371 | |
| ... | ... | @@ -374,13 +374,13 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 374 | 374 | \\const os = @import("std").os; |
| 375 | 375 | \\pub fn main() void { |
| 376 | 376 | \\ 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; | |
| 380 | 380 | \\ var args_it = @import("std").process.args(); |
| 381 | 381 | \\ 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; | |
| 384 | 384 | \\} |
| 385 | 385 | , "before\ndefer2\ndefer1\n"); |
| 386 | 386 | |
| ... | ... | @@ -391,12 +391,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 391 | 391 | \\} |
| 392 | 392 | \\fn do_test() !void { |
| 393 | 393 | \\ 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; | |
| 397 | 397 | \\ 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; | |
| 400 | 400 | \\} |
| 401 | 401 | \\fn its_gonna_fail() !void { |
| 402 | 402 | \\ return error.IToldYouItWouldFail; |
| ... | ... | @@ -410,12 +410,12 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 410 | 410 | \\} |
| 411 | 411 | \\fn do_test() !void { |
| 412 | 412 | \\ 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; | |
| 416 | 416 | \\ 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; | |
| 419 | 419 | \\} |
| 420 | 420 | \\fn its_gonna_pass() anyerror!void { } |
| 421 | 421 | , "before\nafter\ndefer3\ndefer1\n"); |
| ... | ... | @@ -427,7 +427,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 427 | 427 | \\ |
| 428 | 428 | \\pub fn main() void { |
| 429 | 429 | \\ const stdout = &io.getStdOut().outStream().stream; |
| 430 | \\ stdout.print(foo_txt) catch unreachable; | |
| 430 | \\ stdout.print(foo_txt, .{}) catch unreachable; | |
| 431 | 431 | \\} |
| 432 | 432 | , "1234\nabcd\n"); |
| 433 | 433 | |
| ... | ... | @@ -452,7 +452,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 452 | 452 | \\ _ = args_it.skip(); |
| 453 | 453 | \\ while (args_it.next(allocator)) |arg_or_err| : (index += 1) { |
| 454 | 454 | \\ const arg = try arg_or_err; |
| 455 | \\ try stdout.print("{}: {}\n", index, arg); | |
| 455 | \\ try stdout.print("{}: {}\n", .{index, arg}); | |
| 456 | 456 | \\ } |
| 457 | 457 | \\} |
| 458 | 458 | , |
| ... | ... | @@ -493,7 +493,7 @@ pub fn addCases(cases: *tests.CompareOutputContext) void { |
| 493 | 493 | \\ _ = args_it.skip(); |
| 494 | 494 | \\ while (args_it.next(allocator)) |arg_or_err| : (index += 1) { |
| 495 | 495 | \\ const arg = try arg_or_err; |
| 496 | \\ try stdout.print("{}: {}\n", index, arg); | |
| 496 | \\ try stdout.print("{}: {}\n", .{index, arg}); | |
| 497 | 497 | \\ } |
| 498 | 498 | \\} |
| 499 | 499 | , |
test/compile_errors.zig+2-4| ... | ... | @@ -2598,14 +2598,12 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2598 | 2598 | \\fn a(b: fn (*const u8) void) void { |
| 2599 | 2599 | \\ b('a'); |
| 2600 | 2600 | \\} |
| 2601 | \\fn c(d: u8) void { | |
| 2602 | \\ @import("std").debug.warn("{c}\n", d); | |
| 2603 | \\} | |
| 2601 | \\fn c(d: u8) void {} | |
| 2604 | 2602 | \\export fn entry() void { |
| 2605 | 2603 | \\ a(c); |
| 2606 | 2604 | \\} |
| 2607 | 2605 | , |
| 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'", | |
| 2609 | 2607 | ); |
| 2610 | 2608 | |
| 2611 | 2609 | cases.add( |
test/standalone/cat/main.zig+5-5| ... | ... | @@ -23,7 +23,7 @@ pub fn main() !void { |
| 23 | 23 | return usage(exe); |
| 24 | 24 | } else { |
| 25 | 25 | 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)}); | |
| 27 | 27 | return err; |
| 28 | 28 | }; |
| 29 | 29 | defer file.close(); |
| ... | ... | @@ -38,7 +38,7 @@ pub fn main() !void { |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | fn usage(exe: []const u8) !void { |
| 41 | warn("Usage: {} [FILE]...\n", exe); | |
| 41 | warn("Usage: {} [FILE]...\n", .{exe}); | |
| 42 | 42 | return error.Invalid; |
| 43 | 43 | } |
| 44 | 44 | |
| ... | ... | @@ -47,7 +47,7 @@ fn cat_file(stdout: fs.File, file: fs.File) !void { |
| 47 | 47 | |
| 48 | 48 | while (true) { |
| 49 | 49 | 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)}); | |
| 51 | 51 | return err; |
| 52 | 52 | }; |
| 53 | 53 | |
| ... | ... | @@ -56,7 +56,7 @@ fn cat_file(stdout: fs.File, file: fs.File) !void { |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | 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)}); | |
| 60 | 60 | return err; |
| 61 | 61 | }; |
| 62 | 62 | } |
| ... | ... | @@ -64,7 +64,7 @@ fn cat_file(stdout: fs.File, file: fs.File) !void { |
| 64 | 64 | |
| 65 | 65 | fn unwrapArg(arg: anyerror![]u8) ![]u8 { |
| 66 | 66 | return arg catch |err| { |
| 67 | warn("Unable to parse command line: {}\n", err); | |
| 67 | warn("Unable to parse command line: {}\n", .{err}); | |
| 68 | 68 | return err; |
| 69 | 69 | }; |
| 70 | 70 | } |
test/standalone/guess_number/main.zig+8-8| ... | ... | @@ -6,11 +6,11 @@ const fmt = std.fmt; |
| 6 | 6 | pub fn main() !void { |
| 7 | 7 | const stdout = &io.getStdOut().outStream().stream; |
| 8 | 8 | |
| 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", .{}); | |
| 10 | 10 | |
| 11 | 11 | var seed_bytes: [@sizeOf(u64)]u8 = undefined; |
| 12 | 12 | 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}); | |
| 14 | 14 | return err; |
| 15 | 15 | }; |
| 16 | 16 | const seed = std.mem.readIntNative(u64, &seed_bytes); |
| ... | ... | @@ -19,27 +19,27 @@ pub fn main() !void { |
| 19 | 19 | const answer = prng.random.range(u8, 0, 100) + 1; |
| 20 | 20 | |
| 21 | 21 | while (true) { |
| 22 | try stdout.print("\nGuess a number between 1 and 100: "); | |
| 22 | try stdout.print("\nGuess a number between 1 and 100: ", .{}); | |
| 23 | 23 | var line_buf: [20]u8 = undefined; |
| 24 | 24 | |
| 25 | 25 | const line = io.readLineSlice(line_buf[0..]) catch |err| switch (err) { |
| 26 | 26 | error.OutOfMemory => { |
| 27 | try stdout.print("Input too long.\n"); | |
| 27 | try stdout.print("Input too long.\n", .{}); | |
| 28 | 28 | continue; |
| 29 | 29 | }, |
| 30 | 30 | else => return err, |
| 31 | 31 | }; |
| 32 | 32 | |
| 33 | 33 | const guess = fmt.parseUnsigned(u8, line, 10) catch { |
| 34 | try stdout.print("Invalid number.\n"); | |
| 34 | try stdout.print("Invalid number.\n", .{}); | |
| 35 | 35 | continue; |
| 36 | 36 | }; |
| 37 | 37 | if (guess > answer) { |
| 38 | try stdout.print("Guess lower.\n"); | |
| 38 | try stdout.print("Guess lower.\n", .{}); | |
| 39 | 39 | } else if (guess < answer) { |
| 40 | try stdout.print("Guess higher.\n"); | |
| 40 | try stdout.print("Guess higher.\n", .{}); | |
| 41 | 41 | } else { |
| 42 | try stdout.print("You win!\n"); | |
| 42 | try stdout.print("You win!\n", .{}); | |
| 43 | 43 | return; |
| 44 | 44 | } |
| 45 | 45 | } |
test/tests.zig+94-66| ... | ... | @@ -411,7 +411,7 @@ pub fn addPkgTests( |
| 411 | 411 | is_qemu_enabled: bool, |
| 412 | 412 | glibc_dir: ?[]const u8, |
| 413 | 413 | ) *build.Step { |
| 414 | const step = b.step(b.fmt("test-{}", name), desc); | |
| 414 | const step = b.step(b.fmt("test-{}", .{name}), desc); | |
| 415 | 415 | |
| 416 | 416 | for (test_targets) |test_target| { |
| 417 | 417 | if (skip_non_native and test_target.target != .Native) |
| ... | ... | @@ -454,14 +454,14 @@ pub fn addPkgTests( |
| 454 | 454 | test_target.target.zigTripleNoSubArch(b.allocator) catch unreachable; |
| 455 | 455 | |
| 456 | 456 | 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("{}-{}-{}-{}-{} ", .{ | |
| 459 | 459 | name, |
| 460 | 460 | triple_prefix, |
| 461 | 461 | @tagName(test_target.mode), |
| 462 | 462 | libc_prefix, |
| 463 | if (test_target.single_threaded) "single" else "multi", | |
| 464 | )); | |
| 463 | single_threaded_txt, | |
| 464 | })); | |
| 465 | 465 | these_tests.single_threaded = test_target.single_threaded; |
| 466 | 466 | these_tests.setFilter(test_filter); |
| 467 | 467 | these_tests.setBuildMode(test_target.mode); |
| ... | ... | @@ -562,7 +562,7 @@ pub const CompareOutputContext = struct { |
| 562 | 562 | args.append(arg) catch unreachable; |
| 563 | 563 | } |
| 564 | 564 | |
| 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 }); | |
| 566 | 566 | |
| 567 | 567 | const child = std.ChildProcess.init(args.toSliceConst(), b.allocator) catch unreachable; |
| 568 | 568 | defer child.deinit(); |
| ... | ... | @@ -572,7 +572,7 @@ pub const CompareOutputContext = struct { |
| 572 | 572 | child.stderr_behavior = .Pipe; |
| 573 | 573 | child.env_map = b.env_map; |
| 574 | 574 | |
| 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) }); | |
| 576 | 576 | |
| 577 | 577 | var stdout = Buffer.initNull(b.allocator); |
| 578 | 578 | var stderr = Buffer.initNull(b.allocator); |
| ... | ... | @@ -584,18 +584,18 @@ pub const CompareOutputContext = struct { |
| 584 | 584 | stderr_file_in_stream.stream.readAllBuffer(&stderr, max_stdout_size) catch unreachable; |
| 585 | 585 | |
| 586 | 586 | 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) }); | |
| 588 | 588 | }; |
| 589 | 589 | switch (term) { |
| 590 | 590 | .Exited => |code| { |
| 591 | 591 | 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 }); | |
| 593 | 593 | printInvocation(args.toSliceConst()); |
| 594 | 594 | return error.TestFailed; |
| 595 | 595 | } |
| 596 | 596 | }, |
| 597 | 597 | else => { |
| 598 | warn("Process {} terminated unexpectedly\n", full_exe_path); | |
| 598 | warn("Process {} terminated unexpectedly\n", .{full_exe_path}); | |
| 599 | 599 | printInvocation(args.toSliceConst()); |
| 600 | 600 | return error.TestFailed; |
| 601 | 601 | }, |
| ... | ... | @@ -609,10 +609,10 @@ pub const CompareOutputContext = struct { |
| 609 | 609 | \\========= But found: ==================== |
| 610 | 610 | \\{} |
| 611 | 611 | \\ |
| 612 | , self.expected_output, stdout.toSliceConst()); | |
| 612 | , .{ self.expected_output, stdout.toSliceConst() }); | |
| 613 | 613 | return error.TestFailed; |
| 614 | 614 | } |
| 615 | warn("OK\n"); | |
| 615 | warn("OK\n", .{}); | |
| 616 | 616 | } |
| 617 | 617 | }; |
| 618 | 618 | |
| ... | ... | @@ -644,7 +644,7 @@ pub const CompareOutputContext = struct { |
| 644 | 644 | |
| 645 | 645 | const full_exe_path = self.exe.getOutputPath(); |
| 646 | 646 | |
| 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 }); | |
| 648 | 648 | |
| 649 | 649 | const child = std.ChildProcess.init(&[_][]const u8{full_exe_path}, b.allocator) catch unreachable; |
| 650 | 650 | defer child.deinit(); |
| ... | ... | @@ -655,28 +655,34 @@ pub const CompareOutputContext = struct { |
| 655 | 655 | child.stderr_behavior = .Ignore; |
| 656 | 656 | |
| 657 | 657 | 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) }); | |
| 659 | 659 | }; |
| 660 | 660 | |
| 661 | 661 | const expected_exit_code: u32 = 126; |
| 662 | 662 | switch (term) { |
| 663 | 663 | .Exited => |code| { |
| 664 | 664 | 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 | }); | |
| 666 | 668 | return error.TestFailed; |
| 667 | 669 | } |
| 668 | 670 | }, |
| 669 | 671 | .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 | }); | |
| 671 | 675 | return error.TestFailed; |
| 672 | 676 | }, |
| 673 | 677 | 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 | }); | |
| 675 | 681 | return error.TestFailed; |
| 676 | 682 | }, |
| 677 | 683 | } |
| 678 | 684 | |
| 679 | warn("OK\n"); | |
| 685 | warn("OK\n", .{}); | |
| 680 | 686 | } |
| 681 | 687 | }; |
| 682 | 688 | |
| ... | ... | @@ -729,7 +735,9 @@ pub const CompareOutputContext = struct { |
| 729 | 735 | |
| 730 | 736 | switch (case.special) { |
| 731 | 737 | 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; | |
| 733 | 741 | if (self.test_filter) |filter| { |
| 734 | 742 | if (mem.indexOf(u8, annotated_case_name, filter) == null) return; |
| 735 | 743 | } |
| ... | ... | @@ -758,7 +766,11 @@ pub const CompareOutputContext = struct { |
| 758 | 766 | }, |
| 759 | 767 | Special.None => { |
| 760 | 768 | 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; | |
| 762 | 774 | if (self.test_filter) |filter| { |
| 763 | 775 | if (mem.indexOf(u8, annotated_case_name, filter) == null) continue; |
| 764 | 776 | } |
| ... | ... | @@ -790,7 +802,7 @@ pub const CompareOutputContext = struct { |
| 790 | 802 | } |
| 791 | 803 | }, |
| 792 | 804 | 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; | |
| 794 | 806 | if (self.test_filter) |filter| { |
| 795 | 807 | if (mem.indexOf(u8, annotated_case_name, filter) == null) return; |
| 796 | 808 | } |
| ... | ... | @@ -843,7 +855,11 @@ pub const StackTracesContext = struct { |
| 843 | 855 | const expect_for_mode = expect[@enumToInt(mode)]; |
| 844 | 856 | if (expect_for_mode.len == 0) continue; |
| 845 | 857 | |
| 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; | |
| 847 | 863 | if (self.test_filter) |filter| { |
| 848 | 864 | if (mem.indexOf(u8, annotated_case_name, filter) == null) continue; |
| 849 | 865 | } |
| ... | ... | @@ -907,7 +923,7 @@ pub const StackTracesContext = struct { |
| 907 | 923 | defer args.deinit(); |
| 908 | 924 | args.append(full_exe_path) catch unreachable; |
| 909 | 925 | |
| 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 }); | |
| 911 | 927 | |
| 912 | 928 | const child = std.ChildProcess.init(args.toSliceConst(), b.allocator) catch unreachable; |
| 913 | 929 | defer child.deinit(); |
| ... | ... | @@ -917,7 +933,7 @@ pub const StackTracesContext = struct { |
| 917 | 933 | child.stderr_behavior = .Pipe; |
| 918 | 934 | child.env_map = b.env_map; |
| 919 | 935 | |
| 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) }); | |
| 921 | 937 | |
| 922 | 938 | var stdout = Buffer.initNull(b.allocator); |
| 923 | 939 | var stderr = Buffer.initNull(b.allocator); |
| ... | ... | @@ -929,30 +945,34 @@ pub const StackTracesContext = struct { |
| 929 | 945 | stderr_file_in_stream.stream.readAllBuffer(&stderr, max_stdout_size) catch unreachable; |
| 930 | 946 | |
| 931 | 947 | 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) }); | |
| 933 | 949 | }; |
| 934 | 950 | |
| 935 | 951 | switch (term) { |
| 936 | 952 | .Exited => |code| { |
| 937 | 953 | const expect_code: u32 = 1; |
| 938 | 954 | 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 | }); | |
| 940 | 960 | printInvocation(args.toSliceConst()); |
| 941 | 961 | return error.TestFailed; |
| 942 | 962 | } |
| 943 | 963 | }, |
| 944 | 964 | .Signal => |signum| { |
| 945 | warn("Process {} terminated on signal {}\n", full_exe_path, signum); | |
| 965 | warn("Process {} terminated on signal {}\n", .{ full_exe_path, signum }); | |
| 946 | 966 | printInvocation(args.toSliceConst()); |
| 947 | 967 | return error.TestFailed; |
| 948 | 968 | }, |
| 949 | 969 | .Stopped => |signum| { |
| 950 | warn("Process {} stopped on signal {}\n", full_exe_path, signum); | |
| 970 | warn("Process {} stopped on signal {}\n", .{ full_exe_path, signum }); | |
| 951 | 971 | printInvocation(args.toSliceConst()); |
| 952 | 972 | return error.TestFailed; |
| 953 | 973 | }, |
| 954 | 974 | .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 }); | |
| 956 | 976 | printInvocation(args.toSliceConst()); |
| 957 | 977 | return error.TestFailed; |
| 958 | 978 | }, |
| ... | ... | @@ -1003,10 +1023,10 @@ pub const StackTracesContext = struct { |
| 1003 | 1023 | \\================================================ |
| 1004 | 1024 | \\{} |
| 1005 | 1025 | \\ |
| 1006 | , self.expect_output, got); | |
| 1026 | , .{ self.expect_output, got }); | |
| 1007 | 1027 | return error.TestFailed; |
| 1008 | 1028 | } |
| 1009 | warn("OK\n"); | |
| 1029 | warn("OK\n", .{}); | |
| 1010 | 1030 | } |
| 1011 | 1031 | }; |
| 1012 | 1032 | }; |
| ... | ... | @@ -1129,7 +1149,7 @@ pub const CompileErrorContext = struct { |
| 1129 | 1149 | Mode.ReleaseSmall => zig_args.append("--release-small") catch unreachable, |
| 1130 | 1150 | } |
| 1131 | 1151 | |
| 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 }); | |
| 1133 | 1153 | |
| 1134 | 1154 | if (b.verbose) { |
| 1135 | 1155 | printInvocation(zig_args.toSliceConst()); |
| ... | ... | @@ -1143,7 +1163,7 @@ pub const CompileErrorContext = struct { |
| 1143 | 1163 | child.stdout_behavior = .Pipe; |
| 1144 | 1164 | child.stderr_behavior = .Pipe; |
| 1145 | 1165 | |
| 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) }); | |
| 1147 | 1167 | |
| 1148 | 1168 | var stdout_buf = Buffer.initNull(b.allocator); |
| 1149 | 1169 | var stderr_buf = Buffer.initNull(b.allocator); |
| ... | ... | @@ -1155,7 +1175,7 @@ pub const CompileErrorContext = struct { |
| 1155 | 1175 | stderr_file_in_stream.stream.readAllBuffer(&stderr_buf, max_stdout_size) catch unreachable; |
| 1156 | 1176 | |
| 1157 | 1177 | 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) }); | |
| 1159 | 1179 | }; |
| 1160 | 1180 | switch (term) { |
| 1161 | 1181 | .Exited => |code| { |
| ... | ... | @@ -1165,7 +1185,7 @@ pub const CompileErrorContext = struct { |
| 1165 | 1185 | } |
| 1166 | 1186 | }, |
| 1167 | 1187 | else => { |
| 1168 | warn("Process {} terminated unexpectedly\n", b.zig_exe); | |
| 1188 | warn("Process {} terminated unexpectedly\n", .{b.zig_exe}); | |
| 1169 | 1189 | printInvocation(zig_args.toSliceConst()); |
| 1170 | 1190 | return error.TestFailed; |
| 1171 | 1191 | }, |
| ... | ... | @@ -1182,7 +1202,7 @@ pub const CompileErrorContext = struct { |
| 1182 | 1202 | \\{} |
| 1183 | 1203 | \\================================================ |
| 1184 | 1204 | \\ |
| 1185 | , stdout); | |
| 1205 | , .{stdout}); | |
| 1186 | 1206 | return error.TestFailed; |
| 1187 | 1207 | } |
| 1188 | 1208 | |
| ... | ... | @@ -1200,9 +1220,9 @@ pub const CompileErrorContext = struct { |
| 1200 | 1220 | ok = ok and i == self.case.expected_errors.len; |
| 1201 | 1221 | |
| 1202 | 1222 | if (!ok) { |
| 1203 | warn("\n======== Expected these compile errors: ========\n"); | |
| 1223 | warn("\n======== Expected these compile errors: ========\n", .{}); | |
| 1204 | 1224 | for (self.case.expected_errors.toSliceConst()) |expected| { |
| 1205 | warn("{}\n", expected); | |
| 1225 | warn("{}\n", .{expected}); | |
| 1206 | 1226 | } |
| 1207 | 1227 | } |
| 1208 | 1228 | } else { |
| ... | ... | @@ -1213,7 +1233,7 @@ pub const CompileErrorContext = struct { |
| 1213 | 1233 | \\=========== Expected compile error: ============ |
| 1214 | 1234 | \\{} |
| 1215 | 1235 | \\ |
| 1216 | , expected); | |
| 1236 | , .{expected}); | |
| 1217 | 1237 | ok = false; |
| 1218 | 1238 | break; |
| 1219 | 1239 | } |
| ... | ... | @@ -1225,11 +1245,11 @@ pub const CompileErrorContext = struct { |
| 1225 | 1245 | \\================= Full output: ================= |
| 1226 | 1246 | \\{} |
| 1227 | 1247 | \\ |
| 1228 | , stderr); | |
| 1248 | , .{stderr}); | |
| 1229 | 1249 | return error.TestFailed; |
| 1230 | 1250 | } |
| 1231 | 1251 | |
| 1232 | warn("OK\n"); | |
| 1252 | warn("OK\n", .{}); | |
| 1233 | 1253 | } |
| 1234 | 1254 | }; |
| 1235 | 1255 | |
| ... | ... | @@ -1279,7 +1299,9 @@ pub const CompileErrorContext = struct { |
| 1279 | 1299 | pub fn addCase(self: *CompileErrorContext, case: *const TestCase) void { |
| 1280 | 1300 | const b = self.b; |
| 1281 | 1301 | |
| 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; | |
| 1283 | 1305 | if (self.test_filter) |filter| { |
| 1284 | 1306 | if (mem.indexOf(u8, annotated_case_name, filter) == null) return; |
| 1285 | 1307 | } |
| ... | ... | @@ -1316,7 +1338,7 @@ pub const StandaloneContext = struct { |
| 1316 | 1338 | pub fn addBuildFile(self: *StandaloneContext, build_file: []const u8) void { |
| 1317 | 1339 | const b = self.b; |
| 1318 | 1340 | |
| 1319 | const annotated_case_name = b.fmt("build {} (Debug)", build_file); | |
| 1341 | const annotated_case_name = b.fmt("build {} (Debug)", .{build_file}); | |
| 1320 | 1342 | if (self.test_filter) |filter| { |
| 1321 | 1343 | if (mem.indexOf(u8, annotated_case_name, filter) == null) return; |
| 1322 | 1344 | } |
| ... | ... | @@ -1337,7 +1359,7 @@ pub const StandaloneContext = struct { |
| 1337 | 1359 | |
| 1338 | 1360 | const run_cmd = b.addSystemCommand(zig_args.toSliceConst()); |
| 1339 | 1361 | |
| 1340 | const log_step = b.addLog("PASS {}\n", annotated_case_name); | |
| 1362 | const log_step = b.addLog("PASS {}\n", .{annotated_case_name}); | |
| 1341 | 1363 | log_step.step.dependOn(&run_cmd.step); |
| 1342 | 1364 | |
| 1343 | 1365 | self.step.dependOn(&log_step.step); |
| ... | ... | @@ -1347,7 +1369,10 @@ pub const StandaloneContext = struct { |
| 1347 | 1369 | const b = self.b; |
| 1348 | 1370 | |
| 1349 | 1371 | 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; | |
| 1351 | 1376 | if (self.test_filter) |filter| { |
| 1352 | 1377 | if (mem.indexOf(u8, annotated_case_name, filter) == null) continue; |
| 1353 | 1378 | } |
| ... | ... | @@ -1358,7 +1383,7 @@ pub const StandaloneContext = struct { |
| 1358 | 1383 | exe.linkSystemLibrary("c"); |
| 1359 | 1384 | } |
| 1360 | 1385 | |
| 1361 | const log_step = b.addLog("PASS {}\n", annotated_case_name); | |
| 1386 | const log_step = b.addLog("PASS {}\n", .{annotated_case_name}); | |
| 1362 | 1387 | log_step.step.dependOn(&exe.step); |
| 1363 | 1388 | |
| 1364 | 1389 | self.step.dependOn(&log_step.step); |
| ... | ... | @@ -1434,7 +1459,7 @@ pub const TranslateCContext = struct { |
| 1434 | 1459 | zig_args.append(translate_c_cmd) catch unreachable; |
| 1435 | 1460 | zig_args.append(b.pathFromRoot(root_src)) catch unreachable; |
| 1436 | 1461 | |
| 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 }); | |
| 1438 | 1463 | |
| 1439 | 1464 | if (b.verbose) { |
| 1440 | 1465 | printInvocation(zig_args.toSliceConst()); |
| ... | ... | @@ -1448,7 +1473,10 @@ pub const TranslateCContext = struct { |
| 1448 | 1473 | child.stdout_behavior = .Pipe; |
| 1449 | 1474 | child.stderr_behavior = .Pipe; |
| 1450 | 1475 | |
| 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 | }); | |
| 1452 | 1480 | |
| 1453 | 1481 | var stdout_buf = Buffer.initNull(b.allocator); |
| 1454 | 1482 | var stderr_buf = Buffer.initNull(b.allocator); |
| ... | ... | @@ -1460,23 +1488,23 @@ pub const TranslateCContext = struct { |
| 1460 | 1488 | stderr_file_in_stream.stream.readAllBuffer(&stderr_buf, max_stdout_size) catch unreachable; |
| 1461 | 1489 | |
| 1462 | 1490 | 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) }); | |
| 1464 | 1492 | }; |
| 1465 | 1493 | switch (term) { |
| 1466 | 1494 | .Exited => |code| { |
| 1467 | 1495 | if (code != 0) { |
| 1468 | warn("Compilation failed with exit code {}\n", code); | |
| 1496 | warn("Compilation failed with exit code {}\n", .{code}); | |
| 1469 | 1497 | printInvocation(zig_args.toSliceConst()); |
| 1470 | 1498 | return error.TestFailed; |
| 1471 | 1499 | } |
| 1472 | 1500 | }, |
| 1473 | 1501 | .Signal => |code| { |
| 1474 | warn("Compilation failed with signal {}\n", code); | |
| 1502 | warn("Compilation failed with signal {}\n", .{code}); | |
| 1475 | 1503 | printInvocation(zig_args.toSliceConst()); |
| 1476 | 1504 | return error.TestFailed; |
| 1477 | 1505 | }, |
| 1478 | 1506 | else => { |
| 1479 | warn("Compilation terminated unexpectedly\n"); | |
| 1507 | warn("Compilation terminated unexpectedly\n", .{}); | |
| 1480 | 1508 | printInvocation(zig_args.toSliceConst()); |
| 1481 | 1509 | return error.TestFailed; |
| 1482 | 1510 | }, |
| ... | ... | @@ -1491,7 +1519,7 @@ pub const TranslateCContext = struct { |
| 1491 | 1519 | \\{} |
| 1492 | 1520 | \\============================================ |
| 1493 | 1521 | \\ |
| 1494 | , stderr); | |
| 1522 | , .{stderr}); | |
| 1495 | 1523 | printInvocation(zig_args.toSliceConst()); |
| 1496 | 1524 | return error.TestFailed; |
| 1497 | 1525 | } |
| ... | ... | @@ -1505,20 +1533,20 @@ pub const TranslateCContext = struct { |
| 1505 | 1533 | \\========= But found: =========================== |
| 1506 | 1534 | \\{} |
| 1507 | 1535 | \\ |
| 1508 | , expected_line, stdout); | |
| 1536 | , .{ expected_line, stdout }); | |
| 1509 | 1537 | printInvocation(zig_args.toSliceConst()); |
| 1510 | 1538 | return error.TestFailed; |
| 1511 | 1539 | } |
| 1512 | 1540 | } |
| 1513 | warn("OK\n"); | |
| 1541 | warn("OK\n", .{}); | |
| 1514 | 1542 | } |
| 1515 | 1543 | }; |
| 1516 | 1544 | |
| 1517 | 1545 | fn printInvocation(args: []const []const u8) void { |
| 1518 | 1546 | for (args) |arg| { |
| 1519 | warn("{} ", arg); | |
| 1547 | warn("{} ", .{arg}); | |
| 1520 | 1548 | } |
| 1521 | warn("\n"); | |
| 1549 | warn("\n", .{}); | |
| 1522 | 1550 | } |
| 1523 | 1551 | |
| 1524 | 1552 | 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 { |
| 1586 | 1614 | const b = self.b; |
| 1587 | 1615 | |
| 1588 | 1616 | 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; | |
| 1590 | 1618 | if (self.test_filter) |filter| { |
| 1591 | 1619 | if (mem.indexOf(u8, annotated_case_name, filter) == null) return; |
| 1592 | 1620 | } |
| ... | ... | @@ -1666,7 +1694,7 @@ pub const GenHContext = struct { |
| 1666 | 1694 | const self = @fieldParentPtr(GenHCmpOutputStep, "step", step); |
| 1667 | 1695 | const b = self.context.b; |
| 1668 | 1696 | |
| 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 }); | |
| 1670 | 1698 | |
| 1671 | 1699 | const full_h_path = self.obj.getOutputHPath(); |
| 1672 | 1700 | const actual_h = try io.readFileAlloc(b.allocator, full_h_path); |
| ... | ... | @@ -1680,19 +1708,19 @@ pub const GenHContext = struct { |
| 1680 | 1708 | \\========= But found: =========================== |
| 1681 | 1709 | \\{} |
| 1682 | 1710 | \\ |
| 1683 | , expected_line, actual_h); | |
| 1711 | , .{ expected_line, actual_h }); | |
| 1684 | 1712 | return error.TestFailed; |
| 1685 | 1713 | } |
| 1686 | 1714 | } |
| 1687 | warn("OK\n"); | |
| 1715 | warn("OK\n", .{}); | |
| 1688 | 1716 | } |
| 1689 | 1717 | }; |
| 1690 | 1718 | |
| 1691 | 1719 | fn printInvocation(args: []const []const u8) void { |
| 1692 | 1720 | for (args) |arg| { |
| 1693 | warn("{} ", arg); | |
| 1721 | warn("{} ", .{arg}); | |
| 1694 | 1722 | } |
| 1695 | warn("\n"); | |
| 1723 | warn("\n", .{}); | |
| 1696 | 1724 | } |
| 1697 | 1725 | |
| 1698 | 1726 | 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 { |
| 1724 | 1752 | ) catch unreachable; |
| 1725 | 1753 | |
| 1726 | 1754 | 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; | |
| 1728 | 1756 | if (self.test_filter) |filter| { |
| 1729 | 1757 | if (mem.indexOf(u8, annotated_case_name, filter) == null) return; |
| 1730 | 1758 | } |
| ... | ... | @@ -1749,7 +1777,7 @@ pub const GenHContext = struct { |
| 1749 | 1777 | |
| 1750 | 1778 | fn printInvocation(args: []const []const u8) void { |
| 1751 | 1779 | for (args) |arg| { |
| 1752 | warn("{} ", arg); | |
| 1780 | warn("{} ", .{arg}); | |
| 1753 | 1781 | } |
| 1754 | warn("\n"); | |
| 1782 | warn("\n", .{}); | |
| 1755 | 1783 | } |