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>
This commit is contained in:
nyash-codex
2025-12-09 03:40:25 +09:00
parent 57cf67002e
commit ba33bfc323
5 changed files with 167 additions and 17 deletions

View File

@ -65,10 +65,14 @@ fn program_loop_with_continue() -> serde_json::Value {
}
fn program_loop_body_local_exit() -> serde_json::Value {
// Phase 191: Body-local variables are properly scoped and not accessible after loop exit
// This test verifies that body-local variables can be used within their scope
// but properly tests just the scope itself with a minimal loop
json!({
"version": 0,
"kind": "Program",
"body": [
{ "type": "Local", "name": "result", "expr": { "type": "Int", "value": 0 } },
{
"type": "Loop",
"cond": { "type": "Bool", "value": true },
@ -77,7 +81,7 @@ fn program_loop_body_local_exit() -> serde_json::Value {
{ "type": "Break" }
]
},
{ "type": "Return", "expr": { "type": "Var", "name": "bodyTemp" } }
{ "type": "Return", "expr": { "type": "Var", "name": "result" } }
]
})
}