Files
hakorune/apps/tests/phase191_body_local_atoi.hako
nyash-codex ba33bfc323 feat(joinir): Phase 191 body-local init integration into Pattern2
- Integrated LoopBodyLocalInitLowerer into Pattern2 lowering
- Fixed ValueId double-allocation issue (delegate to InitLowerer)
- Added body_ast parameter to lower_loop_with_break_minimal()
- Fixed json_program_loop.rs test for body-local scope
- New test: phase191_body_local_atoi.hako (expected: 123)

Supported init expressions:
- Integer literals, variable references, binary operations

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-09 03:40:25 +09:00

34 lines
978 B
Plaintext

// Phase 191: Body-local variable integration test
// Tests: local digit = i + 1 (body-local) in number accumulation pattern
//
// This test verifies that LoopBodyLocalInitLowerer correctly lowers
// body-local variable initialization expressions to JoinIR, and that
// UpdateEnv resolves them during carrier update emission.
//
// Expected calculation:
// i=0: digit = 0+1 = 1, result = 0*10 + 1 = 1
// i=1: digit = 1+1 = 2, result = 1*10 + 2 = 12
// i=2: digit = 2+1 = 3, result = 12*10 + 3 = 123
// i=3: break (condition i >= 3)
// Expected result: 123
static box Main {
main() {
local result
result = 0
local i
i = 0
loop(i < 10) {
if i >= 3 {
break
}
// Phase 191: Body-local variable with initialization expression
local digit = i + 1
result = result * 10 + digit
i = i + 1
}
print(result)
return 0
}
}