Improve error message when providing alias with a typeid expression where a type was expected. #2944

This commit is contained in:
Christoffer Lerno
2026-02-17 13:02:34 +01:00
parent 8cb23cff29
commit 3ac701be0e
3 changed files with 16 additions and 2 deletions

View File

@@ -2421,8 +2421,12 @@ static inline Decl *parse_alias_type(ParseContext *c, AstId contracts)
print_error_at(decl->span, "An identifier may not be aliased with type name, it must start with a lower case letter.");
}
return poisoned_decl;
case EXPR_TERNARY:
case EXPR_CALL:
PRINT_ERROR_AT(expr, "Expected a type to alias here, if you are providing a constant typeid-expression, e.g. 'FOO > 32 ??? long : int', then you need to wrap the expression in '$typefrom'");
return poisoned_decl;
default:
PRINT_ERROR_HERE("Expected a type to alias here.");
PRINT_ERROR_AT(expr, "Expected the name of the type to alias here.");
return poisoned_decl;
}
ASSERT(!tok_is(c, TOKEN_LBRACE));