| author | |
| committer | |
| log | 8a5818535b83ba87849cb09de9f1ccd32e8bb480 |
| tree | 8b63ffe15c08edbe921d17594c5d333219937670 |
| parent | 32b97df50ea18a194ce9e14b267c99f146a3e2fd |
| signature |
* Export invalidFmtErr
To allow consistent use of "invalid format string" compile error
response for badly formatted format strings.
See https://github.com/ziglang/zig/pull/13489#issuecomment-1311759340.
* Replace format compile errors with invalidFmtErr
- Provides more consistent compile errors.
- Gives user info about the type of the badly formated value.
* Rename invalidFmtErr as invalidFmtError
For consistency. Zig seems to use “Error” more often than “Err”.
* std: add invalid format string checks to remaining custom formatters
* pass reference-trace to comp when building build file; fix checkobjectstep18 files changed, 52 insertions(+), 43 deletions(-)
lib/std/SemanticVersion.zig+1-1| ... | ... | @@ -157,7 +157,7 @@ pub fn format( |
| 157 | 157 | out_stream: anytype, |
| 158 | 158 | ) !void { |
| 159 | 159 | _ = options; |
| 160 | if (fmt.len != 0) @compileError("Unknown format string: '" ++ fmt ++ "'"); | |
| 160 | if (fmt.len != 0) std.fmt.invalidFmtError(fmt, self); | |
| 161 | 161 | try std.fmt.format(out_stream, "{d}.{d}.{d}", .{ self.major, self.minor, self.patch }); |
| 162 | 162 | if (self.pre) |pre| try std.fmt.format(out_stream, "-{s}", .{pre}); |
| 163 | 163 | if (self.build) |build| try std.fmt.format(out_stream, "+{s}", .{build}); |
lib/std/build/CheckObjectStep.zig+2-2| ... | ... | @@ -187,7 +187,7 @@ const ComputeCompareExpected = struct { |
| 187 | 187 | options: std.fmt.FormatOptions, |
| 188 | 188 | writer: anytype, |
| 189 | 189 | ) !void { |
| 190 | _ = fmt; | |
| 190 | if (fmt.len != 0) std.fmt.invalidFmtError(fmt, value); | |
| 191 | 191 | _ = options; |
| 192 | 192 | try writer.print("{s} ", .{@tagName(value.op)}); |
| 193 | 193 | switch (value.value) { |
| ... | ... | @@ -360,7 +360,7 @@ fn make(step: *Step) !void { |
| 360 | 360 | std.debug.print( |
| 361 | 361 | \\ |
| 362 | 362 | \\========= Comparison failed for action: =========== |
| 363 | \\{s} {s} | |
| 363 | \\{s} {} | |
| 364 | 364 | \\========= From parsed file: ======================= |
| 365 | 365 | \\{s} |
| 366 | 366 | \\ |
lib/std/builtin.zig+3-2| ... | ... | @@ -38,12 +38,13 @@ pub const StackTrace = struct { |
| 38 | 38 | options: std.fmt.FormatOptions, |
| 39 | 39 | writer: anytype, |
| 40 | 40 | ) !void { |
| 41 | if (fmt.len != 0) std.fmt.invalidFmtError(fmt, self); | |
| 42 | ||
| 41 | 43 | // TODO: re-evaluate whether to use format() methods at all. |
| 42 | 44 | // Until then, avoid an error when using GeneralPurposeAllocator with WebAssembly |
| 43 | 45 | // where it tries to call detectTTYConfig here. |
| 44 | 46 | if (builtin.os.tag == .freestanding) return; |
| 45 | 47 | |
| 46 | _ = fmt; | |
| 47 | 48 | _ = options; |
| 48 | 49 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 49 | 50 | defer arena.deinit(); |
| ... | ... | @@ -534,7 +535,7 @@ pub const Version = struct { |
| 534 | 535 | return std.fmt.format(out_stream, "{d}.{d}.{d}", .{ self.major, self.minor, self.patch }); |
| 535 | 536 | } |
| 536 | 537 | } else { |
| 537 | @compileError("Unknown format string: '" ++ fmt ++ "'"); | |
| 538 | std.fmt.invalidFmtError(fmt, self); | |
| 538 | 539 | } |
| 539 | 540 | } |
| 540 | 541 | }; |
lib/std/debug.zig+1-1| ... | ... | @@ -2123,7 +2123,7 @@ pub fn ConfigurableTrace(comptime size: usize, comptime stack_frame_count: usize |
| 2123 | 2123 | options: std.fmt.FormatOptions, |
| 2124 | 2124 | writer: anytype, |
| 2125 | 2125 | ) !void { |
| 2126 | _ = fmt; | |
| 2126 | if (fmt.len != 0) std.fmt.invalidFmtError(fmt, t); | |
| 2127 | 2127 | _ = options; |
| 2128 | 2128 | if (enabled) { |
| 2129 | 2129 | try writer.writeAll("\n"); |
lib/std/fmt.zig+15-15| ... | ... | @@ -454,7 +454,7 @@ fn stripOptionalOrErrorUnionSpec(comptime fmt: []const u8) []const u8 { |
| 454 | 454 | fmt[1..]; |
| 455 | 455 | } |
| 456 | 456 | |
| 457 | fn invalidFmtErr(comptime fmt: []const u8, value: anytype) void { | |
| 457 | pub fn invalidFmtError(comptime fmt: []const u8, value: anytype) void { | |
| 458 | 458 | @compileError("invalid format string '" ++ fmt ++ "' for type '" ++ @typeName(@TypeOf(value)) ++ "'"); |
| 459 | 459 | } |
| 460 | 460 | |
| ... | ... | @@ -486,11 +486,11 @@ pub fn formatType( |
| 486 | 486 | return formatValue(value, actual_fmt, options, writer); |
| 487 | 487 | }, |
| 488 | 488 | .Void => { |
| 489 | if (actual_fmt.len != 0) invalidFmtErr(fmt, value); | |
| 489 | if (actual_fmt.len != 0) invalidFmtError(fmt, value); | |
| 490 | 490 | return formatBuf("void", options, writer); |
| 491 | 491 | }, |
| 492 | 492 | .Bool => { |
| 493 | if (actual_fmt.len != 0) invalidFmtErr(fmt, value); | |
| 493 | if (actual_fmt.len != 0) invalidFmtError(fmt, value); | |
| 494 | 494 | return formatBuf(if (value) "true" else "false", options, writer); |
| 495 | 495 | }, |
| 496 | 496 | .Optional => { |
| ... | ... | @@ -514,14 +514,14 @@ pub fn formatType( |
| 514 | 514 | } |
| 515 | 515 | }, |
| 516 | 516 | .ErrorSet => { |
| 517 | if (actual_fmt.len != 0) invalidFmtErr(fmt, value); | |
| 517 | if (actual_fmt.len != 0) invalidFmtError(fmt, value); | |
| 518 | 518 | try writer.writeAll("error."); |
| 519 | 519 | return writer.writeAll(@errorName(value)); |
| 520 | 520 | }, |
| 521 | 521 | .Enum => |enumInfo| { |
| 522 | 522 | try writer.writeAll(@typeName(T)); |
| 523 | 523 | if (enumInfo.is_exhaustive) { |
| 524 | if (actual_fmt.len != 0) invalidFmtErr(fmt, value); | |
| 524 | if (actual_fmt.len != 0) invalidFmtError(fmt, value); | |
| 525 | 525 | try writer.writeAll("."); |
| 526 | 526 | try writer.writeAll(@tagName(value)); |
| 527 | 527 | return; |
| ... | ... | @@ -542,7 +542,7 @@ pub fn formatType( |
| 542 | 542 | try writer.writeAll(")"); |
| 543 | 543 | }, |
| 544 | 544 | .Union => |info| { |
| 545 | if (actual_fmt.len != 0) invalidFmtErr(fmt, value); | |
| 545 | if (actual_fmt.len != 0) invalidFmtError(fmt, value); | |
| 546 | 546 | try writer.writeAll(@typeName(T)); |
| 547 | 547 | if (max_depth == 0) { |
| 548 | 548 | return writer.writeAll("{ ... }"); |
| ... | ... | @@ -562,7 +562,7 @@ pub fn formatType( |
| 562 | 562 | } |
| 563 | 563 | }, |
| 564 | 564 | .Struct => |info| { |
| 565 | if (actual_fmt.len != 0) invalidFmtErr(fmt, value); | |
| 565 | if (actual_fmt.len != 0) invalidFmtError(fmt, value); | |
| 566 | 566 | if (info.is_tuple) { |
| 567 | 567 | // Skip the type and field names when formatting tuples. |
| 568 | 568 | if (max_depth == 0) { |
| ... | ... | @@ -618,7 +618,7 @@ pub fn formatType( |
| 618 | 618 | } |
| 619 | 619 | return; |
| 620 | 620 | } |
| 621 | invalidFmtErr(fmt, value); | |
| 621 | invalidFmtError(fmt, value); | |
| 622 | 622 | }, |
| 623 | 623 | .Enum, .Union, .Struct => { |
| 624 | 624 | return formatType(value.*, actual_fmt, options, writer, max_depth); |
| ... | ... | @@ -640,7 +640,7 @@ pub fn formatType( |
| 640 | 640 | else => {}, |
| 641 | 641 | } |
| 642 | 642 | } |
| 643 | invalidFmtErr(fmt, value); | |
| 643 | invalidFmtError(fmt, value); | |
| 644 | 644 | }, |
| 645 | 645 | .Slice => { |
| 646 | 646 | if (actual_fmt.len == 0) |
| ... | ... | @@ -703,20 +703,20 @@ pub fn formatType( |
| 703 | 703 | try writer.writeAll(" }"); |
| 704 | 704 | }, |
| 705 | 705 | .Fn => { |
| 706 | if (actual_fmt.len != 0) invalidFmtErr(fmt, value); | |
| 706 | if (actual_fmt.len != 0) invalidFmtError(fmt, value); | |
| 707 | 707 | return format(writer, "{s}@{x}", .{ @typeName(T), @ptrToInt(value) }); |
| 708 | 708 | }, |
| 709 | 709 | .Type => { |
| 710 | if (actual_fmt.len != 0) invalidFmtErr(fmt, value); | |
| 710 | if (actual_fmt.len != 0) invalidFmtError(fmt, value); | |
| 711 | 711 | return formatBuf(@typeName(value), options, writer); |
| 712 | 712 | }, |
| 713 | 713 | .EnumLiteral => { |
| 714 | if (actual_fmt.len != 0) invalidFmtErr(fmt, value); | |
| 714 | if (actual_fmt.len != 0) invalidFmtError(fmt, value); | |
| 715 | 715 | const buffer = [_]u8{'.'} ++ @tagName(value); |
| 716 | 716 | return formatBuf(buffer, options, writer); |
| 717 | 717 | }, |
| 718 | 718 | .Null => { |
| 719 | if (actual_fmt.len != 0) invalidFmtErr(fmt, value); | |
| 719 | if (actual_fmt.len != 0) invalidFmtError(fmt, value); | |
| 720 | 720 | return formatBuf("null", options, writer); |
| 721 | 721 | }, |
| 722 | 722 | else => @compileError("unable to format type '" ++ @typeName(T) ++ "'"), |
| ... | ... | @@ -786,7 +786,7 @@ pub fn formatIntValue( |
| 786 | 786 | radix = 8; |
| 787 | 787 | case = .lower; |
| 788 | 788 | } else { |
| 789 | invalidFmtErr(fmt, value); | |
| 789 | invalidFmtError(fmt, value); | |
| 790 | 790 | } |
| 791 | 791 | |
| 792 | 792 | return formatInt(int_value, radix, case, options, writer); |
| ... | ... | @@ -815,7 +815,7 @@ fn formatFloatValue( |
| 815 | 815 | error.NoSpaceLeft => unreachable, |
| 816 | 816 | }; |
| 817 | 817 | } else { |
| 818 | invalidFmtErr(fmt, value); | |
| 818 | invalidFmtError(fmt, value); | |
| 819 | 819 | } |
| 820 | 820 | |
| 821 | 821 | return formatBuf(buf_stream.getWritten(), options, writer); |
lib/std/fs/wasi.zig+1-1| ... | ... | @@ -62,7 +62,7 @@ pub const PreopenType = union(PreopenTypeTag) { |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | pub fn format(self: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, out_stream: anytype) !void { |
| 65 | _ = fmt; | |
| 65 | if (fmt.len != 0) std.fmt.invalidFmtError(fmt, self); | |
| 66 | 66 | _ = options; |
| 67 | 67 | try out_stream.print("PreopenType{{ ", .{}); |
| 68 | 68 | switch (self) { |
lib/std/heap/general_purpose_allocator.zig+5-5| ... | ... | @@ -326,7 +326,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 326 | 326 | const slot_index = @intCast(SlotIndex, used_bits_byte * 8 + bit_index); |
| 327 | 327 | const stack_trace = bucketStackTrace(bucket, size_class, slot_index, .alloc); |
| 328 | 328 | const addr = bucket.page + slot_index * size_class; |
| 329 | log.err("memory address 0x{x} leaked: {s}", .{ | |
| 329 | log.err("memory address 0x{x} leaked: {}", .{ | |
| 330 | 330 | @ptrToInt(addr), stack_trace, |
| 331 | 331 | }); |
| 332 | 332 | leaks = true; |
| ... | ... | @@ -358,7 +358,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 358 | 358 | while (it.next()) |large_alloc| { |
| 359 | 359 | if (config.retain_metadata and large_alloc.freed) continue; |
| 360 | 360 | const stack_trace = large_alloc.getStackTrace(.alloc); |
| 361 | log.err("memory address 0x{x} leaked: {s}", .{ | |
| 361 | log.err("memory address 0x{x} leaked: {}", .{ | |
| 362 | 362 | @ptrToInt(large_alloc.bytes.ptr), stack_trace, |
| 363 | 363 | }); |
| 364 | 364 | leaks = true; |
| ... | ... | @@ -443,7 +443,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 443 | 443 | .index = 0, |
| 444 | 444 | }; |
| 445 | 445 | std.debug.captureStackTrace(ret_addr, &second_free_stack_trace); |
| 446 | log.err("Double free detected. Allocation: {s} First free: {s} Second free: {s}", .{ | |
| 446 | log.err("Double free detected. Allocation: {} First free: {} Second free: {}", .{ | |
| 447 | 447 | alloc_stack_trace, free_stack_trace, second_free_stack_trace, |
| 448 | 448 | }); |
| 449 | 449 | } |
| ... | ... | @@ -533,7 +533,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 533 | 533 | .index = 0, |
| 534 | 534 | }; |
| 535 | 535 | std.debug.captureStackTrace(ret_addr, &free_stack_trace); |
| 536 | log.err("Allocation size {d} bytes does not match free size {d}. Allocation: {s} Free: {s}", .{ | |
| 536 | log.err("Allocation size {d} bytes does not match free size {d}. Allocation: {} Free: {}", .{ | |
| 537 | 537 | entry.value_ptr.bytes.len, |
| 538 | 538 | old_mem.len, |
| 539 | 539 | entry.value_ptr.getStackTrace(.alloc), |
| ... | ... | @@ -606,7 +606,7 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 606 | 606 | .index = 0, |
| 607 | 607 | }; |
| 608 | 608 | std.debug.captureStackTrace(ret_addr, &free_stack_trace); |
| 609 | log.err("Allocation size {d} bytes does not match free size {d}. Allocation: {s} Free: {s}", .{ | |
| 609 | log.err("Allocation size {d} bytes does not match free size {d}. Allocation: {} Free: {}", .{ | |
| 610 | 610 | entry.value_ptr.bytes.len, |
| 611 | 611 | old_mem.len, |
| 612 | 612 | entry.value_ptr.getStackTrace(.alloc), |
lib/std/math/big/int.zig+1-1| ... | ... | @@ -2061,7 +2061,7 @@ pub const Const = struct { |
| 2061 | 2061 | radix = 16; |
| 2062 | 2062 | case = .upper; |
| 2063 | 2063 | } else { |
| 2064 | @compileError("Unknown format string: '" ++ fmt ++ "'"); | |
| 2064 | std.fmt.invalidFmtError(fmt, self); | |
| 2065 | 2065 | } |
| 2066 | 2066 | |
| 2067 | 2067 | var limbs: [128]Limb = undefined; |
lib/std/net.zig+3-2| ... | ... | @@ -149,6 +149,7 @@ pub const Address = extern union { |
| 149 | 149 | options: std.fmt.FormatOptions, |
| 150 | 150 | out_stream: anytype, |
| 151 | 151 | ) !void { |
| 152 | if (fmt.len != 0) std.fmt.invalidFmtError(fmt, self); | |
| 152 | 153 | switch (self.any.family) { |
| 153 | 154 | os.AF.INET => try self.in.format(fmt, options, out_stream), |
| 154 | 155 | os.AF.INET6 => try self.in6.format(fmt, options, out_stream), |
| ... | ... | @@ -274,7 +275,7 @@ pub const Ip4Address = extern struct { |
| 274 | 275 | options: std.fmt.FormatOptions, |
| 275 | 276 | out_stream: anytype, |
| 276 | 277 | ) !void { |
| 277 | _ = fmt; | |
| 278 | if (fmt.len != 0) std.fmt.invalidFmtError(fmt, self); | |
| 278 | 279 | _ = options; |
| 279 | 280 | const bytes = @ptrCast(*const [4]u8, &self.sa.addr); |
| 280 | 281 | try std.fmt.format(out_stream, "{}.{}.{}.{}:{}", .{ |
| ... | ... | @@ -563,7 +564,7 @@ pub const Ip6Address = extern struct { |
| 563 | 564 | options: std.fmt.FormatOptions, |
| 564 | 565 | out_stream: anytype, |
| 565 | 566 | ) !void { |
| 566 | _ = fmt; | |
| 567 | if (fmt.len != 0) std.fmt.invalidFmtError(fmt, self); | |
| 567 | 568 | _ = options; |
| 568 | 569 | const port = mem.bigToNative(u16, self.sa.port); |
| 569 | 570 | if (mem.eql(u8, self.sa.addr[0..12], &[_]u8{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff })) { |
lib/std/os/uefi.zig+1-1| ... | ... | @@ -68,7 +68,7 @@ pub const Guid = extern struct { |
| 68 | 68 | fmt(std.mem.asBytes(&self.node)), |
| 69 | 69 | }); |
| 70 | 70 | } else { |
| 71 | @compileError("Unknown format character: '" ++ f ++ "'"); | |
| 71 | std.fmt.invalidFmtError(f, self); | |
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 |
lib/std/target.zig+4-2| ... | ... | @@ -167,19 +167,21 @@ pub const Target = struct { |
| 167 | 167 | _: std.fmt.FormatOptions, |
| 168 | 168 | out_stream: anytype, |
| 169 | 169 | ) !void { |
| 170 | if (fmt.len > 0 and fmt[0] == 's') { | |
| 170 | if (comptime std.mem.eql(u8, fmt, "s")) { | |
| 171 | 171 | if (@enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.latest)) { |
| 172 | 172 | try std.fmt.format(out_stream, ".{s}", .{@tagName(self)}); |
| 173 | 173 | } else { |
| 174 | 174 | // TODO this code path breaks zig triples, but it is used in `builtin` |
| 175 | 175 | try std.fmt.format(out_stream, "@intToEnum(Target.Os.WindowsVersion, 0x{X:0>8})", .{@enumToInt(self)}); |
| 176 | 176 | } |
| 177 | } else { | |
| 177 | } else if (fmt.len == 0) { | |
| 178 | 178 | if (@enumToInt(self) >= @enumToInt(WindowsVersion.nt4) and @enumToInt(self) <= @enumToInt(WindowsVersion.latest)) { |
| 179 | 179 | try std.fmt.format(out_stream, "WindowsVersion.{s}", .{@tagName(self)}); |
| 180 | 180 | } else { |
| 181 | 181 | try std.fmt.format(out_stream, "WindowsVersion(0x{X:0>8})", .{@enumToInt(self)}); |
| 182 | 182 | } |
| 183 | } else { | |
| 184 | std.fmt.invalidFmtError(fmt, self); | |
| 183 | 185 | } |
| 184 | 186 | } |
| 185 | 187 | }; |
lib/std/testing.zig+1-1| ... | ... | @@ -700,7 +700,7 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime |
| 700 | 700 | error.OutOfMemory => { |
| 701 | 701 | if (failing_allocator_inst.allocated_bytes != failing_allocator_inst.freed_bytes) { |
| 702 | 702 | print( |
| 703 | "\nfail_index: {d}/{d}\nallocated bytes: {d}\nfreed bytes: {d}\nallocations: {d}\ndeallocations: {d}\nallocation that was made to fail: {s}", | |
| 703 | "\nfail_index: {d}/{d}\nallocated bytes: {d}\nfreed bytes: {d}\nallocations: {d}\ndeallocations: {d}\nallocation that was made to fail: {}", | |
| 704 | 704 | .{ |
| 705 | 705 | fail_index, |
| 706 | 706 | needed_alloc_count, |
lib/std/wasm.zig+1-1| ... | ... | @@ -356,7 +356,7 @@ pub const Type = struct { |
| 356 | 356 | returns: []const Valtype, |
| 357 | 357 | |
| 358 | 358 | pub fn format(self: Type, comptime fmt: []const u8, opt: std.fmt.FormatOptions, writer: anytype) !void { |
| 359 | _ = fmt; | |
| 359 | if (fmt.len != 0) std.fmt.invalidFmtError(fmt, self); | |
| 360 | 360 | _ = opt; |
| 361 | 361 | try writer.writeByte('('); |
| 362 | 362 | for (self.params) |param, i| { |
lib/std/x/net/bpf.zig+1-2| ... | ... | @@ -282,8 +282,7 @@ pub const Insn = extern struct { |
| 282 | 282 | writer: anytype, |
| 283 | 283 | ) !void { |
| 284 | 284 | _ = opts; |
| 285 | if (comptime layout.len != 0 and layout[0] != 's') | |
| 286 | @compileError("Unsupported format specifier for BPF Insn type '" ++ layout ++ "'."); | |
| 285 | if (layout.len != 0) std.fmt.invalidFmtError(layout, self); | |
| 287 | 286 | |
| 288 | 287 | try std.fmt.format( |
| 289 | 288 | writer, |
lib/std/x/net/ip.zig+1-1| ... | ... | @@ -47,8 +47,8 @@ pub const Address = union(enum) { |
| 47 | 47 | opts: fmt.FormatOptions, |
| 48 | 48 | writer: anytype, |
| 49 | 49 | ) !void { |
| 50 | if (layout.len != 0) std.fmt.invalidFmtError(layout, self); | |
| 50 | 51 | _ = opts; |
| 51 | _ = layout; | |
| 52 | 52 | switch (self) { |
| 53 | 53 | .ipv4 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }), |
| 54 | 54 | .ipv6 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }), |
lib/std/x/os/net.zig+2-4| ... | ... | @@ -168,9 +168,7 @@ pub const IPv4 = extern struct { |
| 168 | 168 | writer: anytype, |
| 169 | 169 | ) !void { |
| 170 | 170 | _ = opts; |
| 171 | if (comptime layout.len != 0 and layout[0] != 's') { | |
| 172 | @compileError("Unsupported format specifier for IPv4 type '" ++ layout ++ "'."); | |
| 173 | } | |
| 171 | if (layout.len != 0) std.fmt.invalidFmtError(layout, self); | |
| 174 | 172 | |
| 175 | 173 | try fmt.format(writer, "{}.{}.{}.{}", .{ |
| 176 | 174 | self.octets[0], |
| ... | ... | @@ -382,7 +380,7 @@ pub const IPv6 = extern struct { |
| 382 | 380 | 'x', 'X' => |specifier| specifier, |
| 383 | 381 | 's' => 'x', |
| 384 | 382 | 'S' => 'X', |
| 385 | else => @compileError("Unsupported format specifier for IPv6 type '" ++ layout ++ "'."), | |
| 383 | else => std.fmt.invalidFmtError(layout, self), | |
| 386 | 384 | }}; |
| 387 | 385 | |
| 388 | 386 | if (mem.startsWith(u8, &self.octets, &v4_mapped_prefix)) { |
lib/std/x/os/socket.zig+1-1| ... | ... | @@ -127,8 +127,8 @@ pub const Socket = struct { |
| 127 | 127 | opts: fmt.FormatOptions, |
| 128 | 128 | writer: anytype, |
| 129 | 129 | ) !void { |
| 130 | if (layout.len != 0) std.fmt.invalidFmtError(layout, self); | |
| 130 | 131 | _ = opts; |
| 131 | _ = layout; | |
| 132 | 132 | switch (self) { |
| 133 | 133 | .ipv4 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }), |
| 134 | 134 | .ipv6 => |address| try fmt.format(writer, "{}:{}", .{ address.host, address.port }), |
src/main.zig+8| ... | ... | @@ -3744,6 +3744,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi |
| 3744 | 3744 | var override_global_cache_dir: ?[]const u8 = try optionalStringEnvVar(arena, "ZIG_GLOBAL_CACHE_DIR"); |
| 3745 | 3745 | var override_local_cache_dir: ?[]const u8 = try optionalStringEnvVar(arena, "ZIG_LOCAL_CACHE_DIR"); |
| 3746 | 3746 | var child_argv = std.ArrayList([]const u8).init(arena); |
| 3747 | var reference_trace: ?u32 = null; | |
| 3747 | 3748 | |
| 3748 | 3749 | const argv_index_exe = child_argv.items.len; |
| 3749 | 3750 | _ = try child_argv.addOne(); |
| ... | ... | @@ -3795,10 +3796,16 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi |
| 3795 | 3796 | try child_argv.append(arg); |
| 3796 | 3797 | } else if (mem.eql(u8, arg, "-freference-trace")) { |
| 3797 | 3798 | try child_argv.append(arg); |
| 3799 | reference_trace = 256; | |
| 3798 | 3800 | } else if (mem.startsWith(u8, arg, "-freference-trace=")) { |
| 3799 | 3801 | try child_argv.append(arg); |
| 3802 | const num = arg["-freference-trace=".len..]; | |
| 3803 | reference_trace = std.fmt.parseUnsigned(u32, num, 10) catch |err| { | |
| 3804 | fatal("unable to parse reference_trace count '{s}': {s}", .{ num, @errorName(err) }); | |
| 3805 | }; | |
| 3800 | 3806 | } else if (mem.eql(u8, arg, "-fno-reference-trace")) { |
| 3801 | 3807 | try child_argv.append(arg); |
| 3808 | reference_trace = null; | |
| 3802 | 3809 | } |
| 3803 | 3810 | } |
| 3804 | 3811 | try child_argv.append(arg); |
| ... | ... | @@ -3932,6 +3939,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi |
| 3932 | 3939 | .thread_pool = &thread_pool, |
| 3933 | 3940 | .use_stage1 = use_stage1, |
| 3934 | 3941 | .cache_mode = .whole, |
| 3942 | .reference_trace = reference_trace, | |
| 3935 | 3943 | }) catch |err| { |
| 3936 | 3944 | fatal("unable to create compilation: {s}", .{@errorName(err)}); |
| 3937 | 3945 | }; |