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 {...@@ -323,7 +323,7 @@ pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void {
323 .asterisk_after_ptr_deref => {323 .asterisk_after_ptr_deref => {
324 // Note that the token will point at the `.*` but ideally the source324 // Note that the token will point at the `.*` but ideally the source
325 // location would point to the `*` after the `.*`.325 // 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?");
327 },327 },
328 .chained_comparison_operators => {328 .chained_comparison_operators => {
329 return stream.writeAll("comparison operators cannot be chained");329 return stream.writeAll("comparison operators cannot be chained");
...@@ -526,7 +526,7 @@ pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void {...@@ -526,7 +526,7 @@ pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void {
526 return stream.writeAll("expected field initializer");526 return stream.writeAll("expected field initializer");
527 },527 },
528 .mismatched_binary_op_whitespace => {528 .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().?});
530 },530 },
531 .invalid_ampersand_ampersand => {531 .invalid_ampersand_ampersand => {
532 return stream.writeAll("ambiguous use of '&&'; use 'and' for logical AND, or change whitespace to ' & &' for bitwise AND");532 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(...@@ -4299,12 +4299,12 @@ fn fnDeclInner(
4299 &[_]u32{4299 &[_]u32{
4300 try astgen.errNoteNode(4300 try astgen.errNoteNode(
4301 type_expr,4301 type_expr,
4302 "if this is a name, annotate its type '{s}: T'",4302 "if this is a name, annotate its type: '{s}: T'",
4303 .{identifier_str},4303 .{identifier_str},
4304 ),4304 ),
4305 try astgen.errNoteNode(4305 try astgen.errNoteNode(
4306 type_expr,4306 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}'",
4308 .{identifier_str},4308 .{identifier_str},
4309 ),4309 ),
4310 },4310 },
test/cases/compile_errors/Issue_6823_dont_allow_._to_be_followed_by_.zig+1-1
...@@ -7,4 +7,4 @@ fn foo() void {...@@ -7,4 +7,4 @@ fn foo() void {
7// backend=stage27// backend=stage2
8// target=native8// target=native
9//9//
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 {...@@ -15,5 +15,5 @@ fn f1(x) u64 {
15// :1:7: error: missing parameter name15// :1:7: error: missing parameter name
16// :4:7: error: missing parameter name16// :4:7: error: missing parameter name
17// :7:7: error: missing parameter name or type17// :7:7: error: missing parameter name or type
18// :7:7: note: if this is a name, annotate its type 'x: T'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'19// :7:7: note: if this is a type, give it a name: 'name: x'