// Phase 200-D: Simple digits capture test (Pattern 2 with break) // This test verifies that captured variables (digits) work in JoinIR Pattern 2. // // Key constraints: // - Loop condition uses only LoopParam (i) and OuterLocal (n) // - Break condition uses outer-scoped variable (maxIter), NOT body-local // - digits is captured and used in loop body static box Main { main() { local digits = "0123456789" // Captured var local s = "12" // Input string local i = 0 local v = 0 local n = s.length() // n = 2 local maxIter = 10 // Safety limit (outer-scoped, not body-local) // Pattern 2: loop with break (break condition uses outer var) loop(i < n) { // Break if too many iterations (uses outer var, not body-local) if i > maxIter { break } local ch = s.substring(i, i + 1) local d = digits.indexOf(ch) // digits: captured v = v * 10 + d i = i + 1 } print(v) // Expected: 12 } }