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

@@ -11,6 +11,7 @@
- Deprecate `@adhoc`, allow non-nested ad hoc generic types.
- Constant bytes <=> char[] conversion should work #1514.
- Infer now works across ternary.
- Improved error message on invalid subscript index type #1535.
### Fixes
- `Unsupported int[*] $x = { 1, 2, 3, 4 }` #1489.

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));
}
}