Skip to content

Commit

Permalink
If missing type is newline, print "newline", not \n
Browse files Browse the repository at this point in the history
Turns:

W:/Odin/bug/bug.odin(3:27) Syntax Error: Expected a type, got '
'
        Storage :: distinct map[]

Into:

W:/Odin/bug/bug.odin(3:27) Syntax Error: Expected a type, got newline
        Storage :: distinct map[]
  • Loading branch information
Kelimion committed Aug 17, 2024
1 parent ebbb70f commit 9553bc3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3560,7 +3560,12 @@ gb_internal Ast *parse_type(AstFile *f) {
} else {
token = advance_token(f);
}
syntax_error(token, "Expected a type, got '%.*s'", LIT(prev_token.string));
String prev_token_str = prev_token.string;
if (prev_token_str == str_lit("\n")) {
syntax_error(token, "Expected a type, got newline");
} else {
syntax_error(token, "Expected a type, got '%.*s'", LIT(prev_token_str));
}
return ast_bad_expr(f, token, f->curr_token);
} else if (type->kind == Ast_ParenExpr &&
unparen_expr(type) == nullptr) {
Expand Down

0 comments on commit 9553bc3

Please sign in to comment.