$for ct-state not properly popped.

This commit is contained in:
Christoffer Lerno
2025-07-03 22:20:14 +02:00
parent b3e7f074e9
commit 9b3b4ae8be
3 changed files with 18 additions and 0 deletions

View File

@@ -19,6 +19,7 @@
- Check up the hierarchy when considering if an interface cast is valid #2267. - Check up the hierarchy when considering if an interface cast is valid #2267.
- Fix issue with labelled break inside of a $switch. - Fix issue with labelled break inside of a $switch.
- Non-const macros may not return untyped lists. - Non-const macros may not return untyped lists.
- `$for` ct-state not properly popped.
### Stdlib changes ### Stdlib changes

View File

@@ -3048,6 +3048,7 @@ static inline bool sema_analyse_ct_for_stmt(SemaContext *context, Ast *statement
// Analysis is done turn the generated statements into a compound statement for lowering. // Analysis is done turn the generated statements into a compound statement for lowering.
statement->ast_kind = AST_CT_COMPOUND_STMT; statement->ast_kind = AST_CT_COMPOUND_STMT;
statement->ct_compound_stmt = start; statement->ct_compound_stmt = start;
sema_context_pop_ct_stack(context, for_context);
return true; return true;
FAILED: FAILED:
sema_context_pop_ct_stack(context, for_context); sema_context_pop_ct_stack(context, for_context);

View File

@@ -0,0 +1,16 @@
fn int main()
{
$for var $i = 1; $i < 8; ++$i :
$endfor
$for var $i = 0; $i < 8; ++$i :
$endfor
const int[*] ABC = { 1, 2, 3 };
$foreach $i, $val : ABC:
$endforeach
$foreach $i, $val : ABC:
$endforeach
return 0;
}