Fix issue with labelled break inside of a $switch.

This commit is contained in:
Christoffer Lerno
2025-07-03 13:11:12 +02:00
parent 04626b72cd
commit 8b47317ec7
3 changed files with 21 additions and 2 deletions

View File

@@ -17,6 +17,7 @@
- Switch case with const non-int / enum would be treated as ints and crash. #2263
- Missing bounds check on upper bound with const ranges `foo[1:3]`.
- Check up the hierarchy when considering if an interface cast is valid #2267.
- Fix issue with labelled break inside of a $switch.
### Stdlib changes

View File

@@ -2224,9 +2224,10 @@ static inline bool sema_analyse_then_overwrite(SemaContext *context, Ast *statem
return true;
}
Ast *last = NULL;
statement->ast_kind = AST_NOP_STMT;
AstId next = statement->next;
*statement = *astptr(replacement);
AstId current = astid(statement);
statement->next = replacement;
AstId current = replacement;
ASSERT(current);
while (current)
{

View File

@@ -0,0 +1,17 @@
enum Test
{
FOO,
}
fn int main()
{
int v;
$switch (Test.FOO):
$case FOO:
if START: (v < 5)
{
if (v > 3) break START;
}
$endswitch
return 0;
}