Improved error message on invalid subscript index type #1535.

This commit is contained in:
Christoffer Lerno
2024-10-10 14:59:16 +02:00
parent a91ddd40dd
commit bf30e52993
2 changed files with 3 additions and 8 deletions

View File

@@ -629,14 +629,8 @@ bool cast_to_index(SemaContext *context, Expr *index, Type *subscripted_type)
type = type->decl->enums.type_info->type;
goto RETRY;
default:
if (!subscripted_type)
{
RETURN_SEMA_ERROR(index, "Cannot implicitly convert %s to an index.",
type_quoted_error_string(index->type));
}
RETURN_SEMA_ERROR(index, "Cannot implicitly convert %s to index %s.",
type_quoted_error_string(index->type),
type_quoted_error_string(subscripted_type));
RETURN_SEMA_ERROR(index, "An integer value was expected here, but it is a value of type %s, which can't be implicitly converted into an integer index.",
type_quoted_error_string(index->type));
}
}