Files
hakorune/docs/development/roadmap
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
..

🗺️ Nyash 予定(ロードマップ・タスク)

📋 現在進行中

🎯 最重要タスク

  • 現在のタスク: ../../CURRENT_TASK.md
  • Phase 8.3: Box操作WASM実装Copilot担当
  • Phase 8.4: ネイティブコンパイル実装計画AI大会議策定済み

🚀 ネイティブコンパイル計画 (2025-08-14策定)

📊 AI大会議成果

実装フェーズ

  • Phase A (2-3週間): AOT WASM → 500倍高速化目標
  • Phase B (2-3ヶ月): Cranelift Direct → 600倍高速化目標
  • Phase C (6ヶ月+): LLVM Ultimate → 1000倍高速化目標

🤖 Copilot協調管理

📋 Copilot作業管理

🎯 フェーズ別課題

📊 実装状況追跡

完了済み (Phase 8.2)

  • WASM: 0.17ms (280倍高速化)
  • VM: 16.97ms (2.9倍高速化)
  • ベンチマークシステム完成
  • 3バックエンド統合CLI

🚧 進行中 (Phase 8.3)

  • Box操作WASM対応Copilot実装中
  • RefNew/RefGet/RefSet命令
  • メモリレイアウト最適化

🔜 次期予定 (Phase 8.4+)

📚 関連ドキュメント

📖 技術資料

🔄 進捗管理

  • 定期更新: 毎週金曜日に進捗反映
  • AI会議: 重要決定事項は3AI大会議で検討
  • ベンチマーク: 性能回帰チェック自動実行

最終更新: 2025-08-14 - AI大会議によるネイティブコンパイル戦略確定