fix(joinir): Phase 196 Select double-remap bug in instruction_rewriter

Root cause: PHI inputs were being remapped twice in instruction_rewriter.rs
- Line 304: remap_instruction() already remapped JoinIR → Host ValueIds
- Line 328: remap_value() attempted to remap again → undefined ValueIds

Fix: Only remap block IDs, use already-remapped ValueIds as-is

Test results:
- phase195_sum_count.hako → 93  (multi-carrier P3)
- loop_if_phi.hako → sum=9  (single-carrier P3)
- loop_min_while.hako → 0,1,2  (Pattern 1)
- joinir_min_loop.hako → RC:0  (Pattern 2)
- No [joinir/freeze], no regressions

🤖 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 14:45:04 +09:00
parent fa8727c2f8
commit 996925ebaf
11 changed files with 1207 additions and 90 deletions

View File

@ -523,14 +523,16 @@ JoinIR は Rust 側だけでなく、将来的に .hako selfhost コンパイラ
- Deferred loops: _parse_array, _parse_object (multiple MethodCalls)
- 詳細: phase194-loop-inventory.md, phase194-jsonparser-deployment.md
5. **Pattern 3 拡張(複数キャリア対応)** → Phase 195 Lowerer 完了、Phase 196 待ち
5. **Pattern 3 拡張(複数キャリア対応)** → Phase 195 + 196 完了 ✅
- 目的: P3If-Else PHIで 2-3 個の Carrier を同時処理
- **Lowerer 側完了**: multi-carrier PHI 生成sum + count
- **ExitLine**: 変更不要(既存インフラ活用)
- **Blocker**: JoinIR→MIR の Select 変換バグPhase 196 で修正予定)
- パターン側は終わり、問題は bridge 側
- **Phase 195**: Lowerer 側完了multi-carrier PHI 生成: sum + count
- **Phase 196**: Select 二重 remap バグ修正
- 根本原因: `instruction_rewriter.rs` で PHI inputs を二重 remap
- 修正: block ID のみ remap、ValueId は既に remap 済み
- **E2E 結果**: phase195_sum_count.hako → 93 ✅
- 詳細: phase196-select-bug-analysis.md
6. **JsonParser 残り複雑ループへの適用Phase 195+, 200+**
6. **JsonParser 残り複雑ループへの適用Phase 197+, 200+**
- Phase 200+: ConditionEnv 拡張 (function-scoped variables) → _parse_number, _atoi
- Phase 195+: Pattern 3 拡張 (multi-flag carriers) → _parse_string, _unescape_string
- Phase 195+: MethodCall 拡張 (multiple calls in body) → _parse_array, _parse_object