mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 16:18:52 +00:00
Improve "Expected a type" syntax error
This commit is contained in:
+8
-2
@@ -3499,8 +3499,14 @@ gb_internal Array<Ast *> parse_ident_list(AstFile *f, bool allow_poly_names) {
|
|||||||
gb_internal Ast *parse_type(AstFile *f) {
|
gb_internal Ast *parse_type(AstFile *f) {
|
||||||
Ast *type = parse_type_or_ident(f);
|
Ast *type = parse_type_or_ident(f);
|
||||||
if (type == nullptr) {
|
if (type == nullptr) {
|
||||||
Token token = advance_token(f);
|
Token prev_token = f->curr_token;
|
||||||
syntax_error(token, "Expected a type");
|
Token token = {};
|
||||||
|
if (f->curr_token.kind == Token_OpenBrace) {
|
||||||
|
token = f->curr_token;
|
||||||
|
} else {
|
||||||
|
token = advance_token(f);
|
||||||
|
}
|
||||||
|
syntax_error(token, "Expected a type, got '%.*s'", LIT(prev_token.string));
|
||||||
return ast_bad_expr(f, token, f->curr_token);
|
return ast_bad_expr(f, token, f->curr_token);
|
||||||
} else if (type->kind == Ast_ParenExpr &&
|
} else if (type->kind == Ast_ParenExpr &&
|
||||||
unparen_expr(type) == nullptr) {
|
unparen_expr(type) == nullptr) {
|
||||||
|
|||||||
Reference in New Issue
Block a user