Root Cause: - Else blocks were not propagating variable assignments to outer scope - Bug 1 (if_form.rs): PHI materialization happened before variable_map reset, causing PHI nodes to be lost - Bug 2 (phi.rs): Variable merge didn't check if else branch modified variables Changes: - src/mir/builder/if_form.rs:93-127 - Reordered: reset variable_map BEFORE materializing PHI nodes - Now matches then-branch pattern (reset → materialize → execute) - Applied to both "else" and "no else" branches for consistency - src/mir/builder/phi.rs:137-154 - Added else_modified_var check to detect variable modifications - Use modified value from else_var_map_end_opt when available - Fall back to pre-if value only when truly not modified Test Results: ✅ Simple block: { x=42 } → 42 ✅ If block: if 1 { x=42 } → 42 ✅ Else block: if 0 { x=99 } else { x=42 } → 42 (FIXED!) ✅ Stage-B body extraction: "return 42" correctly extracted (was null) Impact: - Else block variable assignments now work correctly - Stage-B compiler body extraction restored - Selfhost builder path can now function - Foundation for Phase 21.x progress 🤖 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/を参照してください。