Inferring the size of a slice with an inner inferred array using {} isn't detected as error #2783

This commit is contained in:
Christoffer Lerno
2026-01-20 23:58:45 +01:00
parent 34a86852c6
commit 1e11b6c442
3 changed files with 10 additions and 0 deletions

View File

@@ -26,6 +26,7 @@
- $typeof untyped list crashes when trying to create typeid from it. #2779
- Recursive constant definition not properly detected, leading to assert #2780
- Failed to reject void compile time variables, leading to crash. #2781
- Inferring the size of a slice with an inner inferred array using {} isn't detected as error #2783
### Fixes
- Regression with npot vector in struct triggering an assert #2219.

View File

@@ -881,6 +881,10 @@ bool sema_expr_analyse_initializer_list(SemaContext *context, Type *to, Expr *ex
{
if (is_zero_init)
{
if (type_len_is_inferred(flattened->array.base))
{
RETURN_SEMA_ERROR(expr, "Inferring the slice inner type from an empty initializer is not possible.");
}
expr_rewrite_const_empty_slice(expr, to);
return true;
}

View File

@@ -0,0 +1,5 @@
fn int main()
{
int [*][] y = { }; // #error: Inferring the slice inner type from an empty initializer is not possible
return 0;
}