From ce65694826fb104693d15fcc66480445f214ec1c Mon Sep 17 00:00:00 2001 From: nyash-codex Date: Sun, 30 Nov 2025 05:20:31 +0900 Subject: [PATCH] =?UTF-8?q?feat(joinir):=20Phase=2064-3=20P2=E5=9E=8B?= =?UTF-8?q?=E3=83=92=E3=83=B3=E3=83=88lifecycle.rs=E7=B5=B1=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 箱理論に基づく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 --- src/mir/builder/lifecycle.rs | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/mir/builder/lifecycle.rs b/src/mir/builder/lifecycle.rs index 7b275040..45f63396 100644 --- a/src/mir/builder/lifecycle.rs +++ b/src/mir/builder/lifecycle.rs @@ -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