From aa658d37c791ff4ba574441446fb891694122235 Mon Sep 17 00:00:00 2001 From: Priyanshu Dangare Date: Tue, 27 Jan 2026 23:17:11 +0530 Subject: [PATCH] Fix until loop function evaluation bug Function calls in until loop conditions are now evaluated every iteration instead of only once before the loop starts. This is achieved by collecting the callsites from the condition separately and appending them to the end of the loop body, ensuring they are re-evaluated each iteration. --- src/visitor/pass1.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/visitor/pass1.rs b/src/visitor/pass1.rs index 760901e..f0b7b13 100644 --- a/src/visitor/pass1.rs +++ b/src/visitor/pass1.rs @@ -93,8 +93,10 @@ fn visit_stmt(stmt: &mut Stmt, s: &mut S) -> Vec { visit_stmts(else_body, s); } Stmt::Until { cond, body } => { - visit_expr(cond, &mut before, s); + let mut cond_callsites = vec![]; + visit_expr(cond, &mut cond_callsites, s); visit_stmts(body, s); + body.extend(cond_callsites); } Stmt::SetVar { name: _,