From f88c0dd645858bfc1b19111d9efc0341f2acc10f Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Thu, 14 Nov 2024 00:19:17 +0100 Subject: [PATCH] Tweak the error message on unexpectedly getting a non-type identifier. #1622 --- src/compiler/parse_global.c | 9 ++++++++- test/test_suite/types/various.c3 | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/compiler/parse_global.c b/src/compiler/parse_global.c index 1ce3fa4fa..8ceb8ca24 100644 --- a/src/compiler/parse_global.c +++ b/src/compiler/parse_global.c @@ -477,7 +477,14 @@ static inline TypeInfo *parse_base_type(ParseContext *c) default: if (c->tok == TOKEN_IDENT) { - PRINT_ERROR_HERE("A type name was expected, but this looks a variable or function name (as it doesn't start with an uppercase letter)."); + if (peek(c) == TOKEN_IDENT) + { + PRINT_ERROR_HERE("The name of a type must start with uppercase and contain at least one lowercase letter."); + } + else + { + PRINT_ERROR_HERE("A type name was expected, but this looks a variable or function name (as it doesn't start with an uppercase letter)."); + } } else { diff --git a/test/test_suite/types/various.c3 b/test/test_suite/types/various.c3 index 3a93475fc..00026afe8 100644 --- a/test/test_suite/types/various.c3 +++ b/test/test_suite/types/various.c3 @@ -1,4 +1,4 @@ -func1 a = 1; // #error: A type name was expected +func1 a = 1; // #error: The name of a type fn void func1() {}