authorgravatar for r00ster91@proton.meWooster <r00ster91@proton.me> 2022-07-23 17:02:55+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-07-27 18:07:53+03:00
log4ef7d8581085394d55f5effbb38c05a15546af1b
tree6491407fba9ac7738e31852387e9089623afdb1d
parent7ba1f9bfb52a1f6fa776eeafb45790331be4388f

std.fmt: lowercase compile errors

`compileError\("([A-Z])` and `compileError\("\L\1`. It's pretty convenient.

2 files changed, 25 insertions(+), 25 deletions(-)

doc/langref.html.in+1-1
......@@ -7228,7 +7228,7 @@ pub fn print(self: *Writer, arg0: []const u8, arg1: i32) !void {
72287228 <p>
72297229 And now, what happens if we give too many arguments to {#syntax#}print{#endsyntax#}?
72307230 </p>
7231 {#code_begin|test_err|Unused argument in 'here is a string: '{s}' here is a number: {}#}
7231 {#code_begin|test_err|unused argument in 'here is a string: '{s}' here is a number: {}#}
72327232const print = @import("std").debug.print;
72337233
72347234const a_number: i32 = 1234;
lib/std/fmt.zig+24-24
......@@ -83,7 +83,7 @@ pub fn format(
8383 const ArgsType = @TypeOf(args);
8484 const args_type_info = @typeInfo(ArgsType);
8585 if (args_type_info != .Struct) {
86 @compileError("Expected tuple or struct argument, found " ++ @typeName(ArgsType));
86 @compileError("expected tuple or struct argument, found " ++ @typeName(ArgsType));
8787 }
8888
8989 const fields_info = args_type_info.Struct.fields;
......@@ -127,7 +127,7 @@ pub fn format(
127127 if (i >= fmt.len) break;
128128
129129 if (fmt[i] == '}') {
130 @compileError("Missing opening {");
130 @compileError("missing opening {");
131131 }
132132
133133 // Get past the {
......@@ -140,7 +140,7 @@ pub fn format(
140140 const fmt_end = i;
141141
142142 if (i >= fmt.len) {
143 @compileError("Missing closing }");
143 @compileError("missing closing }");
144144 }
145145
146146 // Get past the }
......@@ -152,7 +152,7 @@ pub fn format(
152152 .none => null,
153153 .number => |pos| pos,
154154 .named => |arg_name| meta.fieldIndex(ArgsType, arg_name) orelse
155 @compileError("No argument with name '" ++ arg_name ++ "'"),
155 @compileError("no argument with name '" ++ arg_name ++ "'"),
156156 };
157157
158158 const width = switch (placeholder.width) {
......@@ -160,8 +160,8 @@ pub fn format(
160160 .number => |v| v,
161161 .named => |arg_name| blk: {
162162 const arg_i = comptime meta.fieldIndex(ArgsType, arg_name) orelse
163 @compileError("No argument with name '" ++ arg_name ++ "'");
164 _ = comptime arg_state.nextArg(arg_i) orelse @compileError("Too few arguments");
163 @compileError("no argument with name '" ++ arg_name ++ "'");
164 _ = comptime arg_state.nextArg(arg_i) orelse @compileError("too few arguments");
165165 break :blk @field(args, arg_name);
166166 },
167167 };
......@@ -171,14 +171,14 @@ pub fn format(
171171 .number => |v| v,
172172 .named => |arg_name| blk: {
173173 const arg_i = comptime meta.fieldIndex(ArgsType, arg_name) orelse
174 @compileError("No argument with name '" ++ arg_name ++ "'");
175 _ = comptime arg_state.nextArg(arg_i) orelse @compileError("Too few arguments");
174 @compileError("no argument with name '" ++ arg_name ++ "'");
175 _ = comptime arg_state.nextArg(arg_i) orelse @compileError("too few arguments");
176176 break :blk @field(args, arg_name);
177177 },
178178 };
179179
180180 const arg_to_print = comptime arg_state.nextArg(arg_pos) orelse
181 @compileError("Too few arguments");
181 @compileError("too few arguments");
182182
183183 try formatType(
184184 @field(args, fields_info[arg_to_print].name),
......@@ -198,7 +198,7 @@ pub fn format(
198198 const missing_count = arg_state.args_len - @popCount(ArgSetType, arg_state.used_args);
199199 switch (missing_count) {
200200 0 => unreachable,
201 1 => @compileError("Unused argument in '" ++ fmt ++ "'"),
201 1 => @compileError("unused argument in '" ++ fmt ++ "'"),
202202 else => @compileError((comptime comptimePrint("{d}", .{missing_count})) ++ " unused arguments in '" ++ fmt ++ "'"),
203203 }
204204 }
......@@ -217,7 +217,7 @@ fn parsePlaceholder(comptime str: anytype) Placeholder {
217217 // Skip the colon, if present
218218 if (comptime parser.char()) |ch| {
219219 if (ch != ':') {
220 @compileError("Expected : or }, found '" ++ [1]u8{ch} ++ "'");
220 @compileError("expected : or }, found '" ++ [1]u8{ch} ++ "'");
221221 }
222222 }
223223
......@@ -252,7 +252,7 @@ fn parsePlaceholder(comptime str: anytype) Placeholder {
252252 // Skip the dot, if present
253253 if (comptime parser.char()) |ch| {
254254 if (ch != '.') {
255 @compileError("Expected . or }, found '" ++ [1]u8{ch} ++ "'");
255 @compileError("expected . or }, found '" ++ [1]u8{ch} ++ "'");
256256 }
257257 }
258258
......@@ -261,7 +261,7 @@ fn parsePlaceholder(comptime str: anytype) Placeholder {
261261 @compileError(@errorName(err));
262262
263263 if (comptime parser.char()) |ch| {
264 @compileError("Extraneous trailing character '" ++ [1]u8{ch} ++ "'");
264 @compileError("extraneous trailing character '" ++ [1]u8{ch} ++ "'");
265265 }
266266
267267 return Placeholder{
......@@ -423,7 +423,7 @@ pub fn formatAddress(value: anytype, options: FormatOptions, writer: anytype) @T
423423 else => {},
424424 }
425425
426 @compileError("Cannot format non-pointer type " ++ @typeName(T) ++ " with * specifier");
426 @compileError("cannot format non-pointer type " ++ @typeName(T) ++ " with * specifier");
427427}
428428
429429// This ANY const is a workaround for: https://github.com/ziglang/zig/issues/7948
......@@ -608,7 +608,7 @@ pub fn formatType(
608608 }
609609 return;
610610 }
611 @compileError("Unknown format string: '" ++ actual_fmt ++ "' for type '" ++ @typeName(T) ++ "'");
611 @compileError("unknown format string: '" ++ actual_fmt ++ "' for type '" ++ @typeName(T) ++ "'");
612612 },
613613 .Enum, .Union, .Struct => {
614614 return formatType(value.*, actual_fmt, options, writer, max_depth);
......@@ -630,7 +630,7 @@ pub fn formatType(
630630 else => {},
631631 }
632632 }
633 @compileError("Unknown format string: '" ++ actual_fmt ++ "' for type '" ++ @typeName(T) ++ "'");
633 @compileError("unknown format string: '" ++ actual_fmt ++ "' for type '" ++ @typeName(T) ++ "'");
634634 },
635635 .Slice => {
636636 if (actual_fmt.len == 0)
......@@ -701,7 +701,7 @@ pub fn formatType(
701701 return formatBuf(buffer, options, writer);
702702 },
703703 .Null => return formatBuf("null", options, writer),
704 else => @compileError("Unable to format type '" ++ @typeName(T) ++ "'"),
704 else => @compileError("unable to format type '" ++ @typeName(T) ++ "'"),
705705 }
706706}
707707
......@@ -747,13 +747,13 @@ pub fn formatIntValue(
747747 if (@typeInfo(@TypeOf(int_value)).Int.bits <= 8) {
748748 return formatAsciiChar(@as(u8, int_value), options, writer);
749749 } else {
750 @compileError("Cannot print integer that is larger than 8 bits as an ASCII character");
750 @compileError("cannot print integer that is larger than 8 bits as an ASCII character");
751751 }
752752 } else if (comptime std.mem.eql(u8, fmt, "u")) {
753753 if (@typeInfo(@TypeOf(int_value)).Int.bits <= 21) {
754754 return formatUnicodeCodepoint(@as(u21, int_value), options, writer);
755755 } else {
756 @compileError("Cannot print integer that is larger than 21 bits as an UTF-8 sequence");
756 @compileError("cannot print integer that is larger than 21 bits as an UTF-8 sequence");
757757 }
758758 } else if (comptime std.mem.eql(u8, fmt, "b")) {
759759 radix = 2;
......@@ -768,7 +768,7 @@ pub fn formatIntValue(
768768 radix = 8;
769769 case = .lower;
770770 } else {
771 @compileError("Unsupported format string '" ++ fmt ++ "' for type '" ++ @typeName(@TypeOf(value)) ++ "'");
771 @compileError("unsupported format string '" ++ fmt ++ "' for type '" ++ @typeName(@TypeOf(value)) ++ "'");
772772 }
773773
774774 return formatInt(int_value, radix, case, options, writer);
......@@ -797,7 +797,7 @@ fn formatFloatValue(
797797 error.NoSpaceLeft => unreachable,
798798 };
799799 } else {
800 @compileError("Unsupported format string '" ++ fmt ++ "' for type '" ++ @typeName(@TypeOf(value)) ++ "'");
800 @compileError("unsupported format string '" ++ fmt ++ "' for type '" ++ @typeName(@TypeOf(value)) ++ "'");
801801 }
802802
803803 return formatBuf(buf_stream.getWritten(), options, writer);
......@@ -959,7 +959,7 @@ pub fn fmtIntSizeBin(value: u64) std.fmt.Formatter(formatSizeBin) {
959959
960960fn checkTextFmt(comptime fmt: []const u8) void {
961961 if (fmt.len != 1)
962 @compileError("Unsupported format string '" ++ fmt ++ "' when formatting text");
962 @compileError("unsupported format string '" ++ fmt ++ "' when formatting text");
963963 switch (fmt[0]) {
964964 'x' => @compileError("specifier 'x' has been deprecated, wrap your argument in std.fmt.fmtSliceHexLower instead"),
965965 'X' => @compileError("specifier 'X' has been deprecated, wrap your argument in std.fmt.fmtSliceHexUpper instead"),
......@@ -2377,7 +2377,7 @@ test "custom" {
23772377 } else if (comptime std.mem.eql(u8, fmt, "d")) {
23782378 return std.fmt.format(writer, "{d:.3}x{d:.3}", .{ self.x, self.y });
23792379 } else {
2380 @compileError("Unknown format character: '" ++ fmt ++ "'");
2380 @compileError("unknown format character: '" ++ fmt ++ "'");
23812381 }
23822382 }
23832383 };
......@@ -2585,7 +2585,7 @@ test "formatType max_depth" {
25852585 if (fmt.len == 0) {
25862586 return std.fmt.format(writer, "({d:.3},{d:.3})", .{ self.x, self.y });
25872587 } else {
2588 @compileError("Unknown format string: '" ++ fmt ++ "'");
2588 @compileError("unknown format string: '" ++ fmt ++ "'");
25892589 }
25902590 }
25912591 };