| author | |
| committer | |
| log | 9c8aef55b4e287197b552ef18e7dd008e3a527bc |
| tree | 0bbe77c197c55f57a22ab7e2657ce75fac24a80d |
| parent | 30c2921eb87c3157d52edd7d8ee874209a0f7538 |
prevents footgun when formatted type changes from string to enum12 files changed, 39 insertions(+), 29 deletions(-)
lib/std/fmt.zig+3| ... | @@ -67,6 +67,9 @@ pub const Options = struct { | ... | @@ -67,6 +67,9 @@ pub const Options = struct { |
| 67 | /// - `s`: | 67 | /// - `s`: |
| 68 | /// - for pointer-to-many and C pointers of u8, print as a C-string using zero-termination | 68 | /// - for pointer-to-many and C pointers of u8, print as a C-string using zero-termination |
| 69 | /// - for slices of u8, print the entire slice as a string without zero-termination | 69 | /// - for slices of u8, print the entire slice as a string without zero-termination |
| 70 | /// - `t`: | ||
| 71 | /// - for enums and tagged unions: prints the tag name | ||
| 72 | /// - for error sets: prints the error name | ||
| 70 | /// - `b64`: output string as standard base64 | 73 | /// - `b64`: output string as standard base64 |
| 71 | /// - `e`: output floating point value in scientific notation | 74 | /// - `e`: output floating point value in scientific notation |
| 72 | /// - `d`: output numeric value in decimal notation | 75 | /// - `d`: output numeric value in decimal notation |
lib/std/io/Writer.zig+3-3| ... | @@ -851,12 +851,12 @@ pub fn printValue( | ... | @@ -851,12 +851,12 @@ pub fn printValue( |
| 851 | } | 851 | } |
| 852 | }, | 852 | }, |
| 853 | .error_set => { | 853 | .error_set => { |
| 854 | if (fmt.len == 1 and fmt[0] == 's') return w.writeAll(@errorName(value)); | 854 | if (fmt.len == 1 and fmt[0] == 't') return w.writeAll(@errorName(value)); |
| 855 | if (!is_any and fmt.len != 0) invalidFmtError(fmt, value); | 855 | if (!is_any and fmt.len != 0) invalidFmtError(fmt, value); |
| 856 | try printErrorSet(w, value); | 856 | try printErrorSet(w, value); |
| 857 | }, | 857 | }, |
| 858 | .@"enum" => { | 858 | .@"enum" => { |
| 859 | if (fmt.len == 1 and fmt[0] == 's') { | 859 | if (fmt.len == 1 and fmt[0] == 't') { |
| 860 | try w.writeAll(@tagName(value)); | 860 | try w.writeAll(@tagName(value)); |
| 861 | return; | 861 | return; |
| 862 | } | 862 | } |
| ... | @@ -881,7 +881,7 @@ pub fn printValue( | ... | @@ -881,7 +881,7 @@ pub fn printValue( |
| 881 | return; | 881 | return; |
| 882 | }, | 882 | }, |
| 883 | .@"union" => |info| { | 883 | .@"union" => |info| { |
| 884 | if (fmt.len == 1 and fmt[0] == 's') { | 884 | if (fmt.len == 1 and fmt[0] == 't') { |
| 885 | try w.writeAll(@tagName(value)); | 885 | try w.writeAll(@tagName(value)); |
| 886 | return; | 886 | return; |
| 887 | } | 887 | } |
lib/std/zig/llvm/Builder.zig+5-5| ... | @@ -1265,7 +1265,7 @@ pub const Attribute = union(Kind) { | ... | @@ -1265,7 +1265,7 @@ pub const Attribute = union(Kind) { |
| 1265 | try w.writeByte(')'); | 1265 | try w.writeByte(')'); |
| 1266 | }, | 1266 | }, |
| 1267 | .alignstack => |alignment| { | 1267 | .alignstack => |alignment| { |
| 1268 | try w.print(" {s}", .{attribute}); | 1268 | try w.print(" {t}", .{attribute}); |
| 1269 | const alignment_bytes = alignment.toByteUnits() orelse return; | 1269 | const alignment_bytes = alignment.toByteUnits() orelse return; |
| 1270 | if (data.flags.pound) { | 1270 | if (data.flags.pound) { |
| 1271 | try w.print("={d}", .{alignment_bytes}); | 1271 | try w.print("={d}", .{alignment_bytes}); |
| ... | @@ -1274,7 +1274,7 @@ pub const Attribute = union(Kind) { | ... | @@ -1274,7 +1274,7 @@ pub const Attribute = union(Kind) { |
| 1274 | } | 1274 | } |
| 1275 | }, | 1275 | }, |
| 1276 | .allockind => |allockind| { | 1276 | .allockind => |allockind| { |
| 1277 | try w.print(" {s}(\"", .{@tagName(attribute)}); | 1277 | try w.print(" {t}(\"", .{attribute}); |
| 1278 | var any = false; | 1278 | var any = false; |
| 1279 | inline for (@typeInfo(AllocKind).@"struct".fields) |field| { | 1279 | inline for (@typeInfo(AllocKind).@"struct".fields) |field| { |
| 1280 | if (comptime std.mem.eql(u8, field.name, "_")) continue; | 1280 | if (comptime std.mem.eql(u8, field.name, "_")) continue; |
| ... | @@ -1289,13 +1289,13 @@ pub const Attribute = union(Kind) { | ... | @@ -1289,13 +1289,13 @@ pub const Attribute = union(Kind) { |
| 1289 | try w.writeAll("\")"); | 1289 | try w.writeAll("\")"); |
| 1290 | }, | 1290 | }, |
| 1291 | .allocsize => |allocsize| { | 1291 | .allocsize => |allocsize| { |
| 1292 | try w.print(" {s}({d}", .{ @tagName(attribute), allocsize.elem_size }); | 1292 | try w.print(" {t}({d}", .{ attribute, allocsize.elem_size }); |
| 1293 | if (allocsize.num_elems != AllocSize.none) | 1293 | if (allocsize.num_elems != AllocSize.none) |
| 1294 | try w.print(",{d}", .{allocsize.num_elems}); | 1294 | try w.print(",{d}", .{allocsize.num_elems}); |
| 1295 | try w.writeByte(')'); | 1295 | try w.writeByte(')'); |
| 1296 | }, | 1296 | }, |
| 1297 | .memory => |memory| { | 1297 | .memory => |memory| { |
| 1298 | try w.print(" {s}(", .{@tagName(attribute)}); | 1298 | try w.print(" {t}(", .{attribute}); |
| 1299 | var any = memory.other != .none or | 1299 | var any = memory.other != .none or |
| 1300 | (memory.argmem == .none and memory.inaccessiblemem == .none); | 1300 | (memory.argmem == .none and memory.inaccessiblemem == .none); |
| 1301 | if (any) try w.writeAll(@tagName(memory.other)); | 1301 | if (any) try w.writeAll(@tagName(memory.other)); |
| ... | @@ -8445,7 +8445,7 @@ pub const Metadata = enum(u32) { | ... | @@ -8445,7 +8445,7 @@ pub const Metadata = enum(u32) { |
| 8445 | } | 8445 | } |
| 8446 | fmt_str = fmt_str ++ "("; | 8446 | fmt_str = fmt_str ++ "("; |
| 8447 | inline for (fields[2..], names) |*field, name| { | 8447 | inline for (fields[2..], names) |*field, name| { |
| 8448 | fmt_str = fmt_str ++ "{[" ++ name ++ "]fS}"; | 8448 | fmt_str = fmt_str ++ "{[" ++ name ++ "]f}"; |
| 8449 | field.* = .{ | 8449 | field.* = .{ |
| 8450 | .name = name, | 8450 | .name = name, |
| 8451 | .type = std.fmt.Formatter(FormatData, format), | 8451 | .type = std.fmt.Formatter(FormatData, format), |
src/InternPool.zig+1-1| ... | @@ -11406,7 +11406,7 @@ pub fn dumpGenericInstancesFallible(ip: *const InternPool, allocator: Allocator) | ... | @@ -11406,7 +11406,7 @@ pub fn dumpGenericInstancesFallible(ip: *const InternPool, allocator: Allocator) |
| 11406 | var it = instances.iterator(); | 11406 | var it = instances.iterator(); |
| 11407 | while (it.next()) |entry| { | 11407 | while (it.next()) |entry| { |
| 11408 | const generic_fn_owner_nav = ip.getNav(ip.funcDeclInfo(entry.key_ptr.*).owner_nav); | 11408 | const generic_fn_owner_nav = ip.getNav(ip.funcDeclInfo(entry.key_ptr.*).owner_nav); |
| 11409 | try stderr_bw.print("{f} ({f}): \n", .{ generic_fn_owner_nav.name.fmt(ip), entry.value_ptr.items.len }); | 11409 | try stderr_bw.print("{f} ({d}): \n", .{ generic_fn_owner_nav.name.fmt(ip), entry.value_ptr.items.len }); |
| 11410 | for (entry.value_ptr.items) |index| { | 11410 | for (entry.value_ptr.items) |index| { |
| 11411 | const unwrapped_index = index.unwrap(ip); | 11411 | const unwrapped_index = index.unwrap(ip); |
| 11412 | const func = ip.extraFuncInstance(unwrapped_index.tid, unwrapped_index.getExtra(ip), unwrapped_index.getData(ip)); | 11412 | const func = ip.extraFuncInstance(unwrapped_index.tid, unwrapped_index.getExtra(ip), unwrapped_index.getData(ip)); |
src/Sema.zig+13-6| ... | @@ -20465,7 +20465,7 @@ fn zirIntFromBool(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError | ... | @@ -20465,7 +20465,7 @@ fn zirIntFromBool(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 20465 | const is_vector = operand_ty.zigTypeTag(zcu) == .vector; | 20465 | const is_vector = operand_ty.zigTypeTag(zcu) == .vector; |
| 20466 | const operand_scalar_ty = operand_ty.scalarType(zcu); | 20466 | const operand_scalar_ty = operand_ty.scalarType(zcu); |
| 20467 | if (operand_scalar_ty.toIntern() != .bool_type) { | 20467 | if (operand_scalar_ty.toIntern() != .bool_type) { |
| 20468 | return sema.fail(block, src, "expected 'bool', found '{s}'", .{operand_scalar_ty.zigTypeTag(zcu)}); | 20468 | return sema.fail(block, src, "expected 'bool', found '{t}'", .{operand_scalar_ty.zigTypeTag(zcu)}); |
| 20469 | } | 20469 | } |
| 20470 | const len = if (is_vector) operand_ty.vectorLen(zcu) else undefined; | 20470 | const len = if (is_vector) operand_ty.vectorLen(zcu) else undefined; |
| 20471 | const dest_ty: Type = if (is_vector) try pt.vectorType(.{ .child = .u1_type, .len = len }) else .u1; | 20471 | const dest_ty: Type = if (is_vector) try pt.vectorType(.{ .child = .u1_type, .len = len }) else .u1; |
| ... | @@ -23576,7 +23576,7 @@ fn checkNumericType( | ... | @@ -23576,7 +23576,7 @@ fn checkNumericType( |
| 23576 | .comptime_float, .float, .comptime_int, .int => {}, | 23576 | .comptime_float, .float, .comptime_int, .int => {}, |
| 23577 | .vector => switch (ty.childType(zcu).zigTypeTag(zcu)) { | 23577 | .vector => switch (ty.childType(zcu).zigTypeTag(zcu)) { |
| 23578 | .comptime_float, .float, .comptime_int, .int => {}, | 23578 | .comptime_float, .float, .comptime_int, .int => {}, |
| 23579 | else => |t| return sema.fail(block, ty_src, "expected number, found '{s}'", .{t}), | 23579 | else => |t| return sema.fail(block, ty_src, "expected number, found '{t}'", .{t}), |
| 23580 | }, | 23580 | }, |
| 23581 | else => return sema.fail(block, ty_src, "expected number, found '{f}'", .{ty.fmt(pt)}), | 23581 | else => return sema.fail(block, ty_src, "expected number, found '{f}'", .{ty.fmt(pt)}), |
| 23582 | } | 23582 | } |
| ... | @@ -37176,7 +37176,14 @@ fn explainWhyValueContainsReferenceToComptimeVar(sema: *Sema, msg: *Zcu.ErrorMsg | ... | @@ -37176,7 +37176,14 @@ fn explainWhyValueContainsReferenceToComptimeVar(sema: *Sema, msg: *Zcu.ErrorMsg |
| 37176 | } | 37176 | } |
| 37177 | } | 37177 | } |
| 37178 | 37178 | ||
| 37179 | fn notePathToComptimeAllocPtr(sema: *Sema, msg: *Zcu.ErrorMsg, src: LazySrcLoc, val: Value, intermediate_value_count: u32, start_value_name: InternPool.NullTerminatedString) Allocator.Error!union(enum) { | 37179 | fn notePathToComptimeAllocPtr( |
| 37180 | sema: *Sema, | ||
| 37181 | msg: *Zcu.ErrorMsg, | ||
| 37182 | src: LazySrcLoc, | ||
| 37183 | val: Value, | ||
| 37184 | intermediate_value_count: u32, | ||
| 37185 | start_value_name: InternPool.NullTerminatedString, | ||
| 37186 | ) Allocator.Error!union(enum) { | ||
| 37180 | done, | 37187 | done, |
| 37181 | new_val: Value, | 37188 | new_val: Value, |
| 37182 | } { | 37189 | } { |
| ... | @@ -37187,7 +37194,7 @@ fn notePathToComptimeAllocPtr(sema: *Sema, msg: *Zcu.ErrorMsg, src: LazySrcLoc, | ... | @@ -37187,7 +37194,7 @@ fn notePathToComptimeAllocPtr(sema: *Sema, msg: *Zcu.ErrorMsg, src: LazySrcLoc, |
| 37187 | 37194 | ||
| 37188 | var first_path: std.ArrayListUnmanaged(u8) = .empty; | 37195 | var first_path: std.ArrayListUnmanaged(u8) = .empty; |
| 37189 | if (intermediate_value_count == 0) { | 37196 | if (intermediate_value_count == 0) { |
| 37190 | try first_path.print(arena, "{fi}", .{start_value_name.fmt(ip)}); | 37197 | try first_path.print(arena, "{f}", .{start_value_name.fmt(ip)}); |
| 37191 | } else { | 37198 | } else { |
| 37192 | try first_path.print(arena, "v{d}", .{intermediate_value_count - 1}); | 37199 | try first_path.print(arena, "v{d}", .{intermediate_value_count - 1}); |
| 37193 | } | 37200 | } |
| ... | @@ -37283,7 +37290,7 @@ fn notePathToComptimeAllocPtrInner(sema: *Sema, val: Value, path: *std.ArrayList | ... | @@ -37283,7 +37290,7 @@ fn notePathToComptimeAllocPtrInner(sema: *Sema, val: Value, path: *std.ArrayList |
| 37283 | const backing_enum = union_ty.unionTagTypeHypothetical(zcu); | 37290 | const backing_enum = union_ty.unionTagTypeHypothetical(zcu); |
| 37284 | const field_idx = backing_enum.enumTagFieldIndex(.fromInterned(un.tag), zcu).?; | 37291 | const field_idx = backing_enum.enumTagFieldIndex(.fromInterned(un.tag), zcu).?; |
| 37285 | const field_name = backing_enum.enumFieldName(field_idx, zcu); | 37292 | const field_name = backing_enum.enumFieldName(field_idx, zcu); |
| 37286 | try path.print(arena, ".{fi}", .{field_name.fmt(ip)}); | 37293 | try path.print(arena, ".{f}", .{field_name.fmt(ip)}); |
| 37287 | return sema.notePathToComptimeAllocPtrInner(.fromInterned(un.val), path); | 37294 | return sema.notePathToComptimeAllocPtrInner(.fromInterned(un.val), path); |
| 37288 | }, | 37295 | }, |
| 37289 | .aggregate => |agg| { | 37296 | .aggregate => |agg| { |
| ... | @@ -37308,7 +37315,7 @@ fn notePathToComptimeAllocPtrInner(sema: *Sema, val: Value, path: *std.ArrayList | ... | @@ -37308,7 +37315,7 @@ fn notePathToComptimeAllocPtrInner(sema: *Sema, val: Value, path: *std.ArrayList |
| 37308 | try path.print(arena, "[{d}]", .{elem_idx}); | 37315 | try path.print(arena, "[{d}]", .{elem_idx}); |
| 37309 | } else { | 37316 | } else { |
| 37310 | const name = agg_ty.structFieldName(elem_idx, zcu).unwrap().?; | 37317 | const name = agg_ty.structFieldName(elem_idx, zcu).unwrap().?; |
| 37311 | try path.print(arena, ".{fi}", .{name.fmt(ip)}); | 37318 | try path.print(arena, ".{f}", .{name.fmt(ip)}); |
| 37312 | }, | 37319 | }, |
| 37313 | else => unreachable, | 37320 | else => unreachable, |
| 37314 | } | 37321 | } |
src/arch/sparc64/CodeGen.zig+1-1| ... | @@ -723,7 +723,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -723,7 +723,7 @@ fn genBody(self: *Self, body: []const Air.Inst.Index) InnerError!void { |
| 723 | 723 | ||
| 724 | if (std.debug.runtime_safety) { | 724 | if (std.debug.runtime_safety) { |
| 725 | if (self.air_bookkeeping < old_air_bookkeeping + 1) { | 725 | if (self.air_bookkeeping < old_air_bookkeeping + 1) { |
| 726 | std.debug.panic("in codegen.zig, handling of AIR instruction %{d} ('{s}') did not do proper bookkeeping. Look for a missing call to finishAir.", .{ inst, air_tags[@intFromEnum(inst)] }); | 726 | std.debug.panic("in codegen.zig, handling of AIR instruction %{d} ('{t}') did not do proper bookkeeping. Look for a missing call to finishAir.", .{ inst, air_tags[@intFromEnum(inst)] }); |
| 727 | } | 727 | } |
| 728 | } | 728 | } |
| 729 | } | 729 | } |
src/arch/wasm/CodeGen.zig+2-2| ... | @@ -2046,7 +2046,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { | ... | @@ -2046,7 +2046,7 @@ fn genBody(cg: *CodeGen, body: []const Air.Inst.Index) InnerError!void { |
| 2046 | try cg.genInst(inst); | 2046 | try cg.genInst(inst); |
| 2047 | 2047 | ||
| 2048 | if (std.debug.runtime_safety and cg.air_bookkeeping < old_bookkeeping_value + 1) { | 2048 | if (std.debug.runtime_safety and cg.air_bookkeeping < old_bookkeeping_value + 1) { |
| 2049 | std.debug.panic("Missing call to `finishAir` in AIR instruction %{d} ('{s}')", .{ | 2049 | std.debug.panic("Missing call to `finishAir` in AIR instruction %{d} ('{t}')", .{ |
| 2050 | inst, | 2050 | inst, |
| 2051 | cg.air.instructions.items(.tag)[@intFromEnum(inst)], | 2051 | cg.air.instructions.items(.tag)[@intFromEnum(inst)], |
| 2052 | }); | 2052 | }); |
| ... | @@ -3326,7 +3326,7 @@ fn emitUndefined(cg: *CodeGen, ty: Type) InnerError!WValue { | ... | @@ -3326,7 +3326,7 @@ fn emitUndefined(cg: *CodeGen, ty: Type) InnerError!WValue { |
| 3326 | }, | 3326 | }, |
| 3327 | else => unreachable, | 3327 | else => unreachable, |
| 3328 | }, | 3328 | }, |
| 3329 | else => return cg.fail("Wasm TODO: emitUndefined for type: {s}\n", .{ty.zigTypeTag(zcu)}), | 3329 | else => return cg.fail("Wasm TODO: emitUndefined for type: {t}\n", .{ty.zigTypeTag(zcu)}), |
| 3330 | } | 3330 | } |
| 3331 | } | 3331 | } |
| 3332 | 3332 |
src/codegen/c.zig+1-1| ... | @@ -1680,7 +1680,7 @@ pub const DeclGen = struct { | ... | @@ -1680,7 +1680,7 @@ pub const DeclGen = struct { |
| 1680 | try w.writeAll("{("); | 1680 | try w.writeAll("{("); |
| 1681 | const ptr_ty = ty.slicePtrFieldType(zcu); | 1681 | const ptr_ty = ty.slicePtrFieldType(zcu); |
| 1682 | try dg.renderType(w, ptr_ty); | 1682 | try dg.renderType(w, ptr_ty); |
| 1683 | return w.print("){f}, {0fx}}}", .{ | 1683 | return w.print("){f}, {0f}}}", .{ |
| 1684 | try dg.fmtIntLiteralHex(.undef_usize, .Other), | 1684 | try dg.fmtIntLiteralHex(.undef_usize, .Other), |
| 1685 | }); | 1685 | }); |
| 1686 | }, | 1686 | }, |
src/link/Lld.zig+1-1| ... | @@ -437,7 +437,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { | ... | @@ -437,7 +437,7 @@ fn coffLink(lld: *Lld, arena: Allocator) !void { |
| 437 | try argv.append(try allocPrint(arena, "-PDBALTPATH:{s}", .{out_pdb_basename})); | 437 | try argv.append(try allocPrint(arena, "-PDBALTPATH:{s}", .{out_pdb_basename})); |
| 438 | } | 438 | } |
| 439 | if (comp.version) |version| { | 439 | if (comp.version) |version| { |
| 440 | try argv.append(try allocPrint(arena, "-VERSION:{f}.{f}", .{ version.major, version.minor })); | 440 | try argv.append(try allocPrint(arena, "-VERSION:{d}.{d}", .{ version.major, version.minor })); |
| 441 | } | 441 | } |
| 442 | 442 | ||
| 443 | if (target_util.llvmMachineAbi(target)) |mabi| { | 443 | if (target_util.llvmMachineAbi(target)) |mabi| { |
src/main.zig+2-2| ... | @@ -3336,8 +3336,8 @@ fn buildOutputType( | ... | @@ -3336,8 +3336,8 @@ fn buildOutputType( |
| 3336 | var hasher = file_writer.interface.hashed(Cache.Hasher.init("0123456789abcdef"), &buffer); | 3336 | var hasher = file_writer.interface.hashed(Cache.Hasher.init("0123456789abcdef"), &buffer); |
| 3337 | var stdin_reader = fs.File.stdin().readerStreaming(&.{}); | 3337 | var stdin_reader = fs.File.stdin().readerStreaming(&.{}); |
| 3338 | _ = hasher.writer.sendFileAll(&stdin_reader, .unlimited) catch |err| switch (err) { | 3338 | _ = hasher.writer.sendFileAll(&stdin_reader, .unlimited) catch |err| switch (err) { |
| 3339 | error.WriteFailed => fatal("failed to write {s}: {s}", .{ dump_path, file_writer.err.? }), | 3339 | error.WriteFailed => fatal("failed to write {s}: {t}", .{ dump_path, file_writer.err.? }), |
| 3340 | else => fatal("failed to pipe stdin to {s}: {s}", .{ dump_path, err }), | 3340 | else => fatal("failed to pipe stdin to {s}: {t}", .{ dump_path, err }), |
| 3341 | }; | 3341 | }; |
| 3342 | try hasher.writer.flush(); | 3342 | try hasher.writer.flush(); |
| 3343 | 3343 |
src/print_value.zig+4-4| ... | @@ -102,7 +102,7 @@ pub fn print( | ... | @@ -102,7 +102,7 @@ pub fn print( |
| 102 | .enum_tag => |enum_tag| { | 102 | .enum_tag => |enum_tag| { |
| 103 | const enum_type = ip.loadEnumType(val.typeOf(zcu).toIntern()); | 103 | const enum_type = ip.loadEnumType(val.typeOf(zcu).toIntern()); |
| 104 | if (enum_type.tagValueIndex(ip, val.toIntern())) |tag_index| { | 104 | if (enum_type.tagValueIndex(ip, val.toIntern())) |tag_index| { |
| 105 | return writer.print(".{fi}", .{enum_type.names.get(ip)[tag_index].fmt(ip)}); | 105 | return writer.print(".{f}", .{enum_type.names.get(ip)[tag_index].fmt(ip)}); |
| 106 | } | 106 | } |
| 107 | if (level == 0) { | 107 | if (level == 0) { |
| 108 | return writer.writeAll("@enumFromInt(...)"); | 108 | return writer.writeAll("@enumFromInt(...)"); |
| ... | @@ -207,7 +207,7 @@ fn printAggregate( | ... | @@ -207,7 +207,7 @@ fn printAggregate( |
| 207 | for (0..max_len) |i| { | 207 | for (0..max_len) |i| { |
| 208 | if (i != 0) try writer.writeAll(", "); | 208 | if (i != 0) try writer.writeAll(", "); |
| 209 | const field_name = ty.structFieldName(@intCast(i), zcu).unwrap().?; | 209 | const field_name = ty.structFieldName(@intCast(i), zcu).unwrap().?; |
| 210 | try writer.print(".{fi} = ", .{field_name.fmt(ip)}); | 210 | try writer.print(".{f} = ", .{field_name.fmt(ip)}); |
| 211 | try print(try val.fieldValue(pt, i), writer, level - 1, pt, opt_sema); | 211 | try print(try val.fieldValue(pt, i), writer, level - 1, pt, opt_sema); |
| 212 | } | 212 | } |
| 213 | try writer.writeAll(" }"); | 213 | try writer.writeAll(" }"); |
| ... | @@ -392,14 +392,14 @@ pub fn printPtrDerivation( | ... | @@ -392,14 +392,14 @@ pub fn printPtrDerivation( |
| 392 | const agg_ty = (try field.parent.ptrType(pt)).childType(zcu); | 392 | const agg_ty = (try field.parent.ptrType(pt)).childType(zcu); |
| 393 | switch (agg_ty.zigTypeTag(zcu)) { | 393 | switch (agg_ty.zigTypeTag(zcu)) { |
| 394 | .@"struct" => if (agg_ty.structFieldName(field.field_idx, zcu).unwrap()) |field_name| { | 394 | .@"struct" => if (agg_ty.structFieldName(field.field_idx, zcu).unwrap()) |field_name| { |
| 395 | try writer.print(".{fi}", .{field_name.fmt(ip)}); | 395 | try writer.print(".{f}", .{field_name.fmt(ip)}); |
| 396 | } else { | 396 | } else { |
| 397 | try writer.print("[{d}]", .{field.field_idx}); | 397 | try writer.print("[{d}]", .{field.field_idx}); |
| 398 | }, | 398 | }, |
| 399 | .@"union" => { | 399 | .@"union" => { |
| 400 | const tag_ty = agg_ty.unionTagTypeHypothetical(zcu); | 400 | const tag_ty = agg_ty.unionTagTypeHypothetical(zcu); |
| 401 | const field_name = tag_ty.enumFieldName(field.field_idx, zcu); | 401 | const field_name = tag_ty.enumFieldName(field.field_idx, zcu); |
| 402 | try writer.print(".{fi}", .{field_name.fmt(ip)}); | 402 | try writer.print(".{f}", .{field_name.fmt(ip)}); |
| 403 | }, | 403 | }, |
| 404 | .pointer => switch (field.field_idx) { | 404 | .pointer => switch (field.field_idx) { |
| 405 | Value.slice_ptr_index => try writer.writeAll(".ptr"), | 405 | Value.slice_ptr_index => try writer.writeAll(".ptr"), |
src/register_manager.zig+3-3| ... | @@ -238,7 +238,7 @@ pub fn RegisterManager( | ... | @@ -238,7 +238,7 @@ pub fn RegisterManager( |
| 238 | if (i < count) return null; | 238 | if (i < count) return null; |
| 239 | 239 | ||
| 240 | for (regs, insts) |reg, inst| { | 240 | for (regs, insts) |reg, inst| { |
| 241 | log.debug("tryAllocReg {} for inst {f}", .{ reg, inst }); | 241 | log.debug("tryAllocReg {} for inst {?f}", .{ reg, inst }); |
| 242 | self.markRegAllocated(reg); | 242 | self.markRegAllocated(reg); |
| 243 | 243 | ||
| 244 | if (inst) |tracked_inst| { | 244 | if (inst) |tracked_inst| { |
| ... | @@ -317,7 +317,7 @@ pub fn RegisterManager( | ... | @@ -317,7 +317,7 @@ pub fn RegisterManager( |
| 317 | tracked_index: TrackedIndex, | 317 | tracked_index: TrackedIndex, |
| 318 | inst: ?Air.Inst.Index, | 318 | inst: ?Air.Inst.Index, |
| 319 | ) AllocationError!void { | 319 | ) AllocationError!void { |
| 320 | log.debug("getReg {} for inst {f}", .{ regAtTrackedIndex(tracked_index), inst }); | 320 | log.debug("getReg {} for inst {?f}", .{ regAtTrackedIndex(tracked_index), inst }); |
| 321 | if (!self.isRegIndexFree(tracked_index)) { | 321 | if (!self.isRegIndexFree(tracked_index)) { |
| 322 | // Move the instruction that was previously there to a | 322 | // Move the instruction that was previously there to a |
| 323 | // stack allocation. | 323 | // stack allocation. |
| ... | @@ -349,7 +349,7 @@ pub fn RegisterManager( | ... | @@ -349,7 +349,7 @@ pub fn RegisterManager( |
| 349 | tracked_index: TrackedIndex, | 349 | tracked_index: TrackedIndex, |
| 350 | inst: ?Air.Inst.Index, | 350 | inst: ?Air.Inst.Index, |
| 351 | ) void { | 351 | ) void { |
| 352 | log.debug("getRegAssumeFree {} for inst {f}", .{ regAtTrackedIndex(tracked_index), inst }); | 352 | log.debug("getRegAssumeFree {} for inst {?f}", .{ regAtTrackedIndex(tracked_index), inst }); |
| 353 | self.markRegIndexAllocated(tracked_index); | 353 | self.markRegIndexAllocated(tracked_index); |
| 354 | 354 | ||
| 355 | assert(self.isRegIndexFree(tracked_index)); | 355 | assert(self.isRegIndexFree(tracked_index)); |