Compiler didn't check foreach over flexible array member, and folding a flexible array member was allowed #2164.

This commit is contained in:
Christoffer Lerno
2025-05-28 22:21:06 +02:00
parent 349d9ef3cf
commit 00f1206f3c
6 changed files with 27 additions and 2 deletions

View File

@@ -10,7 +10,7 @@ struct Widget
List {any} children;
}
fn void Widget{Label}.draw(Widget* self) // #error: This identifier is recursively using gui::widget
fn void Widget{Label}.draw(Widget* self) // #error: The same method is generated by multiple instances
{
io::printfn("Hello Label");
}

View File

@@ -0,0 +1,15 @@
struct Abc
{
int a;
int[*] b;
}
fn void test()
{
Abc y = {};
foreach (x : y.b) {} // #error: It is not possible to enumerate over a flexible
}
fn int main()
{
foreach (x : (Abc){}.b) {} // #error: it's a flexible array member
return 0;
}