authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-12-08 23:46:50-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-12-08 23:46:50-05:00
log03396b3caac1ab76dae5f672800aafb176d46cad
tree82bab53cf670621b2cc08ea9ff743400f02f530b
parent5f9467d78f678932ec14946fc83ba50ad7fc2454
signature Commit is signed but in an unrecognized format.

update docs to new fmt API


3 files changed, 84 insertions(+), 72 deletions(-)

doc/langref.html.in+82-70
...@@ -205,7 +205,7 @@ const std = @import("std");...@@ -205,7 +205,7 @@ const std = @import("std");
205205
206pub fn main() !void {206pub fn main() !void {
207 const stdout = &std.io.getStdOut().outStream().stream;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 {#code_end#}210 {#code_end#}
211 <p>211 <p>
...@@ -217,7 +217,7 @@ pub fn main() !void {...@@ -217,7 +217,7 @@ pub fn main() !void {
217const warn = @import("std").debug.warn;217const warn = @import("std").debug.warn;
218218
219pub fn main() void {219pub fn main() void {
220 warn("Hello, world!\n");220 warn("Hello, world!\n", .{});
221}221}
222 {#code_end#}222 {#code_end#}
223 <p>223 <p>
...@@ -289,41 +289,50 @@ const assert = std.debug.assert;...@@ -289,41 +289,50 @@ const assert = std.debug.assert;
289pub fn main() void {289pub fn main() void {
290 // integers290 // integers
291 const one_plus_one: i32 = 1 + 1;291 const one_plus_one: i32 = 1 + 1;
292 warn("1 + 1 = {}\n", one_plus_one);292 warn("1 + 1 = {}\n", .{one_plus_one});
293293
294 // floats294 // floats
295 const seven_div_three: f32 = 7.0 / 3.0;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});
297297
298 // boolean298 // boolean
299 warn("{}\n{}\n{}\n",299 warn("{}\n{}\n{}\n", .{
300 true and false,300 true and false,
301 true or false,301 true or false,
302 !true);302 !true,
303 });
303304
304 // optional305 // optional
305 var optional_value: ?[]const u8 = null;306 var optional_value: ?[]const u8 = null;
306 assert(optional_value == null);307 assert(optional_value == null);
307308
308 warn("\noptional 1\ntype: {}\nvalue: {}\n",309 warn("\noptional 1\ntype: {}\nvalue: {}\n", .{
309 @typeName(@typeOf(optional_value)), optional_value);310 @typeName(@typeOf(optional_value)),
311 optional_value,
312 });
310313
311 optional_value = "hi";314 optional_value = "hi";
312 assert(optional_value != null);315 assert(optional_value != null);
313316
314 warn("\noptional 2\ntype: {}\nvalue: {}\n",317 warn("\noptional 2\ntype: {}\nvalue: {}\n", .{
315 @typeName(@typeOf(optional_value)), optional_value);318 @typeName(@typeOf(optional_value)),
319 optional_value,
320 });
316321
317 // error union322 // error union
318 var number_or_error: anyerror!i32 = error.ArgNotFound;323 var number_or_error: anyerror!i32 = error.ArgNotFound;
319324
320 warn("\nerror union 1\ntype: {}\nvalue: {}\n",325 warn("\nerror union 1\ntype: {}\nvalue: {}\n", .{
321 @typeName(@typeOf(number_or_error)), number_or_error);326 @typeName(@typeOf(number_or_error)),
327 number_or_error,
328 });
322329
323 number_or_error = 1234;330 number_or_error = 1234;
324331
325 warn("\nerror union 2\ntype: {}\nvalue: {}\n",332 warn("\nerror union 2\ntype: {}\nvalue: {}\n", .{
326 @typeName(@typeOf(number_or_error)), number_or_error);333 @typeName(@typeOf(number_or_error)),
334 number_or_error,
335 });
327}336}
328 {#code_end#}337 {#code_end#}
329 {#header_open|Primitive Types#}338 {#header_open|Primitive Types#}
...@@ -954,8 +963,8 @@ extern fn foo_optimized(x: f64) f64;...@@ -954,8 +963,8 @@ extern fn foo_optimized(x: f64) f64;
954963
955pub fn main() void {964pub fn main() void {
956 const x = 0.001;965 const x = 0.001;
957 warn("optimized = {}\n", foo_optimized(x));966 warn("optimized = {}\n", .{foo_optimized(x)});
958 warn("strict = {}\n", foo_strict(x));967 warn("strict = {}\n", .{foo_strict(x)});
959}968}
960 {#code_end#}969 {#code_end#}
961 {#see_also|@setFloatMode|Division by Zero#}970 {#see_also|@setFloatMode|Division by Zero#}
...@@ -2182,7 +2191,7 @@ test "using slices for strings" {...@@ -2182,7 +2191,7 @@ test "using slices for strings" {
2182 // You can use slice syntax on an array to convert an array into a slice.2191 // You can use slice syntax on an array to convert an array into a slice.
2183 const all_together_slice = all_together[0..];2192 const all_together_slice = all_together[0..];
2184 // String concatenation example.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});
21862195
2187 // Generally, you can use UTF-8 and not worry about whether something is a2196 // Generally, you can use UTF-8 and not worry about whether something is a
2188 // string. If you don't need to deal with individual characters, no need2197 // string. If you don't need to deal with individual characters, no need
...@@ -2623,9 +2632,9 @@ const std = @import("std");...@@ -2623,9 +2632,9 @@ const std = @import("std");
26232632
2624pub fn main() void {2633pub fn main() void {
2625 const Foo = struct {};2634 const Foo = struct {};
2626 std.debug.warn("variable: {}\n", @typeName(Foo));2635 std.debug.warn("variable: {}\n", .{@typeName(Foo)});
2627 std.debug.warn("anonymous: {}\n", @typeName(struct {}));2636 std.debug.warn("anonymous: {}\n", .{@typeName(struct {})});
2628 std.debug.warn("function: {}\n", @typeName(List(i32)));2637 std.debug.warn("function: {}\n", .{@typeName(List(i32))});
2629}2638}
26302639
2631fn List(comptime T: type) type {2640fn List(comptime T: type) type {
...@@ -3806,18 +3815,18 @@ test "defer basics" {...@@ -3806,18 +3815,18 @@ test "defer basics" {
3806// If multiple defer statements are specified, they will be executed in3815// If multiple defer statements are specified, they will be executed in
3807// the reverse order they were run.3816// the reverse order they were run.
3808fn deferUnwindExample() void {3817fn deferUnwindExample() void {
3809 warn("\n");3818 warn("\n", .{});
38103819
3811 defer {3820 defer {
3812 warn("1 ");3821 warn("1 ", .{});
3813 }3822 }
3814 defer {3823 defer {
3815 warn("2 ");3824 warn("2 ", .{});
3816 }3825 }
3817 if (false) {3826 if (false) {
3818 // defers are not run if they are never executed.3827 // defers are not run if they are never executed.
3819 defer {3828 defer {
3820 warn("3 ");3829 warn("3 ", .{});
3821 }3830 }
3822 }3831 }
3823}3832}
...@@ -3832,15 +3841,15 @@ test "defer unwinding" {...@@ -3832,15 +3841,15 @@ test "defer unwinding" {
3832// This is especially useful in allowing a function to clean up properly3841// This is especially useful in allowing a function to clean up properly
3833// on error, and replaces goto error handling tactics as seen in c.3842// on error, and replaces goto error handling tactics as seen in c.
3834fn deferErrorExample(is_error: bool) !void {3843fn deferErrorExample(is_error: bool) !void {
3835 warn("\nstart of function\n");3844 warn("\nstart of function\n", .{});
38363845
3837 // This will always be executed on exit3846 // This will always be executed on exit
3838 defer {3847 defer {
3839 warn("end of function\n");3848 warn("end of function\n", .{});
3840 }3849 }
38413850
3842 errdefer {3851 errdefer {
3843 warn("encountered an error!\n");3852 warn("encountered an error!\n", .{});
3844 }3853 }
38453854
3846 if (is_error) {3855 if (is_error) {
...@@ -5843,7 +5852,7 @@ const a_number: i32 = 1234;...@@ -5843,7 +5852,7 @@ const a_number: i32 = 1234;
5843const a_string = "foobar";5852const a_string = "foobar";
58445853
5845pub fn main() void {5854pub 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 {#code_end#}5857 {#code_end#}
58495858
...@@ -5960,8 +5969,11 @@ const a_number: i32 = 1234;...@@ -5960,8 +5969,11 @@ const a_number: i32 = 1234;
5960const a_string = "foobar";5969const a_string = "foobar";
59615970
5962test "printf too many arguments" {5971test "printf too many arguments" {
5963 warn("here is a string: '{}' here is a number: {}\n",5972 warn("here is a string: '{}' here is a number: {}\n", .{
5964 a_string, a_number, a_number);5973 a_string,
5974 a_number,
5975 a_number,
5976 });
5965}5977}
5966 {#code_end#}5978 {#code_end#}
5967 <p>5979 <p>
...@@ -5979,7 +5991,7 @@ const a_string = "foobar";...@@ -5979,7 +5991,7 @@ const a_string = "foobar";
5979const fmt = "here is a string: '{}' here is a number: {}\n";5991const fmt = "here is a string: '{}' here is a number: {}\n";
59805992
5981pub fn main() void {5993pub fn main() void {
5982 warn(fmt, a_string, a_number);5994 warn(fmt, .{a_string, a_number});
5983}5995}
5984 {#code_end#}5996 {#code_end#}
5985 <p>5997 <p>
...@@ -6417,7 +6429,7 @@ pub fn main() void {...@@ -6417,7 +6429,7 @@ pub fn main() void {
64176429
6418fn amainWrap() void {6430fn amainWrap() void {
6419 amain() catch |e| {6431 amain() catch |e| {
6420 std.debug.warn("{}\n", e);6432 std.debug.warn("{}\n", .{e});
6421 if (@errorReturnTrace()) |trace| {6433 if (@errorReturnTrace()) |trace| {
6422 std.debug.dumpStackTrace(trace.*);6434 std.debug.dumpStackTrace(trace.*);
6423 }6435 }
...@@ -6447,8 +6459,8 @@ fn amain() !void {...@@ -6447,8 +6459,8 @@ fn amain() !void {
6447 const download_text = try await download_frame;6459 const download_text = try await download_frame;
6448 defer allocator.free(download_text);6460 defer allocator.free(download_text);
64496461
6450 std.debug.warn("download_text: {}\n", download_text);6462 std.debug.warn("download_text: {}\n", .{download_text});
6451 std.debug.warn("file_text: {}\n", file_text);6463 std.debug.warn("file_text: {}\n", .{file_text});
6452}6464}
64536465
6454var global_download_frame: anyframe = undefined;6466var global_download_frame: anyframe = undefined;
...@@ -6458,7 +6470,7 @@ fn fetchUrl(allocator: *Allocator, url: []const u8) ![]u8 {...@@ -6458,7 +6470,7 @@ fn fetchUrl(allocator: *Allocator, url: []const u8) ![]u8 {
6458 suspend {6470 suspend {
6459 global_download_frame = @frame();6471 global_download_frame = @frame();
6460 }6472 }
6461 std.debug.warn("fetchUrl returning\n");6473 std.debug.warn("fetchUrl returning\n", .{});
6462 return result;6474 return result;
6463}6475}
64646476
...@@ -6469,7 +6481,7 @@ fn readFile(allocator: *Allocator, filename: []const u8) ![]u8 {...@@ -6469,7 +6481,7 @@ fn readFile(allocator: *Allocator, filename: []const u8) ![]u8 {
6469 suspend {6481 suspend {
6470 global_file_frame = @frame();6482 global_file_frame = @frame();
6471 }6483 }
6472 std.debug.warn("readFile returning\n");6484 std.debug.warn("readFile returning\n", .{});
6473 return result;6485 return result;
6474}6486}
6475 {#code_end#}6487 {#code_end#}
...@@ -6487,7 +6499,7 @@ pub fn main() void {...@@ -6487,7 +6499,7 @@ pub fn main() void {
64876499
6488fn amainWrap() void {6500fn amainWrap() void {
6489 amain() catch |e| {6501 amain() catch |e| {
6490 std.debug.warn("{}\n", e);6502 std.debug.warn("{}\n", .{e});
6491 if (@errorReturnTrace()) |trace| {6503 if (@errorReturnTrace()) |trace| {
6492 std.debug.dumpStackTrace(trace.*);6504 std.debug.dumpStackTrace(trace.*);
6493 }6505 }
...@@ -6517,21 +6529,21 @@ fn amain() !void {...@@ -6517,21 +6529,21 @@ fn amain() !void {
6517 const download_text = try await download_frame;6529 const download_text = try await download_frame;
6518 defer allocator.free(download_text);6530 defer allocator.free(download_text);
65196531
6520 std.debug.warn("download_text: {}\n", download_text);6532 std.debug.warn("download_text: {}\n", .{download_text});
6521 std.debug.warn("file_text: {}\n", file_text);6533 std.debug.warn("file_text: {}\n", .{file_text});
6522}6534}
65236535
6524fn fetchUrl(allocator: *Allocator, url: []const u8) ![]u8 {6536fn fetchUrl(allocator: *Allocator, url: []const u8) ![]u8 {
6525 const result = try std.mem.dupe(allocator, u8, "this is the downloaded url contents");6537 const result = try std.mem.dupe(allocator, u8, "this is the downloaded url contents");
6526 errdefer allocator.free(result);6538 errdefer allocator.free(result);
6527 std.debug.warn("fetchUrl returning\n");6539 std.debug.warn("fetchUrl returning\n", .{});
6528 return result;6540 return result;
6529}6541}
65306542
6531fn readFile(allocator: *Allocator, filename: []const u8) ![]u8 {6543fn readFile(allocator: *Allocator, filename: []const u8) ![]u8 {
6532 const result = try std.mem.dupe(allocator, u8, "this is the file contents");6544 const result = try std.mem.dupe(allocator, u8, "this is the file contents");
6533 errdefer allocator.free(result);6545 errdefer allocator.free(result);
6534 std.debug.warn("readFile returning\n");6546 std.debug.warn("readFile returning\n", .{});
6535 return result;6547 return result;
6536}6548}
6537 {#code_end#}6549 {#code_end#}
...@@ -7103,7 +7115,7 @@ const num1 = blk: {...@@ -7103,7 +7115,7 @@ const num1 = blk: {
7103test "main" {7115test "main" {
7104 @compileLog("comptime in main");7116 @compileLog("comptime in main");
71057117
7106 warn("Runtime in main, num1 = {}.\n", num1);7118 warn("Runtime in main, num1 = {}.\n", .{num1});
7107}7119}
7108 {#code_end#}7120 {#code_end#}
7109 <p>7121 <p>
...@@ -7124,7 +7136,7 @@ const num1 = blk: {...@@ -7124,7 +7136,7 @@ const num1 = blk: {
7124};7136};
71257137
7126test "main" {7138test "main" {
7127 warn("Runtime in main, num1 = {}.\n", num1);7139 warn("Runtime in main, num1 = {}.\n", .{num1});
7128}7140}
7129 {#code_end#}7141 {#code_end#}
7130 {#header_close#}7142 {#header_close#}
...@@ -8706,7 +8718,7 @@ const std = @import("std");...@@ -8706,7 +8718,7 @@ const std = @import("std");
8706pub fn main() void {8718pub fn main() void {
8707 var value: i32 = -1;8719 var value: i32 = -1;
8708 var unsigned = @intCast(u32, value);8720 var unsigned = @intCast(u32, value);
8709 std.debug.warn("value: {}\n", unsigned);8721 std.debug.warn("value: {}\n", .{unsigned});
8710}8722}
8711 {#code_end#}8723 {#code_end#}
8712 <p>8724 <p>
...@@ -8728,7 +8740,7 @@ const std = @import("std");...@@ -8728,7 +8740,7 @@ const std = @import("std");
8728pub fn main() void {8740pub fn main() void {
8729 var spartan_count: u16 = 300;8741 var spartan_count: u16 = 300;
8730 const byte = @intCast(u8, spartan_count);8742 const byte = @intCast(u8, spartan_count);
8731 std.debug.warn("value: {}\n", byte);8743 std.debug.warn("value: {}\n", .{byte});
8732}8744}
8733 {#code_end#}8745 {#code_end#}
8734 <p>8746 <p>
...@@ -8762,7 +8774,7 @@ const std = @import("std");...@@ -8762,7 +8774,7 @@ const std = @import("std");
8762pub fn main() void {8774pub fn main() void {
8763 var byte: u8 = 255;8775 var byte: u8 = 255;
8764 byte += 1;8776 byte += 1;
8765 std.debug.warn("value: {}\n", byte);8777 std.debug.warn("value: {}\n", .{byte});
8766}8778}
8767 {#code_end#}8779 {#code_end#}
8768 {#header_close#}8780 {#header_close#}
...@@ -8785,11 +8797,11 @@ pub fn main() !void {...@@ -8785,11 +8797,11 @@ pub fn main() !void {
8785 var byte: u8 = 255;8797 var byte: u8 = 255;
87868798
8787 byte = if (math.add(u8, byte, 1)) |result| result else |err| {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 return err;8801 return err;
8790 };8802 };
87918803
8792 warn("result: {}\n", byte);8804 warn("result: {}\n", .{byte});
8793}8805}
8794 {#code_end#}8806 {#code_end#}
8795 {#header_close#}8807 {#header_close#}
...@@ -8814,9 +8826,9 @@ pub fn main() void {...@@ -8814,9 +8826,9 @@ pub fn main() void {
88148826
8815 var result: u8 = undefined;8827 var result: u8 = undefined;
8816 if (@addWithOverflow(u8, byte, 10, &result)) {8828 if (@addWithOverflow(u8, byte, 10, &result)) {
8817 warn("overflowed result: {}\n", result);8829 warn("overflowed result: {}\n", .{result});
8818 } else {8830 } else {
8819 warn("result: {}\n", result);8831 warn("result: {}\n", .{result});
8820 }8832 }
8821}8833}
8822 {#code_end#}8834 {#code_end#}
...@@ -8861,7 +8873,7 @@ const std = @import("std");...@@ -8861,7 +8873,7 @@ const std = @import("std");
8861pub fn main() void {8873pub fn main() void {
8862 var x: u8 = 0b01010101;8874 var x: u8 = 0b01010101;
8863 var y = @shlExact(x, 2);8875 var y = @shlExact(x, 2);
8864 std.debug.warn("value: {}\n", y);8876 std.debug.warn("value: {}\n", .{y});
8865}8877}
8866 {#code_end#}8878 {#code_end#}
8867 {#header_close#}8879 {#header_close#}
...@@ -8879,7 +8891,7 @@ const std = @import("std");...@@ -8879,7 +8891,7 @@ const std = @import("std");
8879pub fn main() void {8891pub fn main() void {
8880 var x: u8 = 0b10101010;8892 var x: u8 = 0b10101010;
8881 var y = @shrExact(x, 2);8893 var y = @shrExact(x, 2);
8882 std.debug.warn("value: {}\n", y);8894 std.debug.warn("value: {}\n", .{y});
8883}8895}
8884 {#code_end#}8896 {#code_end#}
8885 {#header_close#}8897 {#header_close#}
...@@ -8900,7 +8912,7 @@ pub fn main() void {...@@ -8900,7 +8912,7 @@ pub fn main() void {
8900 var a: u32 = 1;8912 var a: u32 = 1;
8901 var b: u32 = 0;8913 var b: u32 = 0;
8902 var c = a / b;8914 var c = a / b;
8903 std.debug.warn("value: {}\n", c);8915 std.debug.warn("value: {}\n", .{c});
8904}8916}
8905 {#code_end#}8917 {#code_end#}
8906 {#header_close#}8918 {#header_close#}
...@@ -8921,7 +8933,7 @@ pub fn main() void {...@@ -8921,7 +8933,7 @@ pub fn main() void {
8921 var a: u32 = 10;8933 var a: u32 = 10;
8922 var b: u32 = 0;8934 var b: u32 = 0;
8923 var c = a % b;8935 var c = a % b;
8924 std.debug.warn("value: {}\n", c);8936 std.debug.warn("value: {}\n", .{c});
8925}8937}
8926 {#code_end#}8938 {#code_end#}
8927 {#header_close#}8939 {#header_close#}
...@@ -8942,7 +8954,7 @@ pub fn main() void {...@@ -8942,7 +8954,7 @@ pub fn main() void {
8942 var a: u32 = 10;8954 var a: u32 = 10;
8943 var b: u32 = 3;8955 var b: u32 = 3;
8944 var c = @divExact(a, b);8956 var c = @divExact(a, b);
8945 std.debug.warn("value: {}\n", c);8957 std.debug.warn("value: {}\n", .{c});
8946}8958}
8947 {#code_end#}8959 {#code_end#}
8948 {#header_close#}8960 {#header_close#}
...@@ -8961,7 +8973,7 @@ const std = @import("std");...@@ -8961,7 +8973,7 @@ const std = @import("std");
8961pub fn main() void {8973pub fn main() void {
8962 var bytes = [5]u8{ 1, 2, 3, 4, 5 };8974 var bytes = [5]u8{ 1, 2, 3, 4, 5 };
8963 var slice = @bytesToSlice(u32, bytes[0..]);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 {#code_end#}8978 {#code_end#}
8967 {#header_close#}8979 {#header_close#}
...@@ -8980,7 +8992,7 @@ const std = @import("std");...@@ -8980,7 +8992,7 @@ const std = @import("std");
8980pub fn main() void {8992pub fn main() void {
8981 var optional_number: ?i32 = null;8993 var optional_number: ?i32 = null;
8982 var number = optional_number.?;8994 var number = optional_number.?;
8983 std.debug.warn("value: {}\n", number);8995 std.debug.warn("value: {}\n", .{number});
8984}8996}
8985 {#code_end#}8997 {#code_end#}
8986 <p>One way to avoid this crash is to test for null instead of assuming non-null, with8998 <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,9 +9003,9 @@ pub fn main() void {
8991 const optional_number: ?i32 = null;9003 const optional_number: ?i32 = null;
89929004
8993 if (optional_number) |number| {9005 if (optional_number) |number| {
8994 warn("got number: {}\n", number);9006 warn("got number: {}\n", .{number});
8995 } else {9007 } else {
8996 warn("it's null\n");9008 warn("it's null\n", .{});
8997 }9009 }
8998}9010}
8999 {#code_end#}9011 {#code_end#}
...@@ -9016,7 +9028,7 @@ const std = @import("std");...@@ -9016,7 +9028,7 @@ const std = @import("std");
90169028
9017pub fn main() void {9029pub fn main() void {
9018 const number = getNumberOrFail() catch unreachable;9030 const number = getNumberOrFail() catch unreachable;
9019 std.debug.warn("value: {}\n", number);9031 std.debug.warn("value: {}\n", .{number});
9020}9032}
90219033
9022fn getNumberOrFail() !i32 {9034fn getNumberOrFail() !i32 {
...@@ -9032,9 +9044,9 @@ pub fn main() void {...@@ -9032,9 +9044,9 @@ pub fn main() void {
9032 const result = getNumberOrFail();9044 const result = getNumberOrFail();
90339045
9034 if (result) |number| {9046 if (result) |number| {
9035 warn("got number: {}\n", number);9047 warn("got number: {}\n", .{number});
9036 } else |err| {9048 } else |err| {
9037 warn("got error: {}\n", @errorName(err));9049 warn("got error: {}\n", .{@errorName(err)});
9038 }9050 }
9039}9051}
90409052
...@@ -9061,7 +9073,7 @@ pub fn main() void {...@@ -9061,7 +9073,7 @@ pub fn main() void {
9061 var err = error.AnError;9073 var err = error.AnError;
9062 var number = @errorToInt(err) + 500;9074 var number = @errorToInt(err) + 500;
9063 var invalid_err = @intToError(number);9075 var invalid_err = @intToError(number);
9064 std.debug.warn("value: {}\n", number);9076 std.debug.warn("value: {}\n", .{number});
9065}9077}
9066 {#code_end#}9078 {#code_end#}
9067 {#header_close#}9079 {#header_close#}
...@@ -9091,7 +9103,7 @@ const Foo = enum {...@@ -9091,7 +9103,7 @@ const Foo = enum {
9091pub fn main() void {9103pub fn main() void {
9092 var a: u2 = 3;9104 var a: u2 = 3;
9093 var b = @intToEnum(Foo, a);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 {#code_end#}9108 {#code_end#}
9097 {#header_close#}9109 {#header_close#}
...@@ -9128,7 +9140,7 @@ pub fn main() void {...@@ -9128,7 +9140,7 @@ pub fn main() void {
9128}9140}
9129fn foo(set1: Set1) void {9141fn foo(set1: Set1) void {
9130 const x = @errSetCast(Set2, set1);9142 const x = @errSetCast(Set2, set1);
9131 std.debug.warn("value: {}\n", x);9143 std.debug.warn("value: {}\n", .{x});
9132}9144}
9133 {#code_end#}9145 {#code_end#}
9134 {#header_close#}9146 {#header_close#}
...@@ -9184,7 +9196,7 @@ pub fn main() void {...@@ -9184,7 +9196,7 @@ pub fn main() void {
91849196
9185fn bar(f: *Foo) void {9197fn bar(f: *Foo) void {
9186 f.float = 12.34;9198 f.float = 12.34;
9187 std.debug.warn("value: {}\n", f.float);9199 std.debug.warn("value: {}\n", .{f.float});
9188}9200}
9189 {#code_end#}9201 {#code_end#}
9190 <p>9202 <p>
...@@ -9208,7 +9220,7 @@ pub fn main() void {...@@ -9208,7 +9220,7 @@ pub fn main() void {
92089220
9209fn bar(f: *Foo) void {9221fn bar(f: *Foo) void {
9210 f.* = Foo{ .float = 12.34 };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 {#code_end#}9225 {#code_end#}
9214 <p>9226 <p>
...@@ -9227,7 +9239,7 @@ pub fn main() void {...@@ -9227,7 +9239,7 @@ pub fn main() void {
9227 var f = Foo{ .int = 42 };9239 var f = Foo{ .int = 42 };
9228 f = Foo{ .float = undefined };9240 f = Foo{ .float = undefined };
9229 bar(&f);9241 bar(&f);
9230 std.debug.warn("value: {}\n", f.float);9242 std.debug.warn("value: {}\n", .{f.float});
9231}9243}
92329244
9233fn bar(f: *Foo) void {9245fn bar(f: *Foo) void {
...@@ -9348,7 +9360,7 @@ pub fn main() !void {...@@ -9348,7 +9360,7 @@ pub fn main() !void {
9348 const allocator = &arena.allocator;9360 const allocator = &arena.allocator;
93499361
9350 const ptr = try allocator.create(i32);9362 const ptr = try allocator.create(i32);
9351 std.debug.warn("ptr={*}\n", ptr);9363 std.debug.warn("ptr={*}\n", .{ptr});
9352}9364}
9353 {#code_end#}9365 {#code_end#}
9354 When using this kind of allocator, there is no need to free anything manually. Everything9366 When using this kind of allocator, there is no need to free anything manually. Everything
...@@ -9881,7 +9893,7 @@ pub fn main() !void {...@@ -9881,7 +9893,7 @@ pub fn main() !void {
9881 defer std.process.argsFree(std.heap.page_allocator, args);9893 defer std.process.argsFree(std.heap.page_allocator, args);
98829894
9883 for (args) |arg, i| {9895 for (args) |arg, i| {
9884 std.debug.warn("{}: {}\n", i, arg);9896 std.debug.warn("{}: {}\n", .{i, arg});
9885 }9897 }
9886}9898}
9887 {#code_end#}9899 {#code_end#}
lib/std/os/windows.zig+1-1
...@@ -323,7 +323,7 @@ pub fn GetQueuedCompletionStatus(...@@ -323,7 +323,7 @@ pub fn GetQueuedCompletionStatus(
323 ERROR.HANDLE_EOF => return GetQueuedCompletionStatusResult.EOF,323 ERROR.HANDLE_EOF => return GetQueuedCompletionStatusResult.EOF,
324 else => |err| {324 else => |err| {
325 if (std.debug.runtime_safety) {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 }
src-self-hosted/stage1.zig+1-1
...@@ -149,7 +149,7 @@ export fn stage2_fmt(argc: c_int, argv: [*]const [*:0]const u8) c_int {...@@ -149,7 +149,7 @@ export fn stage2_fmt(argc: c_int, argv: [*]const [*:0]const u8) c_int {
149 fmtMain(argc, argv) catch unreachable;149 fmtMain(argc, argv) catch unreachable;
150 } else {150 } else {
151 fmtMain(argc, argv) catch |e| {151 fmtMain(argc, argv) catch |e| {
152 std.debug.warn("{}\n", @errorName(e));152 std.debug.warn("{}\n", .{@errorName(e)});
153 return -1;153 return -1;
154 };154 };
155 }155 }