Skip to content

Commit 56fad6a

Browse files
wooster0mlugg
authored andcommitted
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.
1 parent 08d534e commit 56fad6a

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

lib/std/zig/Ast.zig

+2-2
Original file line numberDiff line numberDiff line change
@@ -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
Original file line numberDiff line numberDiff line change
@@ -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
Original file line numberDiff line numberDiff line change
@@ -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
Original file line numberDiff line numberDiff line change
@@ -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'

0 commit comments

Comments
 (0)