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>
Nyash Reference Documentation 📖
このディレクトリには、Nyashプログラミング言語の正式な技術仕様が含まれています。
📚 サブディレクトリ
language/
- 言語仕様(構文、型システム、Box仕様、デリゲーション)
- 正式な言語リファレンス
architecture/
- システムアーキテクチャ(MIR、VM、インタープリター)
- 実行バックエンド仕様
- 内部設計ドキュメント
api/
- ビルトインBoxのAPI仕様
- 標準ライブラリリファレンス
- 各Boxのメソッド詳細
plugin-system/
- プラグインシステム仕様
- BID-FFI(Box Interface Definition - Foreign Function Interface)
- プラグイン開発ガイド
📝 注意事項
このディレクトリのドキュメントは安定版です。開発中の仕様はdevelopment/を参照してください。