feat(joinir): Phase 63-4 infer_type_from_phi degradation design
Phase 63-4: infer_type_from_phi を『JoinIR 型ヒント優先+従来ロジックフォールバック』に縮退する仕様を設計(実装は Phase 63-5+)
## Changes
### Documentation Updates
- **README.md**: Added complete Phase 63-4 design (63-4.1 through 63-4.5)
- 63-4.1: Current state analysis (definition location, callsites, role, JoinIR preparation)
- 63-4.2: Degradation spec (type_hint priority + fallback pattern)
- 63-4.3: Representative cases and A/B testing strategy (P1/P2/P3)
- 63-4.4: Deletion conditions (5 conditions, current: 2/5 = 40%)
- 63-4.5: Phase 63-5 handoff (infer_type_from_phi_with_hint() implementation tasks)
- **PHI_BOX_INVENTORY.md**: Updated if_phi.rs entry with Phase 63-4 deletion plan
- Added: "Phase 63-4完了: infer_type_from_phi の JoinIR type_hint 優先への縮退案を設計(実装は Phase 63-5+)"
- **CURRENT_TASK.md**: Added Phase 63-4 section with summary of design work
## Design Highlights
### Degradation Pattern
```rust
pub fn infer_type_from_phi_with_hint(
function: &MirFunction,
ret_val: ValueId,
types: &BTreeMap<ValueId, MirType>,
type_hint: Option<MirType>,
) -> Option<MirType> {
if let Some(hint) = type_hint {
return Some(hint); // Route B: JoinIR priority (SSOT)
}
infer_type_from_phi(function, ret_val, types) // Route A: Fallback
}
```
### Representative Cases
- **P1**: IfSelectTest.simple/local (Phase 63-5 target)
- **P2**: read_quoted_from (Phase 63-6+ target)
- **P3**: MethodCall/Box constructors (Phase 64+ expansion)
### Deletion Conditions (2/5 achieved)
1. ✅ JoinIR has type_hint field (Phase 63-3)
2. ✅ Type hints populated for representative cases (Phase 63-2)
3. ⏳ Degraded to type_hint priority (Phase 63-5)
4. ⏳ P1 cases determined by type_hint only (Phase 63-5)
5. ⏳ All functions use type hints (Phase 64+)
## Files Changed
- docs/private/roadmap2/phases/phase-63-joinir-type-info/README.md
- docs/private/roadmap2/phases/phase-30-final-joinir-world/PHI_BOX_INVENTORY.md
- CURRENT_TASK.md
## Next Steps
Phase 63-5: Implement degradation for P1 cases (IfSelectTest.simple/local)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -42,6 +42,7 @@ pub fn lower(
|
||||
cond: cond_id,
|
||||
then_val,
|
||||
else_val,
|
||||
type_hint: None, // Phase 63-3
|
||||
});
|
||||
|
||||
ctx.register_param(var_name.to_string(), result_id);
|
||||
|
||||
@ -40,6 +40,7 @@ pub fn lower(
|
||||
cond: cond_id,
|
||||
then_val,
|
||||
else_val,
|
||||
type_hint: None, // Phase 63-3
|
||||
});
|
||||
|
||||
ctx.register_param(var_name.to_string(), result_id);
|
||||
|
||||
@ -128,6 +128,7 @@ impl AstToJoinIrLowerer {
|
||||
cond: cond_var,
|
||||
then_val: then_var,
|
||||
else_val: else_var,
|
||||
type_hint: None, // Phase 63-3
|
||||
});
|
||||
|
||||
// Ret result
|
||||
|
||||
@ -212,6 +212,7 @@ fn create_loop_step_function_continue(
|
||||
cond: continue_cond_var,
|
||||
then_val: step_acc, // Continue: 更新しない
|
||||
else_val: acc_increment, // 通常: 更新
|
||||
type_hint: None, // Phase 63-3
|
||||
});
|
||||
|
||||
// 6. 末尾再帰
|
||||
|
||||
@ -843,6 +843,7 @@ impl AstToJoinIrLowerer {
|
||||
cond: continue_cond_var,
|
||||
then_val: step_acc, // Continue: 更新しない
|
||||
else_val: acc_increment, // 通常: 更新
|
||||
type_hint: None, // Phase 63-3
|
||||
});
|
||||
|
||||
// 6. 末尾再帰
|
||||
|
||||
@ -145,6 +145,7 @@ impl AstToJoinIrLowerer {
|
||||
dst,
|
||||
then_val: then_var,
|
||||
else_val: else_var,
|
||||
type_hint: None, // Phase 63-3
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -403,11 +403,13 @@ impl AstToJoinIrLowerer {
|
||||
dst: i_after_esc,
|
||||
then_val: i_esc,
|
||||
else_val: step_i,
|
||||
type_hint: None, // Phase 63-3
|
||||
},
|
||||
MergePair {
|
||||
dst: ch_merged,
|
||||
then_val: ch_esc,
|
||||
else_val: step_ch,
|
||||
type_hint: None, // Phase 63-3
|
||||
},
|
||||
],
|
||||
k_next: None,
|
||||
|
||||
Reference in New Issue
Block a user