nyash-codex
525e59bc8d
feat(loop-phi): Add body-local variable PHI generation for Rust AST loops
Phase 25.1c/k: Fix ValueId undefined errors in loops with body-local variables
**Problem:**
- FuncScannerBox.scan_all_boxes/1 and BreakFinderBox._find_loops/2 had ValueId
undefined errors for variables declared inside loop bodies
- LoopFormBuilder only generated PHIs for preheader variables, missing body-locals
- Example: `local ch = s.substring(i, i+1)` inside loop → undefined on next iteration
**Solution:**
1. **Rust AST path** (src/mir/loop_builder.rs):
- Detect body-local variables by comparing body_end_vars vs current_vars
- Generate empty PHI nodes at loop header for body-local variables
- Seal PHIs with latch + continue snapshot inputs after seal_phis()
- Added HAKO_LOOP_PHI_TRACE=1 logging for debugging
2. **JSON v0 path** (already fixed in previous session):
- src/runner/json_v0_bridge/lowering/loop_.rs handles body-locals
- Uses same strategy but for JSON v0 bridge lowering
**Results:**
- ✅ FuncScannerBox.scan_all_boxes: 41 body-local PHIs generated
- ✅ Main.main (demo harness): 23 body-local PHIs generated
- ⚠️ Still some ValueId undefined errors remaining (exit PHI issue)
**Files changed:**
- src/mir/loop_builder.rs: body-local PHI generation logic
- lang/src/compiler/entry/func_scanner.hako: debug logging
- /tmp/stageb_funcscan_demo.hako: test harness
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-19 23:12:01 +09:00
..
2025-11-06 15:41:52 +09:00
2025-08-21 00:41:26 +09:00
2025-08-21 00:41:26 +09:00
2025-11-06 15:41:52 +09:00
2025-11-06 15:41:52 +09:00
2025-11-06 15:41:52 +09:00
2025-11-06 15:41:52 +09:00
2025-11-06 15:41:52 +09:00
2025-11-06 15:41:52 +09:00
2025-11-06 15:41:52 +09:00
2025-11-06 15:41:52 +09:00
2025-11-06 15:41:52 +09:00
2025-09-03 01:37:38 +09:00
2025-09-04 11:34:15 +09:00
2025-11-06 15:41:52 +09:00
2025-11-06 15:41:52 +09:00
2025-11-06 15:41:52 +09:00
2025-11-06 15:41:52 +09:00
2025-11-06 15:41:52 +09:00
2025-08-21 00:41:26 +09:00
2025-11-06 15:41:52 +09:00
2025-11-06 15:41:52 +09:00
2025-11-06 15:41:52 +09:00
2025-09-02 09:26:09 +09:00
2025-11-06 15:41:52 +09:00
2025-11-06 15:41:52 +09:00
2025-11-06 15:41:52 +09:00
2025-09-08 03:30:35 +09:00
2025-09-08 03:30:35 +09:00
2025-11-06 15:41:52 +09:00
2025-11-14 15:18:14 +09:00
2025-11-14 15:18:14 +09:00
2025-11-13 16:40:58 +09:00
2025-11-13 16:40:58 +09:00
2025-11-14 20:19:00 +09:00
2025-11-06 15:41:52 +09:00
2025-11-15 05:42:32 +09:00
2025-11-19 08:56:44 +09:00
2025-11-15 22:32:13 +09:00
2025-11-19 23:12:01 +09:00
2025-11-19 23:12:01 +09:00
2025-11-18 09:26:39 +09:00
2025-11-19 08:56:44 +09:00
2025-11-18 18:56:35 +09:00
2025-11-19 00:02:41 +09:00
2025-11-19 00:02:41 +09:00
2025-11-19 00:02:41 +09:00
2025-11-19 23:12:01 +09:00
2025-11-19 03:28:58 +09:00
2025-11-19 10:08:04 +09:00
2025-11-19 23:12:01 +09:00
2025-11-19 23:12:01 +09:00
2025-11-15 05:42:32 +09:00
2025-11-15 22:32:13 +09:00
2025-09-11 00:21:11 +09:00
2025-11-04 16:33:04 +09:00
2025-11-06 15:41:52 +09:00