Improve the error message when typing fn void Foo().

This commit is contained in:
Christoffer Lerno
2024-07-28 21:08:47 +02:00
parent 35cb36fcea
commit 08c7b35731

View File

@@ -2029,6 +2029,10 @@ static inline bool parse_func_macro_header(ParseContext *c, Decl *decl)
else if (method_type)
{
// 5d. A method type but no dot is also wrong.
if (method_type->kind == TYPE_INFO_IDENTIFIER && tok_is(c, TOKEN_LPAREN))
{
RETURN_PRINT_ERROR_AT(false, method_type, "A function name must start with lower case, as names starting with upper case are reserved for types.");
}
RETURN_PRINT_ERROR_AT(false, method_type, "There is unexpectedly a type after the return type, did you forget a '.'?");
}
RESULT: