authorgravatar for r00ster91@proton.meWooster <r00ster91@proton.me> 2025-05-08 14:47:22+09:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-05-15 16:39:15+01:00
log56fad6a19554b83f54c3cdf12b93510546346068
tree7a86d5594b76eb21dc8221c15b1ed5d99af5204c
parent08d534e8d8482b0c59b5311111a6ae70593d783d

make error messages prettier

Error messages never contain periods or grave accents. Get rid of the periods and use apostrophes instead in probably the only two error messages that had them.

4 files changed, 7 insertions(+), 7 deletions(-)

lib/std/zig/Ast.zig+2-2
......@@ -323,7 +323,7 @@ pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void {
323323 .asterisk_after_ptr_deref => {
324324 // Note that the token will point at the `.*` but ideally the source
325325 // location would point to the `*` after the `.*`.
326 return stream.writeAll("'.*' cannot be followed by '*'. Are you missing a space?");
326 return stream.writeAll("'.*' cannot be followed by '*'; are you missing a space?");
327327 },
328328 .chained_comparison_operators => {
329329 return stream.writeAll("comparison operators cannot be chained");
......@@ -526,7 +526,7 @@ pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void {
526526 return stream.writeAll("expected field initializer");
527527 },
528528 .mismatched_binary_op_whitespace => {
529 return stream.print("binary operator `{s}` has whitespace on one side, but not the other.", .{tree.tokenTag(parse_error.token).lexeme().?});
529 return stream.print("binary operator '{s}' has whitespace on one side, but not the other", .{tree.tokenTag(parse_error.token).lexeme().?});
530530 },
531531 .invalid_ampersand_ampersand => {
532532 return stream.writeAll("ambiguous use of '&&'; use 'and' for logical AND, or change whitespace to ' & &' for bitwise AND");
lib/std/zig/AstGen.zig+2-2
......@@ -4299,12 +4299,12 @@ fn fnDeclInner(
42994299 &[_]u32{
43004300 try astgen.errNoteNode(
43014301 type_expr,
4302 "if this is a name, annotate its type '{s}: T'",
4302 "if this is a name, annotate its type: '{s}: T'",
43034303 .{identifier_str},
43044304 ),
43054305 try astgen.errNoteNode(
43064306 type_expr,
4307 "if this is a type, give it a name '<name>: {s}'",
4307 "if this is a type, give it a name: 'name: {s}'",
43084308 .{identifier_str},
43094309 ),
43104310 },
test/cases/compile_errors/Issue_6823_dont_allow_._to_be_followed_by_.zig+1-1
......@@ -7,4 +7,4 @@ fn foo() void {
77// backend=stage2
88// target=native
99//
10// :2:28: error: '.*' cannot be followed by '*'. Are you missing a space?
10// :2:28: error: '.*' cannot be followed by '*'; are you missing a space?
test/cases/compile_errors/missing_parameter_name.zig+2-2
......@@ -15,5 +15,5 @@ fn f1(x) u64 {
1515// :1:7: error: missing parameter name
1616// :4:7: error: missing parameter name
1717// :7:7: error: missing parameter name or type
18// :7:7: note: if this is a name, annotate its type 'x: T'
19// :7:7: note: if this is a type, give it a name '<name>: x'
18// :7:7: note: if this is a name, annotate its type: 'x: T'
19// :7:7: note: if this is a type, give it a name: 'name: x'