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.
This commit is contained in:
wooster0 2025-05-08 14:47:22 +09:00 committed by Matthew Lugg
parent 08d534e8d8
commit 56fad6a195
4 changed files with 7 additions and 7 deletions

View file

@ -323,7 +323,7 @@ pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void {
.asterisk_after_ptr_deref => { .asterisk_after_ptr_deref => {
// Note that the token will point at the `.*` but ideally the source // Note that the token will point at the `.*` but ideally the source
// location would point to the `*` after the `.*`. // location would point to the `*` after the `.*`.
return stream.writeAll("'.*' cannot be followed by '*'. Are you missing a space?"); return stream.writeAll("'.*' cannot be followed by '*'; are you missing a space?");
}, },
.chained_comparison_operators => { .chained_comparison_operators => {
return stream.writeAll("comparison operators cannot be chained"); return stream.writeAll("comparison operators cannot be chained");
@ -526,7 +526,7 @@ pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void {
return stream.writeAll("expected field initializer"); return stream.writeAll("expected field initializer");
}, },
.mismatched_binary_op_whitespace => { .mismatched_binary_op_whitespace => {
return stream.print("binary operator `{s}` has whitespace on one side, but not the other.", .{tree.tokenTag(parse_error.token).lexeme().?}); return stream.print("binary operator '{s}' has whitespace on one side, but not the other", .{tree.tokenTag(parse_error.token).lexeme().?});
}, },
.invalid_ampersand_ampersand => { .invalid_ampersand_ampersand => {
return stream.writeAll("ambiguous use of '&&'; use 'and' for logical AND, or change whitespace to ' & &' for bitwise AND"); return stream.writeAll("ambiguous use of '&&'; use 'and' for logical AND, or change whitespace to ' & &' for bitwise AND");

View file

@ -4299,12 +4299,12 @@ fn fnDeclInner(
&[_]u32{ &[_]u32{
try astgen.errNoteNode( try astgen.errNoteNode(
type_expr, type_expr,
"if this is a name, annotate its type '{s}: T'", "if this is a name, annotate its type: '{s}: T'",
.{identifier_str}, .{identifier_str},
), ),
try astgen.errNoteNode( try astgen.errNoteNode(
type_expr, type_expr,
"if this is a type, give it a name '<name>: {s}'", "if this is a type, give it a name: 'name: {s}'",
.{identifier_str}, .{identifier_str},
), ),
}, },

View file

@ -7,4 +7,4 @@ fn foo() void {
// backend=stage2 // backend=stage2
// target=native // target=native
// //
// :2:28: error: '.*' cannot be followed by '*'. Are you missing a space? // :2:28: error: '.*' cannot be followed by '*'; are you missing a space?

View file

@ -15,5 +15,5 @@ fn f1(x) u64 {
// :1:7: error: missing parameter name // :1:7: error: missing parameter name
// :4:7: error: missing parameter name // :4:7: error: missing parameter name
// :7:7: error: missing parameter name or type // :7:7: error: missing parameter name or type
// :7:7: note: if this is a name, annotate its type 'x: T' // :7:7: note: if this is a name, annotate its type: 'x: T'
// :7:7: note: if this is a type, give it a name '<name>: x' // :7:7: note: if this is a type, give it a name: 'name: x'