mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
Inferring the size of a slice with an inner inferred array using {} isn't detected as error #2783
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
5
test/test_suite/slices/slice_infer_inner_empty_err.c3
Normal file
5
test/test_suite/slices/slice_infer_inner_empty_err.c3
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user