// Phase 186: Simple Body-local Init Lowering Test (Pattern2) // // Tests body-local init expressions used ONLY in updates, NOT in conditions. // This is within Phase 186 scope (int/arithmetic init, condition-free usage). // // Expected behavior: // - loop(pos < 5) iterates 5 times with break condition on pos // - Each iteration: // - local offset = pos - 0 (body-local init: always equals pos) // - if pos >= 3 { break } (condition uses pos, NOT offset) // - sum = sum + offset (use body-local in update) // - pos = pos + 1 // - Expected sum: 0 + (0-0) + (1-0) + (2-0) = 0+0+1+2 = 3 static box Main { main() { local sum = 0 local pos = 0 loop (pos < 5) { local offset = pos - 0 // Body-local init (Phase 186: BinOp) if pos >= 3 { // Condition uses pos (loop var), NOT offset! break } sum = sum + offset // Update uses offset (body-local) pos = pos + 1 } print(sum) // Expected: 3 (0+0+1+2) return sum } }