From 542c3d7561df82486310f355ca84a88fa5af3f9f Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 20 May 2024 13:32:16 +0100 Subject: Improve "Expected a type" syntax error --- src/parser.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/parser.cpp') diff --git a/src/parser.cpp b/src/parser.cpp index e296e6935..5aa11b5d0 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -3499,8 +3499,14 @@ gb_internal Array parse_ident_list(AstFile *f, bool allow_poly_names) { gb_internal Ast *parse_type(AstFile *f) { Ast *type = parse_type_or_ident(f); if (type == nullptr) { - Token token = advance_token(f); - syntax_error(token, "Expected a type"); + Token prev_token = f->curr_token; + 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); } else if (type->kind == Ast_ParenExpr && unparen_expr(type) == nullptr) { -- cgit v1.2.3