feat(joinir): Phase 64-3 P2型ヒントlifecycle.rs統合

箱理論に基づくP1/P2型ヒント判定の統合:
- `is_type_hint_target()` ヘルパー関数追加(箱に切り出す)
- P1: IfSelectTest.* (既存、Phase 63-6)
- P2: IfMergeTest.*, read_quoted* (新規、Phase 64-3)

lifecycle.rs 2箇所の条件を統一関数に置き換え:
- 関数名フィルタで段階的拡大を制御
- Fail-fast原則: 対象外は従来挙動維持

テスト確認:
- test_p1_ab_type_inference  PASS
- test_p2_if_merge_type_hint  PASS
- 退行なし確認済み(既存の43 failedは元々のバグ)

技術的成果:
- P1/P2 両方で JoinIR 型ヒント → lifecycle.rs → 型推論 の経路確立
- 箱理論「まず箱に切り出す」原則の実践

修正ファイル:
- src/mir/builder/lifecycle.rs: is_type_hint_target() 追加、条件統一

🎯 Phase 64-4 へ: infer_type_from_phi 削除条件確認

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-11-30 05:20:31 +09:00
parent e669f124d2
commit ce65694826

View File

@ -31,7 +31,9 @@ fn has_main_static(ast: &ASTNode) -> bool {
/// Phase 63-6-3: PHI命令から型ヒントを取得
///
/// ValueId が PHI 命令の結果である場合、その type_hint を返す。
/// P1 ケースIfSelectTest.simple/localでのみ使用を想定
/// P1 ケースIfSelectTest.*)および P2 ケースIfMergeTest.*, read_quoted*)で使用
///
/// Phase 64-3: P2 ケース拡大 - IfMerge パターンと read_quoted 系関数を追加
///
/// # Arguments
///
@ -59,6 +61,33 @@ fn get_phi_type_hint(
None
}
/// Phase 64-3: P1/P2 型ヒント対象判定
///
/// 関数名が型ヒント使用対象かどうかを判定する。
/// 箱理論: 段階的拡大のため、関数名フィルタで制御
///
/// # P1 対象Phase 63-6 完了)
/// - `IfSelectTest.*` - If Select パターンのテスト関数
///
/// # P2 対象Phase 64-3 追加)
/// - `IfMergeTest.*` - If Merge パターンのテスト関数
/// - `read_quoted*` - selfhost の read_quoted 系関数
fn is_type_hint_target(func_name: &str) -> bool {
// P1: If Select テスト関数
if func_name.starts_with("IfSelectTest.") {
return true;
}
// P2: If Merge テスト関数
if func_name.starts_with("IfMergeTest.") {
return true;
}
// P2: selfhost read_quoted 系関数
if func_name.contains("read_quoted") {
return true;
}
false
}
impl super::MirBuilder {
/// Unified declaration indexing (Phase A): collect symbols before lowering
/// - user_defined_boxes: non-static Box names (for NewBox birth() skip)
@ -309,8 +338,8 @@ impl super::MirBuilder {
inferred = Some(mt);
break 'outer;
}
// Phase 63-6-3: P1 ケースIfSelectTest.*で型ヒント使用
let hint = if function.signature.name.starts_with("IfSelectTest.") {
// Phase 64-3: P1/P2 ケースで型ヒント使用
let hint = if is_type_hint_target(&function.signature.name) {
get_phi_type_hint(&function, *v)
} else {
None