authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-01-02 19:03:14-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-01-02 19:03:14-07:00
log974c008a0ee0e0d7933e37d5ea930f712d494f6a
treec12b14dceebe7f6055fe07cfed2780d2b5c7bf60
parent5b981b1be7b387a3f51d60b8642064e6642b956c

convert more {} to {d} and {s}


23 files changed, 97 insertions(+), 97 deletions(-)

lib/std/SemanticVersion.zig+1-1
...@@ -163,7 +163,7 @@ pub fn format(...@@ -163,7 +163,7 @@ pub fn format(
163 out_stream: anytype,163 out_stream: anytype,
164) !void {164) !void {
165 if (fmt.len != 0) @compileError("Unknown format string: '" ++ fmt ++ "'");165 if (fmt.len != 0) @compileError("Unknown format string: '" ++ fmt ++ "'");
166 try std.fmt.format(out_stream, "{}.{}.{}", .{ self.major, self.minor, self.patch });166 try std.fmt.format(out_stream, "{d}.{d}.{d}", .{ self.major, self.minor, self.patch });
167 if (self.pre) |pre| try std.fmt.format(out_stream, "-{s}", .{pre});167 if (self.pre) |pre| try std.fmt.format(out_stream, "-{s}", .{pre});
168 if (self.build) |build| try std.fmt.format(out_stream, "+{s}", .{build});168 if (self.build) |build| try std.fmt.format(out_stream, "+{s}", .{build});
169}169}
lib/std/c/ast.zig+4-4
...@@ -115,10 +115,10 @@ pub const Error = union(enum) {...@@ -115,10 +115,10 @@ pub const Error = union(enum) {
115 pub fn render(self: *const ExpectedToken, tree: *Tree, stream: anytype) !void {115 pub fn render(self: *const ExpectedToken, tree: *Tree, stream: anytype) !void {
116 const found_token = tree.tokens.at(self.token);116 const found_token = tree.tokens.at(self.token);
117 if (found_token.id == .Invalid) {117 if (found_token.id == .Invalid) {
118 return stream.print("expected '{}', found invalid bytes", .{self.expected_id.symbol()});118 return stream.print("expected '{s}', found invalid bytes", .{self.expected_id.symbol()});
119 } else {119 } else {
120 const token_name = found_token.id.symbol();120 const token_name = found_token.id.symbol();
121 return stream.print("expected '{}', found '{}'", .{ self.expected_id.symbol(), token_name });121 return stream.print("expected '{s}', found '{s}'", .{ self.expected_id.symbol(), token_name });
122 }122 }
123 }123 }
124 };124 };
...@@ -131,7 +131,7 @@ pub const Error = union(enum) {...@@ -131,7 +131,7 @@ pub const Error = union(enum) {
131 try stream.write("invalid type specifier '");131 try stream.write("invalid type specifier '");
132 try type_spec.spec.print(tree, stream);132 try type_spec.spec.print(tree, stream);
133 const token_name = tree.tokens.at(self.token).id.symbol();133 const token_name = tree.tokens.at(self.token).id.symbol();
134 return stream.print("{}'", .{token_name});134 return stream.print("{s}'", .{token_name});
135 }135 }
136 };136 };
137137
...@@ -140,7 +140,7 @@ pub const Error = union(enum) {...@@ -140,7 +140,7 @@ pub const Error = union(enum) {
140 name: TokenIndex,140 name: TokenIndex,
141141
142 pub fn render(self: *const ExpectedToken, tree: *Tree, stream: anytype) !void {142 pub fn render(self: *const ExpectedToken, tree: *Tree, stream: anytype) !void {
143 return stream.print("must use '{}' tag to refer to type '{}'", .{ tree.slice(kw), tree.slice(name) });143 return stream.print("must use '{s}' tag to refer to type '{s}'", .{ tree.slice(kw), tree.slice(name) });
144 }144 }
145 };145 };
146146
lib/std/fs/wasi.zig+1-1
...@@ -38,7 +38,7 @@ pub const PreopenType = union(PreopenTypeTag) {...@@ -38,7 +38,7 @@ pub const PreopenType = union(PreopenTypeTag) {
38 pub fn format(self: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, out_stream: anytype) !void {38 pub fn format(self: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, out_stream: anytype) !void {
39 try out_stream.print("PreopenType{{ ", .{});39 try out_stream.print("PreopenType{{ ", .{});
40 switch (self) {40 switch (self) {
41 PreopenType.Dir => |path| try out_stream.print(".Dir = '{}'", .{path}),41 PreopenType.Dir => |path| try out_stream.print(".Dir = '{z}'", .{path}),
42 }42 }
43 return out_stream.print(" }}", .{});43 return out_stream.print(" }}", .{});
44 }44 }
lib/std/os.zig+2-2
...@@ -4256,7 +4256,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {...@@ -4256,7 +4256,7 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {
4256 },4256 },
4257 .linux => {4257 .linux => {
4258 var procfs_buf: ["/proc/self/fd/-2147483648".len:0]u8 = undefined;4258 var procfs_buf: ["/proc/self/fd/-2147483648".len:0]u8 = undefined;
4259 const proc_path = std.fmt.bufPrint(procfs_buf[0..], "/proc/self/fd/{}\x00", .{fd}) catch unreachable;4259 const proc_path = std.fmt.bufPrint(procfs_buf[0..], "/proc/self/fd/{d}\x00", .{fd}) catch unreachable;
42604260
4261 const target = readlinkZ(std.meta.assumeSentinel(proc_path.ptr, 0), out_buffer) catch |err| {4261 const target = readlinkZ(std.meta.assumeSentinel(proc_path.ptr, 0), out_buffer) catch |err| {
4262 switch (err) {4262 switch (err) {
...@@ -4487,7 +4487,7 @@ pub const UnexpectedError = error{...@@ -4487,7 +4487,7 @@ pub const UnexpectedError = error{
4487/// and you get an unexpected error.4487/// and you get an unexpected error.
4488pub fn unexpectedErrno(err: usize) UnexpectedError {4488pub fn unexpectedErrno(err: usize) UnexpectedError {
4489 if (unexpected_error_tracing) {4489 if (unexpected_error_tracing) {
4490 std.debug.warn("unexpected errno: {}\n", .{err});4490 std.debug.warn("unexpected errno: {d}\n", .{err});
4491 std.debug.dumpCurrentStackTrace(null);4491 std.debug.dumpCurrentStackTrace(null);
4492 }4492 }
4493 return error.Unexpected;4493 return error.Unexpected;
lib/std/special/c.zig+1-1
...@@ -172,7 +172,7 @@ test "strncmp" {...@@ -172,7 +172,7 @@ test "strncmp" {
172pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {172pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
173 if (builtin.is_test) {173 if (builtin.is_test) {
174 @setCold(true);174 @setCold(true);
175 std.debug.panic("{}", .{msg});175 std.debug.panic("{s}", .{msg});
176 }176 }
177 if (builtin.os.tag != .freestanding and builtin.os.tag != .other) {177 if (builtin.os.tag != .freestanding and builtin.os.tag != .other) {
178 std.os.abort();178 std.os.abort();
lib/std/special/compiler_rt.zig+1-1
...@@ -324,7 +324,7 @@ pub usingnamespace @import("compiler_rt/atomics.zig");...@@ -324,7 +324,7 @@ pub usingnamespace @import("compiler_rt/atomics.zig");
324pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {324pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
325 @setCold(true);325 @setCold(true);
326 if (is_test) {326 if (is_test) {
327 std.debug.panic("{}", .{msg});327 std.debug.panic("{s}", .{msg});
328 } else {328 } else {
329 unreachable;329 unreachable;
330 }330 }
lib/std/testing.zig+1-1
...@@ -258,7 +258,7 @@ pub fn expectEqualSlices(comptime T: type, expected: []const T, actual: []const...@@ -258,7 +258,7 @@ pub fn expectEqualSlices(comptime T: type, expected: []const T, actual: []const
258 // If the child type is u8 and no weird bytes, we could print it as strings258 // If the child type is u8 and no weird bytes, we could print it as strings
259 // Even for the length difference, it would be useful to see the values of the slices probably.259 // Even for the length difference, it would be useful to see the values of the slices probably.
260 if (expected.len != actual.len) {260 if (expected.len != actual.len) {
261 std.debug.panic("slice lengths differ. expected {}, found {}", .{ expected.len, actual.len });261 std.debug.panic("slice lengths differ. expected {d}, found {d}", .{ expected.len, actual.len });
262 }262 }
263 var i: usize = 0;263 var i: usize = 0;
264 while (i < expected.len) : (i += 1) {264 while (i < expected.len) : (i += 1) {
lib/std/zig/parser_test.zig+2-2
...@@ -3742,7 +3742,7 @@ fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *b...@@ -3742,7 +3742,7 @@ fn testParse(source: []const u8, allocator: *mem.Allocator, anything_changed: *b
3742 for (tree.errors) |*parse_error| {3742 for (tree.errors) |*parse_error| {
3743 const token = tree.token_locs[parse_error.loc()];3743 const token = tree.token_locs[parse_error.loc()];
3744 const loc = tree.tokenLocation(0, parse_error.loc());3744 const loc = tree.tokenLocation(0, parse_error.loc());
3745 try stderr.print("(memory buffer):{}:{}: error: ", .{ loc.line + 1, loc.column + 1 });3745 try stderr.print("(memory buffer):{d}:{d}: error: ", .{ loc.line + 1, loc.column + 1 });
3746 try tree.renderError(parse_error, stderr);3746 try tree.renderError(parse_error, stderr);
3747 try stderr.print("\n{s}\n", .{source[loc.line_start..loc.line_end]});3747 try stderr.print("\n{s}\n", .{source[loc.line_start..loc.line_end]});
3748 {3748 {
...@@ -3800,7 +3800,7 @@ fn testTransform(source: []const u8, expected_source: []const u8) !void {...@@ -3800,7 +3800,7 @@ fn testTransform(source: []const u8, expected_source: []const u8) !void {
3800 error.OutOfMemory => {3800 error.OutOfMemory => {
3801 if (failing_allocator.allocated_bytes != failing_allocator.freed_bytes) {3801 if (failing_allocator.allocated_bytes != failing_allocator.freed_bytes) {
3802 warn(3802 warn(
3803 "\nfail_index: {}/{}\nallocated bytes: {}\nfreed bytes: {}\nallocations: {}\ndeallocations: {}\n",3803 "\nfail_index: {d}/{d}\nallocated bytes: {d}\nfreed bytes: {d}\nallocations: {d}\ndeallocations: {d}\n",
3804 .{3804 .{
3805 fail_index,3805 fail_index,
3806 needed_alloc_count,3806 needed_alloc_count,
lib/std/zig/system/macos.zig+2-2
...@@ -450,7 +450,7 @@ test "version_from_build" {...@@ -450,7 +450,7 @@ test "version_from_build" {
450 for (known) |pair| {450 for (known) |pair| {
451 var buf: [32]u8 = undefined;451 var buf: [32]u8 = undefined;
452 const ver = try version_from_build(pair[0]);452 const ver = try version_from_build(pair[0]);
453 const sver = try std.fmt.bufPrint(buf[0..], "{}.{}.{}", .{ ver.major, ver.minor, ver.patch });453 const sver = try std.fmt.bufPrint(buf[0..], "{d}.{d}.{d}", .{ ver.major, ver.minor, ver.patch });
454 std.testing.expect(std.mem.eql(u8, sver, pair[1]));454 std.testing.expect(std.mem.eql(u8, sver, pair[1]));
455 }455 }
456}456}
...@@ -468,7 +468,7 @@ pub fn getSDKPath(allocator: *mem.Allocator) ![]u8 {...@@ -468,7 +468,7 @@ pub fn getSDKPath(allocator: *mem.Allocator) ![]u8 {
468 allocator.free(result.stdout);468 allocator.free(result.stdout);
469 }469 }
470 if (result.stderr.len != 0) {470 if (result.stderr.len != 0) {
471 std.log.err("unexpected 'xcrun --show-sdk-path' stderr: {}", .{result.stderr});471 std.log.err("unexpected 'xcrun --show-sdk-path' stderr: {s}", .{result.stderr});
472 }472 }
473 if (result.term.Exited != 0) {473 if (result.term.Exited != 0) {
474 return error.ProcessTerminated;474 return error.ProcessTerminated;
src/Compilation.zig+6-6
...@@ -1512,7 +1512,7 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor...@@ -1512,7 +1512,7 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor
1512 module.failed_decls.putAssumeCapacityNoClobber(decl, try ErrorMsg.create(1512 module.failed_decls.putAssumeCapacityNoClobber(decl, try ErrorMsg.create(
1513 module.gpa,1513 module.gpa,
1514 decl.src(),1514 decl.src(),
1515 "unable to generate C header: {}",1515 "unable to generate C header: {s}",
1516 .{@errorName(err)},1516 .{@errorName(err)},
1517 ));1517 ));
1518 decl.analysis = .codegen_failure_retryable;1518 decl.analysis = .codegen_failure_retryable;
...@@ -1593,7 +1593,7 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor...@@ -1593,7 +1593,7 @@ pub fn performAllTheWork(self: *Compilation) error{ TimerUnsupported, OutOfMemor
1593 .libtsan => {1593 .libtsan => {
1594 libtsan.buildTsan(self) catch |err| {1594 libtsan.buildTsan(self) catch |err| {
1595 // TODO Expose this as a normal compile error rather than crashing here.1595 // TODO Expose this as a normal compile error rather than crashing here.
1596 fatal("unable to build TSAN library: {}", .{@errorName(err)});1596 fatal("unable to build TSAN library: {s}", .{@errorName(err)});
1597 };1597 };
1598 },1598 },
1599 .compiler_rt_lib => {1599 .compiler_rt_lib => {
...@@ -1983,7 +1983,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_comp_progress_node: *...@@ -1983,7 +1983,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_comp_progress_node: *
1983 // TODO parse clang stderr and turn it into an error message1983 // TODO parse clang stderr and turn it into an error message
1984 // and then call failCObjWithOwnedErrorMsg1984 // and then call failCObjWithOwnedErrorMsg
1985 log.err("clang failed with stderr: {s}", .{stderr});1985 log.err("clang failed with stderr: {s}", .{stderr});
1986 return comp.failCObj(c_object, "clang exited with code {}", .{code});1986 return comp.failCObj(c_object, "clang exited with code {d}", .{code});
1987 }1987 }
1988 },1988 },
1989 else => {1989 else => {
...@@ -3013,7 +3013,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node...@@ -3013,7 +3013,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node
3013 id_symlink_basename,3013 id_symlink_basename,
3014 &prev_digest_buf,3014 &prev_digest_buf,
3015 ) catch |err| blk: {3015 ) catch |err| blk: {
3016 log.debug("stage1 {} new_digest={} error: {s}", .{ mod.root_pkg.root_src_path, digest, @errorName(err) });3016 log.debug("stage1 {s} new_digest={} error: {s}", .{ mod.root_pkg.root_src_path, digest, @errorName(err) });
3017 // Handle this as a cache miss.3017 // Handle this as a cache miss.
3018 break :blk prev_digest_buf[0..0];3018 break :blk prev_digest_buf[0..0];
3019 };3019 };
...@@ -3021,7 +3021,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node...@@ -3021,7 +3021,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node
3021 if (!mem.eql(u8, prev_digest[0..digest.len], &digest))3021 if (!mem.eql(u8, prev_digest[0..digest.len], &digest))
3022 break :hit;3022 break :hit;
30233023
3024 log.debug("stage1 {} digest={} match - skipping invocation", .{ mod.root_pkg.root_src_path, digest });3024 log.debug("stage1 {s} digest={} match - skipping invocation", .{ mod.root_pkg.root_src_path, digest });
3025 var flags_bytes: [1]u8 = undefined;3025 var flags_bytes: [1]u8 = undefined;
3026 _ = std.fmt.hexToBytes(&flags_bytes, prev_digest[digest.len..]) catch {3026 _ = std.fmt.hexToBytes(&flags_bytes, prev_digest[digest.len..]) catch {
3027 log.warn("bad cache stage1 digest: '{s}'", .{prev_digest});3027 log.warn("bad cache stage1 digest: '{s}'", .{prev_digest});
...@@ -3044,7 +3044,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node...@@ -3044,7 +3044,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node
3044 mod.stage1_flags = @bitCast(@TypeOf(mod.stage1_flags), flags_bytes[0]);3044 mod.stage1_flags = @bitCast(@TypeOf(mod.stage1_flags), flags_bytes[0]);
3045 return;3045 return;
3046 }3046 }
3047 log.debug("stage1 {} prev_digest={} new_digest={}", .{ mod.root_pkg.root_src_path, prev_digest, digest });3047 log.debug("stage1 {s} prev_digest={} new_digest={}", .{ mod.root_pkg.root_src_path, prev_digest, digest });
3048 man.unhit(prev_hash_state, input_file_count);3048 man.unhit(prev_hash_state, input_file_count);
3049 }3049 }
30503050
src/DepTokenizer.zig+3-3
...@@ -373,7 +373,7 @@ pub const Token = union(enum) {...@@ -373,7 +373,7 @@ pub const Token = union(enum) {
373 } else {373 } else {
374 try printCharValues(writer, index_and_bytes.bytes);374 try printCharValues(writer, index_and_bytes.bytes);
375 }375 }
376 try writer.print("' at position {}", .{index_and_bytes.index});376 try writer.print("' at position {d}", .{index_and_bytes.index});
377 },377 },
378 .invalid_target,378 .invalid_target,
379 .bad_target_escape,379 .bad_target_escape,
...@@ -383,7 +383,7 @@ pub const Token = union(enum) {...@@ -383,7 +383,7 @@ pub const Token = union(enum) {
383 => |index_and_char| {383 => |index_and_char| {
384 try writer.writeAll("illegal char ");384 try writer.writeAll("illegal char ");
385 try printUnderstandableChar(writer, index_and_char.char);385 try printUnderstandableChar(writer, index_and_char.char);
386 try writer.print(" at position {}: {s}", .{ index_and_char.index, self.errStr() });386 try writer.print(" at position {d}: {s}", .{ index_and_char.index, self.errStr() });
387 },387 },
388 }388 }
389 }389 }
...@@ -943,7 +943,7 @@ fn printSection(out: anytype, label: []const u8, bytes: []const u8) !void {...@@ -943,7 +943,7 @@ fn printSection(out: anytype, label: []const u8, bytes: []const u8) !void {
943943
944fn printLabel(out: anytype, label: []const u8, bytes: []const u8) !void {944fn printLabel(out: anytype, label: []const u8, bytes: []const u8) !void {
945 var buf: [80]u8 = undefined;945 var buf: [80]u8 = undefined;
946 var text = try std.fmt.bufPrint(buf[0..], "{s} {} bytes ", .{ label, bytes.len });946 var text = try std.fmt.bufPrint(buf[0..], "{s} {d} bytes ", .{ label, bytes.len });
947 try out.writeAll(text);947 try out.writeAll(text);
948 var i: usize = text.len;948 var i: usize = text.len;
949 const end = 79;949 const end = 79;
src/Module.zig+11-11
...@@ -248,7 +248,7 @@ pub const Decl = struct {...@@ -248,7 +248,7 @@ pub const Decl = struct {
248248
249 pub fn dump(self: *Decl) void {249 pub fn dump(self: *Decl) void {
250 const loc = std.zig.findLineColumn(self.scope.source.bytes, self.src);250 const loc = std.zig.findLineColumn(self.scope.source.bytes, self.src);
251 std.debug.print("{}:{}:{} name={} status={}", .{251 std.debug.print("{s}:{d}:{d} name={s} status={s}", .{
252 self.scope.sub_file_path,252 self.scope.sub_file_path,
253 loc.line + 1,253 loc.line + 1,
254 loc.column + 1,254 loc.column + 1,
...@@ -308,7 +308,7 @@ pub const Fn = struct {...@@ -308,7 +308,7 @@ pub const Fn = struct {
308308
309 /// For debugging purposes.309 /// For debugging purposes.
310 pub fn dump(self: *Fn, mod: Module) void {310 pub fn dump(self: *Fn, mod: Module) void {
311 std.debug.print("Module.Function(name={}) ", .{self.owner_decl.name});311 std.debug.print("Module.Function(name={s}) ", .{self.owner_decl.name});
312 switch (self.analysis) {312 switch (self.analysis) {
313 .queued => {313 .queued => {
314 std.debug.print("queued\n", .{});314 std.debug.print("queued\n", .{});
...@@ -632,7 +632,7 @@ pub const Scope = struct {...@@ -632,7 +632,7 @@ pub const Scope = struct {
632632
633 pub fn dumpSrc(self: *File, src: usize) void {633 pub fn dumpSrc(self: *File, src: usize) void {
634 const loc = std.zig.findLineColumn(self.source.bytes, src);634 const loc = std.zig.findLineColumn(self.source.bytes, src);
635 std.debug.print("{}:{}:{}\n", .{ self.sub_file_path, loc.line + 1, loc.column + 1 });635 std.debug.print("{s}:{d}:{d}\n", .{ self.sub_file_path, loc.line + 1, loc.column + 1 });
636 }636 }
637637
638 pub fn getSource(self: *File, module: *Module) ![:0]const u8 {638 pub fn getSource(self: *File, module: *Module) ![:0]const u8 {
...@@ -730,7 +730,7 @@ pub const Scope = struct {...@@ -730,7 +730,7 @@ pub const Scope = struct {
730730
731 pub fn dumpSrc(self: *ZIRModule, src: usize) void {731 pub fn dumpSrc(self: *ZIRModule, src: usize) void {
732 const loc = std.zig.findLineColumn(self.source.bytes, src);732 const loc = std.zig.findLineColumn(self.source.bytes, src);
733 std.debug.print("{}:{}:{}\n", .{ self.sub_file_path, loc.line + 1, loc.column + 1 });733 std.debug.print("{s}:{d}:{d}\n", .{ self.sub_file_path, loc.line + 1, loc.column + 1 });
734 }734 }
735735
736 pub fn getSource(self: *ZIRModule, module: *Module) ![:0]const u8 {736 pub fn getSource(self: *ZIRModule, module: *Module) ![:0]const u8 {
...@@ -1641,7 +1641,7 @@ pub fn analyzeContainer(self: *Module, container_scope: *Scope.Container) !void...@@ -1641,7 +1641,7 @@ pub fn analyzeContainer(self: *Module, container_scope: *Scope.Container) !void
1641 }1641 }
1642 } else if (src_decl.castTag(.Comptime)) |comptime_node| {1642 } else if (src_decl.castTag(.Comptime)) |comptime_node| {
1643 const name_index = self.getNextAnonNameIndex();1643 const name_index = self.getNextAnonNameIndex();
1644 const name = try std.fmt.allocPrint(self.gpa, "__comptime_{}", .{name_index});1644 const name = try std.fmt.allocPrint(self.gpa, "__comptime_{d}", .{name_index});
1645 defer self.gpa.free(name);1645 defer self.gpa.free(name);
16461646
1647 const name_hash = container_scope.fullyQualifiedNameHash(name);1647 const name_hash = container_scope.fullyQualifiedNameHash(name);
...@@ -2277,7 +2277,7 @@ pub fn createAnonymousDecl(...@@ -2277,7 +2277,7 @@ pub fn createAnonymousDecl(
2277) !*Decl {2277) !*Decl {
2278 const name_index = self.getNextAnonNameIndex();2278 const name_index = self.getNextAnonNameIndex();
2279 const scope_decl = scope.decl().?;2279 const scope_decl = scope.decl().?;
2280 const name = try std.fmt.allocPrint(self.gpa, "{s}__anon_{}", .{ scope_decl.name, name_index });2280 const name = try std.fmt.allocPrint(self.gpa, "{s}__anon_{d}", .{ scope_decl.name, name_index });
2281 defer self.gpa.free(name);2281 defer self.gpa.free(name);
2282 const name_hash = scope.namespace().fullyQualifiedNameHash(name);2282 const name_hash = scope.namespace().fullyQualifiedNameHash(name);
2283 const src_hash: std.zig.SrcHash = undefined;2283 const src_hash: std.zig.SrcHash = undefined;
...@@ -2555,7 +2555,7 @@ pub fn cmpNumeric(...@@ -2555,7 +2555,7 @@ pub fn cmpNumeric(
25552555
2556 if (lhs_ty_tag == .Vector and rhs_ty_tag == .Vector) {2556 if (lhs_ty_tag == .Vector and rhs_ty_tag == .Vector) {
2557 if (lhs.ty.arrayLen() != rhs.ty.arrayLen()) {2557 if (lhs.ty.arrayLen() != rhs.ty.arrayLen()) {
2558 return self.fail(scope, src, "vector length mismatch: {} and {}", .{2558 return self.fail(scope, src, "vector length mismatch: {d} and {d}", .{
2559 lhs.ty.arrayLen(),2559 lhs.ty.arrayLen(),
2560 rhs.ty.arrayLen(),2560 rhs.ty.arrayLen(),
2561 });2561 });
...@@ -2700,7 +2700,7 @@ pub fn cmpNumeric(...@@ -2700,7 +2700,7 @@ pub fn cmpNumeric(
2700 const dest_type = if (dest_float_type) |ft| ft else blk: {2700 const dest_type = if (dest_float_type) |ft| ft else blk: {
2701 const max_bits = std.math.max(lhs_bits, rhs_bits);2701 const max_bits = std.math.max(lhs_bits, rhs_bits);
2702 const casted_bits = std.math.cast(u16, max_bits) catch |err| switch (err) {2702 const casted_bits = std.math.cast(u16, max_bits) catch |err| switch (err) {
2703 error.Overflow => return self.fail(scope, src, "{} exceeds maximum integer bit count", .{max_bits}),2703 error.Overflow => return self.fail(scope, src, "{d} exceeds maximum integer bit count", .{max_bits}),
2704 };2704 };
2705 break :blk try self.makeIntType(scope, dest_int_is_signed, casted_bits);2705 break :blk try self.makeIntType(scope, dest_int_is_signed, casted_bits);
2706 };2706 };
...@@ -3319,7 +3319,7 @@ pub fn dumpInst(self: *Module, scope: *Scope, inst: *Inst) void {...@@ -3319,7 +3319,7 @@ pub fn dumpInst(self: *Module, scope: *Scope, inst: *Inst) void {
3319 const source = zir_module.getSource(self) catch @panic("dumpInst failed to get source");3319 const source = zir_module.getSource(self) catch @panic("dumpInst failed to get source");
3320 const loc = std.zig.findLineColumn(source, inst.src);3320 const loc = std.zig.findLineColumn(source, inst.src);
3321 if (inst.tag == .constant) {3321 if (inst.tag == .constant) {
3322 std.debug.print("constant ty={} val={} src={}:{}:{}\n", .{3322 std.debug.print("constant ty={} val={} src={s}:{d}:{d}\n", .{
3323 inst.ty,3323 inst.ty,
3324 inst.castTag(.constant).?.val,3324 inst.castTag(.constant).?.val,
3325 zir_module.subFilePath(),3325 zir_module.subFilePath(),
...@@ -3327,7 +3327,7 @@ pub fn dumpInst(self: *Module, scope: *Scope, inst: *Inst) void {...@@ -3327,7 +3327,7 @@ pub fn dumpInst(self: *Module, scope: *Scope, inst: *Inst) void {
3327 loc.column + 1,3327 loc.column + 1,
3328 });3328 });
3329 } else if (inst.deaths == 0) {3329 } else if (inst.deaths == 0) {
3330 std.debug.print("{} ty={} src={}:{}:{}\n", .{3330 std.debug.print("{s} ty={} src={s}:{d}:{d}\n", .{
3331 @tagName(inst.tag),3331 @tagName(inst.tag),
3332 inst.ty,3332 inst.ty,
3333 zir_module.subFilePath(),3333 zir_module.subFilePath(),
...@@ -3335,7 +3335,7 @@ pub fn dumpInst(self: *Module, scope: *Scope, inst: *Inst) void {...@@ -3335,7 +3335,7 @@ pub fn dumpInst(self: *Module, scope: *Scope, inst: *Inst) void {
3335 loc.column + 1,3335 loc.column + 1,
3336 });3336 });
3337 } else {3337 } else {
3338 std.debug.print("{} ty={} deaths={b} src={}:{}:{}\n", .{3338 std.debug.print("{s} ty={} deaths={b} src={s}:{d}:{d}\n", .{
3339 @tagName(inst.tag),3339 @tagName(inst.tag),
3340 inst.ty,3340 inst.ty,
3341 inst.deaths,3341 inst.deaths,
src/astgen.zig+3-3
...@@ -385,7 +385,7 @@ fn breakExpr(mod: *Module, parent_scope: *Scope, node: *ast.Node.ControlFlowExpr...@@ -385,7 +385,7 @@ fn breakExpr(mod: *Module, parent_scope: *Scope, node: *ast.Node.ControlFlowExpr
385 .local_ptr => scope = scope.cast(Scope.LocalPtr).?.parent,385 .local_ptr => scope = scope.cast(Scope.LocalPtr).?.parent,
386 else => if (node.getLabel()) |break_label| {386 else => if (node.getLabel()) |break_label| {
387 const label_name = try identifierTokenString(mod, parent_scope, break_label);387 const label_name = try identifierTokenString(mod, parent_scope, break_label);
388 return mod.failTok(parent_scope, break_label, "label not found: '{}'", .{label_name});388 return mod.failTok(parent_scope, break_label, "label not found: '{s}'", .{label_name});
389 } else {389 } else {
390 return mod.failTok(parent_scope, src, "break expression outside loop", .{});390 return mod.failTok(parent_scope, src, "break expression outside loop", .{});
391 },391 },
...@@ -427,7 +427,7 @@ fn continueExpr(mod: *Module, parent_scope: *Scope, node: *ast.Node.ControlFlowE...@@ -427,7 +427,7 @@ fn continueExpr(mod: *Module, parent_scope: *Scope, node: *ast.Node.ControlFlowE
427 .local_ptr => scope = scope.cast(Scope.LocalPtr).?.parent,427 .local_ptr => scope = scope.cast(Scope.LocalPtr).?.parent,
428 else => if (node.getLabel()) |break_label| {428 else => if (node.getLabel()) |break_label| {
429 const label_name = try identifierTokenString(mod, parent_scope, break_label);429 const label_name = try identifierTokenString(mod, parent_scope, break_label);
430 return mod.failTok(parent_scope, break_label, "label not found: '{}'", .{label_name});430 return mod.failTok(parent_scope, break_label, "label not found: '{s}'", .{label_name});
431 } else {431 } else {
432 return mod.failTok(parent_scope, src, "continue expression outside loop", .{});432 return mod.failTok(parent_scope, src, "continue expression outside loop", .{});
433 },433 },
...@@ -2204,7 +2204,7 @@ fn ensureBuiltinParamCount(mod: *Module, scope: *Scope, call: *ast.Node.BuiltinC...@@ -2204,7 +2204,7 @@ fn ensureBuiltinParamCount(mod: *Module, scope: *Scope, call: *ast.Node.BuiltinC
2204 return;2204 return;
22052205
2206 const s = if (count == 1) "" else "s";2206 const s = if (count == 1) "" else "s";
2207 return mod.failTok(scope, call.builtin_token, "expected {} parameter{s}, found {}", .{ count, s, call.params_len });2207 return mod.failTok(scope, call.builtin_token, "expected {d} parameter{s}, found {d}", .{ count, s, call.params_len });
2208}2208}
22092209
2210fn simpleCast(2210fn simpleCast(
src/codegen/c.zig+3-3
...@@ -383,7 +383,7 @@ const Context = struct {...@@ -383,7 +383,7 @@ const Context = struct {
383 }383 }
384384
385 fn name(self: *Context) ![]u8 {385 fn name(self: *Context) ![]u8 {
386 const val = try std.fmt.allocPrint(&self.arena.allocator, "__temp_{}", .{self.unnamed_index});386 const val = try std.fmt.allocPrint(&self.arena.allocator, "__temp_{d}", .{self.unnamed_index});
387 self.unnamed_index += 1;387 self.unnamed_index += 1;
388 return val;388 return val;
389 }389 }
...@@ -420,7 +420,7 @@ fn genAlloc(ctx: *Context, file: *C, alloc: *Inst.NoOp) !?[]u8 {...@@ -420,7 +420,7 @@ fn genAlloc(ctx: *Context, file: *C, alloc: *Inst.NoOp) !?[]u8 {
420}420}
421421
422fn genArg(ctx: *Context) !?[]u8 {422fn genArg(ctx: *Context) !?[]u8 {
423 const name = try std.fmt.allocPrint(&ctx.arena.allocator, "arg{}", .{ctx.argdex});423 const name = try std.fmt.allocPrint(&ctx.arena.allocator, "arg{d}", .{ctx.argdex});
424 ctx.argdex += 1;424 ctx.argdex += 1;
425 return name;425 return name;
426}426}
...@@ -528,7 +528,7 @@ fn genCall(ctx: *Context, file: *C, inst: *Inst.Call) !?[]u8 {...@@ -528,7 +528,7 @@ fn genCall(ctx: *Context, file: *C, inst: *Inst.Call) !?[]u8 {
528 try renderValue(ctx, writer, arg.ty, val);528 try renderValue(ctx, writer, arg.ty, val);
529 } else {529 } else {
530 const val = try ctx.resolveInst(arg);530 const val = try ctx.resolveInst(arg);
531 try writer.print("{}", .{val});531 try writer.print("{s}", .{val});
532 }532 }
533 }533 }
534 }534 }
src/glibc.zig+14-14
...@@ -111,12 +111,12 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!...@@ -111,12 +111,12 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!
111 while (it.next()) |line| : (line_i += 1) {111 while (it.next()) |line| : (line_i += 1) {
112 const prefix = "GLIBC_";112 const prefix = "GLIBC_";
113 if (!mem.startsWith(u8, line, prefix)) {113 if (!mem.startsWith(u8, line, prefix)) {
114 std.log.err("vers.txt:{}: expected 'GLIBC_' prefix", .{line_i});114 std.log.err("vers.txt:{d}: expected 'GLIBC_' prefix", .{line_i});
115 return error.ZigInstallationCorrupt;115 return error.ZigInstallationCorrupt;
116 }116 }
117 const adjusted_line = line[prefix.len..];117 const adjusted_line = line[prefix.len..];
118 const ver = std.builtin.Version.parse(adjusted_line) catch |err| {118 const ver = std.builtin.Version.parse(adjusted_line) catch |err| {
119 std.log.err("vers.txt:{}: unable to parse glibc version '{s}': {s}", .{ line_i, line, @errorName(err) });119 std.log.err("vers.txt:{d}: unable to parse glibc version '{s}': {s}", .{ line_i, line, @errorName(err) });
120 return error.ZigInstallationCorrupt;120 return error.ZigInstallationCorrupt;
121 };121 };
122 try all_versions.append(arena, ver);122 try all_versions.append(arena, ver);
...@@ -128,15 +128,15 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!...@@ -128,15 +128,15 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!
128 while (file_it.next()) |line| : (line_i += 1) {128 while (file_it.next()) |line| : (line_i += 1) {
129 var line_it = mem.tokenize(line, " ");129 var line_it = mem.tokenize(line, " ");
130 const fn_name = line_it.next() orelse {130 const fn_name = line_it.next() orelse {
131 std.log.err("fns.txt:{}: expected function name", .{line_i});131 std.log.err("fns.txt:{d}: expected function name", .{line_i});
132 return error.ZigInstallationCorrupt;132 return error.ZigInstallationCorrupt;
133 };133 };
134 const lib_name = line_it.next() orelse {134 const lib_name = line_it.next() orelse {
135 std.log.err("fns.txt:{}: expected library name", .{line_i});135 std.log.err("fns.txt:{d}: expected library name", .{line_i});
136 return error.ZigInstallationCorrupt;136 return error.ZigInstallationCorrupt;
137 };137 };
138 const lib = findLib(lib_name) orelse {138 const lib = findLib(lib_name) orelse {
139 std.log.err("fns.txt:{}: unknown library name: {s}", .{ line_i, lib_name });139 std.log.err("fns.txt:{d}: unknown library name: {s}", .{ line_i, lib_name });
140 return error.ZigInstallationCorrupt;140 return error.ZigInstallationCorrupt;
141 };141 };
142 try all_functions.append(arena, .{142 try all_functions.append(arena, .{
...@@ -158,27 +158,27 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!...@@ -158,27 +158,27 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!
158 while (line_it.next()) |target_string| {158 while (line_it.next()) |target_string| {
159 var component_it = mem.tokenize(target_string, "-");159 var component_it = mem.tokenize(target_string, "-");
160 const arch_name = component_it.next() orelse {160 const arch_name = component_it.next() orelse {
161 std.log.err("abi.txt:{}: expected arch name", .{line_i});161 std.log.err("abi.txt:{d}: expected arch name", .{line_i});
162 return error.ZigInstallationCorrupt;162 return error.ZigInstallationCorrupt;
163 };163 };
164 const os_name = component_it.next() orelse {164 const os_name = component_it.next() orelse {
165 std.log.err("abi.txt:{}: expected OS name", .{line_i});165 std.log.err("abi.txt:{d}: expected OS name", .{line_i});
166 return error.ZigInstallationCorrupt;166 return error.ZigInstallationCorrupt;
167 };167 };
168 const abi_name = component_it.next() orelse {168 const abi_name = component_it.next() orelse {
169 std.log.err("abi.txt:{}: expected ABI name", .{line_i});169 std.log.err("abi.txt:{d}: expected ABI name", .{line_i});
170 return error.ZigInstallationCorrupt;170 return error.ZigInstallationCorrupt;
171 };171 };
172 const arch_tag = std.meta.stringToEnum(std.Target.Cpu.Arch, arch_name) orelse {172 const arch_tag = std.meta.stringToEnum(std.Target.Cpu.Arch, arch_name) orelse {
173 std.log.err("abi.txt:{}: unrecognized arch: '{s}'", .{ line_i, arch_name });173 std.log.err("abi.txt:{d}: unrecognized arch: '{s}'", .{ line_i, arch_name });
174 return error.ZigInstallationCorrupt;174 return error.ZigInstallationCorrupt;
175 };175 };
176 if (!mem.eql(u8, os_name, "linux")) {176 if (!mem.eql(u8, os_name, "linux")) {
177 std.log.err("abi.txt:{}: expected OS 'linux', found '{s}'", .{ line_i, os_name });177 std.log.err("abi.txt:{d}: expected OS 'linux', found '{s}'", .{ line_i, os_name });
178 return error.ZigInstallationCorrupt;178 return error.ZigInstallationCorrupt;
179 }179 }
180 const abi_tag = std.meta.stringToEnum(std.Target.Abi, abi_name) orelse {180 const abi_tag = std.meta.stringToEnum(std.Target.Abi, abi_name) orelse {
181 std.log.err("abi.txt:{}: unrecognized ABI: '{s}'", .{ line_i, abi_name });181 std.log.err("abi.txt:{d}: unrecognized ABI: '{s}'", .{ line_i, abi_name });
182 return error.ZigInstallationCorrupt;182 return error.ZigInstallationCorrupt;
183 };183 };
184184
...@@ -193,7 +193,7 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!...@@ -193,7 +193,7 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!
193 };193 };
194 for (ver_list_base) |*ver_list| {194 for (ver_list_base) |*ver_list| {
195 const line = file_it.next() orelse {195 const line = file_it.next() orelse {
196 std.log.err("abi.txt:{}: missing version number line", .{line_i});196 std.log.err("abi.txt:{d}: missing version number line", .{line_i});
197 return error.ZigInstallationCorrupt;197 return error.ZigInstallationCorrupt;
198 };198 };
199 line_i += 1;199 line_i += 1;
...@@ -206,12 +206,12 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!...@@ -206,12 +206,12 @@ pub fn loadMetaData(gpa: *Allocator, zig_lib_dir: std.fs.Dir) LoadMetaDataError!
206 while (line_it.next()) |version_index_string| {206 while (line_it.next()) |version_index_string| {
207 if (ver_list.len >= ver_list.versions.len) {207 if (ver_list.len >= ver_list.versions.len) {
208 // If this happens with legit data, increase the array len in the type.208 // If this happens with legit data, increase the array len in the type.
209 std.log.err("abi.txt:{}: too many versions", .{line_i});209 std.log.err("abi.txt:{d}: too many versions", .{line_i});
210 return error.ZigInstallationCorrupt;210 return error.ZigInstallationCorrupt;
211 }211 }
212 const version_index = std.fmt.parseInt(u8, version_index_string, 10) catch |err| {212 const version_index = std.fmt.parseInt(u8, version_index_string, 10) catch |err| {
213 // If this happens with legit data, increase the size of the integer type in the struct.213 // If this happens with legit data, increase the size of the integer type in the struct.
214 std.log.err("abi.txt:{}: unable to parse version: {s}", .{ line_i, @errorName(err) });214 std.log.err("abi.txt:{d}: unable to parse version: {s}", .{ line_i, @errorName(err) });
215 return error.ZigInstallationCorrupt;215 return error.ZigInstallationCorrupt;
216 };216 };
217217
src/link.zig+1-1
...@@ -523,7 +523,7 @@ pub const File = struct {...@@ -523,7 +523,7 @@ pub const File = struct {
523 id_symlink_basename,523 id_symlink_basename,
524 &prev_digest_buf,524 &prev_digest_buf,
525 ) catch |err| b: {525 ) catch |err| b: {
526 log.debug("archive new_digest={} readFile error: {}", .{ digest, @errorName(err) });526 log.debug("archive new_digest={} readFile error: {s}", .{ digest, @errorName(err) });
527 break :b prev_digest_buf[0..0];527 break :b prev_digest_buf[0..0];
528 };528 };
529 if (mem.eql(u8, prev_digest, &digest)) {529 if (mem.eql(u8, prev_digest, &digest)) {
src/link/Elf.zig+3-3
...@@ -2082,10 +2082,10 @@ pub fn allocateDeclIndexes(self: *Elf, decl: *Module.Decl) !void {...@@ -2082,10 +2082,10 @@ pub fn allocateDeclIndexes(self: *Elf, decl: *Module.Decl) !void {
2082 try self.offset_table.ensureCapacity(self.base.allocator, self.offset_table.items.len + 1);2082 try self.offset_table.ensureCapacity(self.base.allocator, self.offset_table.items.len + 1);
20832083
2084 if (self.local_symbol_free_list.popOrNull()) |i| {2084 if (self.local_symbol_free_list.popOrNull()) |i| {
2085 log.debug("reusing symbol index {} for {s}\n", .{ i, decl.name });2085 log.debug("reusing symbol index {d} for {s}\n", .{ i, decl.name });
2086 decl.link.elf.local_sym_index = i;2086 decl.link.elf.local_sym_index = i;
2087 } else {2087 } else {
2088 log.debug("allocating symbol index {} for {s}\n", .{ self.local_symbols.items.len, decl.name });2088 log.debug("allocating symbol index {d} for {s}\n", .{ self.local_symbols.items.len, decl.name });
2089 decl.link.elf.local_sym_index = @intCast(u32, self.local_symbols.items.len);2089 decl.link.elf.local_sym_index = @intCast(u32, self.local_symbols.items.len);
2090 _ = self.local_symbols.addOneAssumeCapacity();2090 _ = self.local_symbols.addOneAssumeCapacity();
2091 }2091 }
...@@ -2432,7 +2432,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void {...@@ -2432,7 +2432,7 @@ pub fn updateDecl(self: *Elf, module: *Module, decl: *Module.Decl) !void {
2432 if (needed_size > self.allocatedSize(debug_line_sect.sh_offset)) {2432 if (needed_size > self.allocatedSize(debug_line_sect.sh_offset)) {
2433 const new_offset = self.findFreeSpace(needed_size, 1);2433 const new_offset = self.findFreeSpace(needed_size, 1);
2434 const existing_size = last_src_fn.off;2434 const existing_size = last_src_fn.off;
2435 log.debug("moving .debug_line section: {} bytes from 0x{x} to 0x{x}\n", .{2435 log.debug("moving .debug_line section: {d} bytes from 0x{x} to 0x{x}\n", .{
2436 existing_size,2436 existing_size,
2437 debug_line_sect.sh_offset,2437 debug_line_sect.sh_offset,
2438 new_offset,2438 new_offset,
src/liveness.zig+2-1
...@@ -1,6 +1,7 @@...@@ -1,6 +1,7 @@
1const std = @import("std");1const std = @import("std");
2const ir = @import("ir.zig");2const ir = @import("ir.zig");
3const trace = @import("tracy.zig").trace;3const trace = @import("tracy.zig").trace;
4const log = std.log.scoped(.liveness);
45
5/// Perform Liveness Analysis over the `Body`. Each `Inst` will have its `deaths` field populated.6/// Perform Liveness Analysis over the `Body`. Each `Inst` will have its `deaths` field populated.
6pub fn analyze(7pub fn analyze(
...@@ -248,5 +249,5 @@ fn analyzeInst(...@@ -248,5 +249,5 @@ fn analyzeInst(
248 @panic("Handle liveness analysis for instructions with many parameters");249 @panic("Handle liveness analysis for instructions with many parameters");
249 }250 }
250251
251 std.log.scoped(.liveness).debug("analyze {}: 0b{b}\n", .{ base.tag, base.deaths });252 log.debug("analyze {}: 0b{b}\n", .{ base.tag, base.deaths });
252}253}
src/main.zig+7-7
...@@ -626,7 +626,7 @@ fn buildOutputType(...@@ -626,7 +626,7 @@ fn buildOutputType(
626 fs.path.dirname(pkg_path),626 fs.path.dirname(pkg_path),
627 fs.path.basename(pkg_path),627 fs.path.basename(pkg_path),
628 ) catch |err| {628 ) catch |err| {
629 fatal("Failed to add package at path {}: {}", .{ pkg_path, @errorName(err) });629 fatal("Failed to add package at path {s}: {s}", .{ pkg_path, @errorName(err) });
630 };630 };
631 new_cur_pkg.parent = cur_pkg;631 new_cur_pkg.parent = cur_pkg;
632 try cur_pkg.add(gpa, pkg_name, new_cur_pkg);632 try cur_pkg.add(gpa, pkg_name, new_cur_pkg);
...@@ -696,13 +696,13 @@ fn buildOutputType(...@@ -696,13 +696,13 @@ fn buildOutputType(
696 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});696 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
697 i += 1;697 i += 1;
698 stack_size_override = std.fmt.parseUnsigned(u64, args[i], 0) catch |err| {698 stack_size_override = std.fmt.parseUnsigned(u64, args[i], 0) catch |err| {
699 fatal("unable to parse '{}': {}", .{ arg, @errorName(err) });699 fatal("unable to parse '{s}': {s}", .{ arg, @errorName(err) });
700 };700 };
701 } else if (mem.eql(u8, arg, "--image-base")) {701 } else if (mem.eql(u8, arg, "--image-base")) {
702 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});702 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
703 i += 1;703 i += 1;
704 image_base_override = std.fmt.parseUnsigned(u64, args[i], 0) catch |err| {704 image_base_override = std.fmt.parseUnsigned(u64, args[i], 0) catch |err| {
705 fatal("unable to parse '{}': {}", .{ arg, @errorName(err) });705 fatal("unable to parse '{s}': {s}", .{ arg, @errorName(err) });
706 };706 };
707 } else if (mem.eql(u8, arg, "--name")) {707 } else if (mem.eql(u8, arg, "--name")) {
708 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});708 if (i + 1 >= args.len) fatal("expected parameter after {s}", .{arg});
...@@ -1914,7 +1914,7 @@ fn buildOutputType(...@@ -1914,7 +1914,7 @@ fn buildOutputType(
1914 if (!watch) return cleanExit();1914 if (!watch) return cleanExit();
1915 } else {1915 } else {
1916 const cmd = try argvCmd(arena, argv.items);1916 const cmd = try argvCmd(arena, argv.items);
1917 fatal("the following test command failed with exit code {}:\n{s}", .{ code, cmd });1917 fatal("the following test command failed with exit code {d}:\n{s}", .{ code, cmd });
1918 }1918 }
1919 },1919 },
1920 else => {1920 else => {
...@@ -2069,7 +2069,7 @@ fn cmdTranslateC(comp: *Compilation, arena: *Allocator, enable_cache: bool) !voi...@@ -2069,7 +2069,7 @@ fn cmdTranslateC(comp: *Compilation, arena: *Allocator, enable_cache: bool) !voi
2069 error.ASTUnitFailure => fatal("clang API returned errors but due to a clang bug, it is not exposing the errors for zig to see. For more details: https://github.com/ziglang/zig/issues/4455", .{}),2069 error.ASTUnitFailure => fatal("clang API returned errors but due to a clang bug, it is not exposing the errors for zig to see. For more details: https://github.com/ziglang/zig/issues/4455", .{}),
2070 error.SemanticAnalyzeFail => {2070 error.SemanticAnalyzeFail => {
2071 for (clang_errors) |clang_err| {2071 for (clang_errors) |clang_err| {
2072 std.debug.print("{s}:{}:{}: {s}\n", .{2072 std.debug.print("{s}:{d}:{d}: {s}\n", .{
2073 if (clang_err.filename_ptr) |p| p[0..clang_err.filename_len] else "(no file)",2073 if (clang_err.filename_ptr) |p| p[0..clang_err.filename_len] else "(no file)",
2074 clang_err.line + 1,2074 clang_err.line + 1,
2075 clang_err.column + 1,2075 clang_err.column + 1,
...@@ -2493,7 +2493,7 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v...@@ -2493,7 +2493,7 @@ pub fn cmdBuild(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v
2493 .Exited => |code| {2493 .Exited => |code| {
2494 if (code == 0) return cleanExit();2494 if (code == 0) return cleanExit();
2495 const cmd = try argvCmd(arena, child_argv);2495 const cmd = try argvCmd(arena, child_argv);
2496 fatal("the following build command failed with exit code {}:\n{s}", .{ code, cmd });2496 fatal("the following build command failed with exit code {d}:\n{s}", .{ code, cmd });
2497 },2497 },
2498 else => {2498 else => {
2499 const cmd = try argvCmd(arena, child_argv);2499 const cmd = try argvCmd(arena, child_argv);
...@@ -2812,7 +2812,7 @@ fn printErrMsgToFile(...@@ -2812,7 +2812,7 @@ fn printErrMsgToFile(
2812 const text = text_buf.items;2812 const text = text_buf.items;
28132813
2814 const stream = file.outStream();2814 const stream = file.outStream();
2815 try stream.print("{s}:{}:{}: error: {s}\n", .{ path, start_loc.line + 1, start_loc.column + 1, text });2815 try stream.print("{s}:{d}:{d}: error: {s}\n", .{ path, start_loc.line + 1, start_loc.column + 1, text });
28162816
2817 if (!color_on) return;2817 if (!color_on) return;
28182818
src/translate_c.zig+9-9
...@@ -136,7 +136,7 @@ const Scope = struct {...@@ -136,7 +136,7 @@ const Scope = struct {
136 var proposed_name = name_copy;136 var proposed_name = name_copy;
137 while (scope.contains(proposed_name)) {137 while (scope.contains(proposed_name)) {
138 scope.mangle_count += 1;138 scope.mangle_count += 1;
139 proposed_name = try std.fmt.allocPrint(c.arena, "{s}_{}", .{ name, scope.mangle_count });139 proposed_name = try std.fmt.allocPrint(c.arena, "{s}_{d}", .{ name, scope.mangle_count });
140 }140 }
141 try scope.variables.append(.{ .name = name_copy, .alias = proposed_name });141 try scope.variables.append(.{ .name = name_copy, .alias = proposed_name });
142 return proposed_name;142 return proposed_name;
...@@ -440,7 +440,7 @@ pub fn translate(...@@ -440,7 +440,7 @@ pub fn translate(
440 mem.copy(*ast.Node, root_node.decls(), context.root_decls.items);440 mem.copy(*ast.Node, root_node.decls(), context.root_decls.items);
441441
442 if (false) {442 if (false) {
443 std.debug.warn("debug source:\n{}\n==EOF==\ntokens:\n", .{source_buffer.items});443 std.debug.warn("debug source:\n{s}\n==EOF==\ntokens:\n", .{source_buffer.items});
444 for (context.token_ids.items) |token| {444 for (context.token_ids.items) |token| {
445 std.debug.warn("{}\n", .{token});445 std.debug.warn("{}\n", .{token});
446 }446 }
...@@ -945,7 +945,7 @@ fn transRecordDecl(c: *Context, record_decl: *const clang.RecordDecl) Error!?*as...@@ -945,7 +945,7 @@ fn transRecordDecl(c: *Context, record_decl: *const clang.RecordDecl) Error!?*as
945 // Record declarations such as `struct {...} x` have no name but they're not945 // Record declarations such as `struct {...} x` have no name but they're not
946 // anonymous hence here isAnonymousStructOrUnion is not needed946 // anonymous hence here isAnonymousStructOrUnion is not needed
947 if (bare_name.len == 0) {947 if (bare_name.len == 0) {
948 bare_name = try std.fmt.allocPrint(c.arena, "unnamed_{}", .{c.getMangle()});948 bare_name = try std.fmt.allocPrint(c.arena, "unnamed_{d}", .{c.getMangle()});
949 is_unnamed = true;949 is_unnamed = true;
950 }950 }
951951
...@@ -1019,7 +1019,7 @@ fn transRecordDecl(c: *Context, record_decl: *const clang.RecordDecl) Error!?*as...@@ -1019,7 +1019,7 @@ fn transRecordDecl(c: *Context, record_decl: *const clang.RecordDecl) Error!?*as
1019 var raw_name = try c.str(@ptrCast(*const clang.NamedDecl, field_decl).getName_bytes_begin());1019 var raw_name = try c.str(@ptrCast(*const clang.NamedDecl, field_decl).getName_bytes_begin());
1020 if (field_decl.isAnonymousStructOrUnion() or raw_name.len == 0) {1020 if (field_decl.isAnonymousStructOrUnion() or raw_name.len == 0) {
1021 // Context.getMangle() is not used here because doing so causes unpredictable field names for anonymous fields.1021 // Context.getMangle() is not used here because doing so causes unpredictable field names for anonymous fields.
1022 raw_name = try std.fmt.allocPrint(c.arena, "unnamed_{}", .{unnamed_field_count});1022 raw_name = try std.fmt.allocPrint(c.arena, "unnamed_{d}", .{unnamed_field_count});
1023 unnamed_field_count += 1;1023 unnamed_field_count += 1;
1024 is_anon = true;1024 is_anon = true;
1025 }1025 }
...@@ -1110,7 +1110,7 @@ fn transEnumDecl(c: *Context, enum_decl: *const clang.EnumDecl) Error!?*ast.Node...@@ -1110,7 +1110,7 @@ fn transEnumDecl(c: *Context, enum_decl: *const clang.EnumDecl) Error!?*ast.Node
1110 var bare_name = try c.str(@ptrCast(*const clang.NamedDecl, enum_decl).getName_bytes_begin());1110 var bare_name = try c.str(@ptrCast(*const clang.NamedDecl, enum_decl).getName_bytes_begin());
1111 var is_unnamed = false;1111 var is_unnamed = false;
1112 if (bare_name.len == 0) {1112 if (bare_name.len == 0) {
1113 bare_name = try std.fmt.allocPrint(c.arena, "unnamed_{}", .{c.getMangle()});1113 bare_name = try std.fmt.allocPrint(c.arena, "unnamed_{d}", .{c.getMangle()});
1114 is_unnamed = true;1114 is_unnamed = true;
1115 }1115 }
11161116
...@@ -3956,7 +3956,7 @@ fn qualTypeToLog2IntRef(rp: RestorePoint, qt: clang.QualType, source_loc: clang....@@ -3956,7 +3956,7 @@ fn qualTypeToLog2IntRef(rp: RestorePoint, qt: clang.QualType, source_loc: clang.
3956 const node = try rp.c.arena.create(ast.Node.OneToken);3956 const node = try rp.c.arena.create(ast.Node.OneToken);
3957 node.* = .{3957 node.* = .{
3958 .base = .{ .tag = .IntegerLiteral },3958 .base = .{ .tag = .IntegerLiteral },
3959 .token = try appendTokenFmt(rp.c, .Identifier, "u{}", .{cast_bit_width}),3959 .token = try appendTokenFmt(rp.c, .Identifier, "u{d}", .{cast_bit_width}),
3960 };3960 };
3961 return &node.base;3961 return &node.base;
3962 }3962 }
...@@ -4484,7 +4484,7 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: *ast.Node, proto_a...@@ -4484,7 +4484,7 @@ fn transCreateNodeMacroFn(c: *Context, name: []const u8, ref: *ast.Node, proto_a
4484 _ = try appendToken(c, .Comma, ",");4484 _ = try appendToken(c, .Comma, ",");
4485 }4485 }
4486 const param_name_tok = param.name_token orelse4486 const param_name_tok = param.name_token orelse
4487 try appendTokenFmt(c, .Identifier, "arg_{}", .{c.getMangle()});4487 try appendTokenFmt(c, .Identifier, "arg_{d}", .{c.getMangle()});
44884488
4489 _ = try appendToken(c, .Colon, ":");4489 _ = try appendToken(c, .Colon, ":");
44904490
...@@ -5916,11 +5916,11 @@ fn parseCPrimaryExprInner(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!*...@@ -5916,11 +5916,11 @@ fn parseCPrimaryExprInner(c: *Context, m: *MacroCtx, scope: *Scope) ParseError!*
5916 // struct Foo will be declared as struct_Foo by transRecordDecl5916 // struct Foo will be declared as struct_Foo by transRecordDecl
5917 const next_id = m.next().?;5917 const next_id = m.next().?;
5918 if (next_id != .Identifier) {5918 if (next_id != .Identifier) {
5919 try m.fail(c, "unable to translate C expr: expected Identifier instead got: {}", .{@tagName(next_id)});5919 try m.fail(c, "unable to translate C expr: expected Identifier instead got: {s}", .{@tagName(next_id)});
5920 return error.ParseError;5920 return error.ParseError;
5921 }5921 }
59225922
5923 const ident_token = try appendTokenFmt(c, .Identifier, "{}_{}", .{ slice, m.slice() });5923 const ident_token = try appendTokenFmt(c, .Identifier, "{s}_{s}", .{ slice, m.slice() });
5924 const identifier = try c.arena.create(ast.Node.OneToken);5924 const identifier = try c.arena.create(ast.Node.OneToken);
5925 identifier.* = .{5925 identifier.* = .{
5926 .base = .{ .tag = .Identifier },5926 .base = .{ .tag = .Identifier },
src/type.zig+4-4
...@@ -558,21 +558,21 @@ pub const Type = extern union {...@@ -558,21 +558,21 @@ pub const Type = extern union {
558 },558 },
559 .array_u8 => {559 .array_u8 => {
560 const len = ty.castTag(.array_u8).?.data;560 const len = ty.castTag(.array_u8).?.data;
561 return out_stream.print("[{}]u8", .{len});561 return out_stream.print("[{d}]u8", .{len});
562 },562 },
563 .array_u8_sentinel_0 => {563 .array_u8_sentinel_0 => {
564 const len = ty.castTag(.array_u8_sentinel_0).?.data;564 const len = ty.castTag(.array_u8_sentinel_0).?.data;
565 return out_stream.print("[{}:0]u8", .{len});565 return out_stream.print("[{d}:0]u8", .{len});
566 },566 },
567 .array => {567 .array => {
568 const payload = ty.castTag(.array).?.data;568 const payload = ty.castTag(.array).?.data;
569 try out_stream.print("[{}]", .{payload.len});569 try out_stream.print("[{d}]", .{payload.len});
570 ty = payload.elem_type;570 ty = payload.elem_type;
571 continue;571 continue;
572 },572 },
573 .array_sentinel => {573 .array_sentinel => {
574 const payload = ty.castTag(.array_sentinel).?.data;574 const payload = ty.castTag(.array_sentinel).?.data;
575 try out_stream.print("[{}:{}]", .{ payload.len, payload.sentinel });575 try out_stream.print("[{d}:{}]", .{ payload.len, payload.sentinel });
576 ty = payload.elem_type;576 ty = payload.elem_type;
577 continue;577 continue;
578 },578 },
src/zir.zig+9-10
...@@ -1257,12 +1257,12 @@ const Writer = struct {...@@ -1257,12 +1257,12 @@ const Writer = struct {
1257 self.next_instr_index += 1;1257 self.next_instr_index += 1;
1258 try self.inst_table.putNoClobber(inst, .{ .inst = inst, .index = my_i, .name = undefined });1258 try self.inst_table.putNoClobber(inst, .{ .inst = inst, .index = my_i, .name = undefined });
1259 try stream.writeByteNTimes(' ', self.indent);1259 try stream.writeByteNTimes(' ', self.indent);
1260 try stream.print("%{} ", .{my_i});1260 try stream.print("%{d} ", .{my_i});
1261 if (inst.cast(Inst.Block)) |block| {1261 if (inst.cast(Inst.Block)) |block| {
1262 const name = try std.fmt.allocPrint(&self.arena.allocator, "label_{}", .{my_i});1262 const name = try std.fmt.allocPrint(&self.arena.allocator, "label_{d}", .{my_i});
1263 try self.block_table.put(block, name);1263 try self.block_table.put(block, name);
1264 } else if (inst.cast(Inst.Loop)) |loop| {1264 } else if (inst.cast(Inst.Loop)) |loop| {
1265 const name = try std.fmt.allocPrint(&self.arena.allocator, "loop_{}", .{my_i});1265 const name = try std.fmt.allocPrint(&self.arena.allocator, "loop_{d}", .{my_i});
1266 try self.loop_table.put(loop, name);1266 try self.loop_table.put(loop, name);
1267 }1267 }
1268 self.indent += 2;1268 self.indent += 2;
...@@ -1332,7 +1332,7 @@ const Writer = struct {...@@ -1332,7 +1332,7 @@ const Writer = struct {
1332 fn writeInstParamToStream(self: *Writer, stream: anytype, inst: *Inst) !void {1332 fn writeInstParamToStream(self: *Writer, stream: anytype, inst: *Inst) !void {
1333 if (self.inst_table.get(inst)) |info| {1333 if (self.inst_table.get(inst)) |info| {
1334 if (info.index) |i| {1334 if (info.index) |i| {
1335 try stream.print("%{}", .{info.index});1335 try stream.print("%{d}", .{info.index});
1336 } else {1336 } else {
1337 try stream.print("@{s}", .{info.name});1337 try stream.print("@{s}", .{info.name});
1338 }1338 }
...@@ -1660,7 +1660,6 @@ const Parser = struct {...@@ -1660,7 +1660,6 @@ const Parser = struct {
1660 .contents_hash = std.zig.hashSrc(self.source[contents_start..self.i]),1660 .contents_hash = std.zig.hashSrc(self.source[contents_start..self.i]),
1661 .inst = &inst_specific.base,1661 .inst = &inst_specific.base,
1662 };1662 };
1663 //std.debug.warn("parsed {} = '{}'\n", .{ inst_specific.base.name, inst_specific.base.contents });
16641663
1665 return decl;1664 return decl;
1666 }1665 }
...@@ -1805,7 +1804,7 @@ const Parser = struct {...@@ -1805,7 +1804,7 @@ const Parser = struct {
1805 }1804 }
18061805
1807 fn generateName(self: *Parser) ![]u8 {1806 fn generateName(self: *Parser) ![]u8 {
1808 const result = try std.fmt.allocPrint(&self.arena.allocator, "unnamed${}", .{self.unnamed_index});1807 const result = try std.fmt.allocPrint(&self.arena.allocator, "unnamed${d}", .{self.unnamed_index});
1809 self.unnamed_index += 1;1808 self.unnamed_index += 1;
1810 return result;1809 return result;
1811 }1810 }
...@@ -2865,7 +2864,7 @@ const EmitZIR = struct {...@@ -2865,7 +2864,7 @@ const EmitZIR = struct {
28652864
2866 fn autoName(self: *EmitZIR) ![]u8 {2865 fn autoName(self: *EmitZIR) ![]u8 {
2867 while (true) {2866 while (true) {
2868 const proposed_name = try std.fmt.allocPrint(&self.arena.allocator, "unnamed${}", .{self.next_auto_name});2867 const proposed_name = try std.fmt.allocPrint(&self.arena.allocator, "unnamed${d}", .{self.next_auto_name});
2869 self.next_auto_name += 1;2868 self.next_auto_name += 1;
2870 const gop = try self.names.getOrPut(proposed_name);2869 const gop = try self.names.getOrPut(proposed_name);
2871 if (!gop.found_existing) {2870 if (!gop.found_existing) {
...@@ -2954,15 +2953,15 @@ pub fn dumpZir(allocator: *Allocator, kind: []const u8, decl_name: [*:0]const u8...@@ -2954,15 +2953,15 @@ pub fn dumpZir(allocator: *Allocator, kind: []const u8, decl_name: [*:0]const u8
2954 write.next_instr_index += 1;2953 write.next_instr_index += 1;
29552954
2956 if (inst.cast(Inst.Block)) |block| {2955 if (inst.cast(Inst.Block)) |block| {
2957 const name = try std.fmt.allocPrint(&write.arena.allocator, "label_{}", .{my_i});2956 const name = try std.fmt.allocPrint(&write.arena.allocator, "label_{d}", .{my_i});
2958 try write.block_table.put(block, name);2957 try write.block_table.put(block, name);
2959 } else if (inst.cast(Inst.Loop)) |loop| {2958 } else if (inst.cast(Inst.Loop)) |loop| {
2960 const name = try std.fmt.allocPrint(&write.arena.allocator, "loop_{}", .{my_i});2959 const name = try std.fmt.allocPrint(&write.arena.allocator, "loop_{d}", .{my_i});
2961 try write.loop_table.put(loop, name);2960 try write.loop_table.put(loop, name);
2962 }2961 }
29632962
2964 try write.inst_table.putNoClobber(inst, .{ .inst = inst, .index = my_i, .name = "inst" });2963 try write.inst_table.putNoClobber(inst, .{ .inst = inst, .index = my_i, .name = "inst" });
2965 try stderr.print(" %{} ", .{my_i});2964 try stderr.print(" %{d} ", .{my_i});
2966 try write.writeInstToStream(stderr, inst);2965 try write.writeInstToStream(stderr, inst);
2967 try stderr.writeByte('\n');2966 try stderr.writeByte('\n');
2968 }2967 }
src/zir_sema.zig+7-7
...@@ -535,7 +535,7 @@ fn analyzeInstParamType(mod: *Module, scope: *Scope, inst: *zir.Inst.ParamType)...@@ -535,7 +535,7 @@ fn analyzeInstParamType(mod: *Module, scope: *Scope, inst: *zir.Inst.ParamType)
535 // TODO support C-style var args535 // TODO support C-style var args
536 const param_count = fn_ty.fnParamLen();536 const param_count = fn_ty.fnParamLen();
537 if (arg_index >= param_count) {537 if (arg_index >= param_count) {
538 return mod.fail(scope, inst.base.src, "arg index {} out of bounds; '{}' has {} argument(s)", .{538 return mod.fail(scope, inst.base.src, "arg index {d} out of bounds; '{}' has {d} argument(s)", .{
539 arg_index,539 arg_index,
540 fn_ty,540 fn_ty,
541 param_count,541 param_count,
...@@ -580,7 +580,7 @@ fn analyzeInstArg(mod: *Module, scope: *Scope, inst: *zir.Inst.Arg) InnerError!*...@@ -580,7 +580,7 @@ fn analyzeInstArg(mod: *Module, scope: *Scope, inst: *zir.Inst.Arg) InnerError!*
580 const param_index = b.instructions.items.len;580 const param_index = b.instructions.items.len;
581 const param_count = fn_ty.fnParamLen();581 const param_count = fn_ty.fnParamLen();
582 if (param_index >= param_count) {582 if (param_index >= param_count) {
583 return mod.fail(scope, inst.base.src, "parameter index {} outside list of length {}", .{583 return mod.fail(scope, inst.base.src, "parameter index {d} outside list of length {d}", .{
584 param_index,584 param_index,
585 param_count,585 param_count,
586 });586 });
...@@ -790,7 +790,7 @@ fn analyzeInstCall(mod: *Module, scope: *Scope, inst: *zir.Inst.Call) InnerError...@@ -790,7 +790,7 @@ fn analyzeInstCall(mod: *Module, scope: *Scope, inst: *zir.Inst.Call) InnerError
790 return mod.fail(790 return mod.fail(
791 scope,791 scope,
792 inst.positionals.func.src,792 inst.positionals.func.src,
793 "expected at least {} argument(s), found {}",793 "expected at least {d} argument(s), found {d}",
794 .{ fn_params_len, call_params_len },794 .{ fn_params_len, call_params_len },
795 );795 );
796 }796 }
...@@ -800,7 +800,7 @@ fn analyzeInstCall(mod: *Module, scope: *Scope, inst: *zir.Inst.Call) InnerError...@@ -800,7 +800,7 @@ fn analyzeInstCall(mod: *Module, scope: *Scope, inst: *zir.Inst.Call) InnerError
800 return mod.fail(800 return mod.fail(
801 scope,801 scope,
802 inst.positionals.func.src,802 inst.positionals.func.src,
803 "expected {} argument(s), found {}",803 "expected {d} argument(s), found {d}",
804 .{ fn_params_len, call_params_len },804 .{ fn_params_len, call_params_len },
805 );805 );
806 }806 }
...@@ -1545,7 +1545,7 @@ fn analyzeInstBitwise(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerE...@@ -1545,7 +1545,7 @@ fn analyzeInstBitwise(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) InnerE
15451545
1546 if (lhs.ty.zigTypeTag() == .Vector and rhs.ty.zigTypeTag() == .Vector) {1546 if (lhs.ty.zigTypeTag() == .Vector and rhs.ty.zigTypeTag() == .Vector) {
1547 if (lhs.ty.arrayLen() != rhs.ty.arrayLen()) {1547 if (lhs.ty.arrayLen() != rhs.ty.arrayLen()) {
1548 return mod.fail(scope, inst.base.src, "vector length mismatch: {} and {}", .{1548 return mod.fail(scope, inst.base.src, "vector length mismatch: {d} and {d}", .{
1549 lhs.ty.arrayLen(),1549 lhs.ty.arrayLen(),
1550 rhs.ty.arrayLen(),1550 rhs.ty.arrayLen(),
1551 });1551 });
...@@ -1620,7 +1620,7 @@ fn analyzeInstArithmetic(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) Inn...@@ -1620,7 +1620,7 @@ fn analyzeInstArithmetic(mod: *Module, scope: *Scope, inst: *zir.Inst.BinOp) Inn
16201620
1621 if (lhs.ty.zigTypeTag() == .Vector and rhs.ty.zigTypeTag() == .Vector) {1621 if (lhs.ty.zigTypeTag() == .Vector and rhs.ty.zigTypeTag() == .Vector) {
1622 if (lhs.ty.arrayLen() != rhs.ty.arrayLen()) {1622 if (lhs.ty.arrayLen() != rhs.ty.arrayLen()) {
1623 return mod.fail(scope, inst.base.src, "vector length mismatch: {} and {}", .{1623 return mod.fail(scope, inst.base.src, "vector length mismatch: {d} and {d}", .{
1624 lhs.ty.arrayLen(),1624 lhs.ty.arrayLen(),
1625 rhs.ty.arrayLen(),1625 rhs.ty.arrayLen(),
1626 });1626 });
...@@ -1791,7 +1791,7 @@ fn analyzeInstCmp(...@@ -1791,7 +1791,7 @@ fn analyzeInstCmp(
1791 return mod.cmpNumeric(scope, inst.base.src, lhs, rhs, op);1791 return mod.cmpNumeric(scope, inst.base.src, lhs, rhs, op);
1792 } else if (lhs_ty_tag == .Type and rhs_ty_tag == .Type) {1792 } else if (lhs_ty_tag == .Type and rhs_ty_tag == .Type) {
1793 if (!is_equality_cmp) {1793 if (!is_equality_cmp) {
1794 return mod.fail(scope, inst.base.src, "{} operator not allowed for types", .{@tagName(op)});1794 return mod.fail(scope, inst.base.src, "{s} operator not allowed for types", .{@tagName(op)});
1795 }1795 }
1796 return mod.constBool(scope, inst.base.src, lhs.value().?.eql(rhs.value().?) == (op == .eq));1796 return mod.constBool(scope, inst.base.src, lhs.value().?.eql(rhs.value().?) == (op == .eq));
1797 }1797 }