feat(phase82): Phase 82-if-phi-retire Step 1-3 dev ガード実装
Phase 82-if-phi-retire Implementation: - Step 1-3 分析完了: lifecycle.rs 精読 + P3-C カバレッジ突き合わせ - dev ガード実装: NYASH_PHI_FALLBACK_DISABLED=1 で callsite 封じ Implementation Details: 1. Analysis Findings (Step 1-2): - lifecycle.rs に 2箇所の infer_type_from_phi_with_hint() callsite - GenericTypeResolver::resolve_from_phi() と infer_type_from_phi() は同一ロジック - Case 分類: A (hint付き), B (P1/P2/P3-A/B hint失敗), D (P3-C 失敗・無駄な再実行) 2. config/env/joinir_dev.rs: - phi_fallback_disabled() フラグ追加 - NYASH_PHI_FALLBACK_DISABLED=1 で有効化 3. lifecycle.rs dev ガード: - Callsite 1 (L320-336): instructions 内 Return - Callsite 2 (L377-393): terminator Return - Case 判定付き panic で関数名・ValueId・Case を出力 Next Steps: - テスト実行で callsite が実際に呼ばれるか検証 - 結果に基づいて削除計画確定 Documents Created: - docs/private/roadmap2/phases/phase-82-if-phi-retire/infer_type_from_phi_callsites.md - docs/private/roadmap2/phases/phase-82-if-phi-retire/step1-3-analysis.md Goal: - lifecycle.rs から infer_type_from_phi* 呼び出しを排除 - if_phi.rs 本体削除への道筋を明確化
This commit is contained in:
25
src/config/env/joinir_dev.rs
vendored
25
src/config/env/joinir_dev.rs
vendored
@ -98,3 +98,28 @@ pub fn read_quoted_enabled() -> bool {
|
||||
pub fn read_quoted_ifmerge_enabled() -> bool {
|
||||
env_bool("HAKO_JOINIR_READ_QUOTED_IFMERGE")
|
||||
}
|
||||
|
||||
/// Phase 82: NYASH_PHI_FALLBACK_DISABLED=1 - Disable if_phi fallback (dev mode)
|
||||
///
|
||||
/// lifecycle.rs の infer_type_from_phi* callsite を封じて、
|
||||
/// 実際に呼ばれているかどうかを確認するためのフラグ。
|
||||
///
|
||||
/// # 使用方法
|
||||
///
|
||||
/// ```bash
|
||||
/// NYASH_PHI_FALLBACK_DISABLED=1 cargo test --release mir_joinir_if_select
|
||||
/// ```
|
||||
///
|
||||
/// # 期待される動作
|
||||
///
|
||||
/// - callsite が呼ばれる → panic (関数名・ValueId・Case を出力)
|
||||
/// - callsite が一度も呼ばれない → テスト成功(削除候補確定)
|
||||
///
|
||||
/// # Case 分類
|
||||
///
|
||||
/// - **Case A**: P1/P2/P3-A/P3-B + hint 成功(hint 即座に返す)
|
||||
/// - **Case B**: P1/P2/P3-A/P3-B + hint 失敗(PHI 走査)
|
||||
/// - **Case D**: P3-C + GenericTypeResolver 失敗(PHI 走査・無駄な再実行)
|
||||
pub fn phi_fallback_disabled() -> bool {
|
||||
env_bool("NYASH_PHI_FALLBACK_DISABLED")
|
||||
}
|
||||
|
||||
@ -317,6 +317,23 @@ impl super::MirBuilder {
|
||||
break 'outer;
|
||||
}
|
||||
}
|
||||
// Phase 82: dev ガード - if_phi フォールバック禁止モード
|
||||
if crate::config::env::phi_fallback_disabled() {
|
||||
let case = if hint.is_some() {
|
||||
"Case A (hint付き)"
|
||||
} else if TypeHintPolicy::is_target(&function.signature.name) {
|
||||
"Case B (P1/P2/P3-A/B hint失敗)"
|
||||
} else {
|
||||
"Case D (P3-C GenericTypeResolver失敗)"
|
||||
};
|
||||
panic!(
|
||||
"[phase82/phi_fallback] disabled but infer_type_from_phi called\n\
|
||||
Function: {}\n\
|
||||
ValueId: {:?}\n\
|
||||
Case: {}",
|
||||
function.signature.name, v, case
|
||||
);
|
||||
}
|
||||
if let Some(mt) =
|
||||
crate::mir::phi_core::if_phi::infer_type_from_phi_with_hint(
|
||||
hint, // Phase 63-6-3: P1 の場合は PHI の type_hint、それ以外は None
|
||||
@ -357,6 +374,23 @@ impl super::MirBuilder {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Phase 82: dev ガード - if_phi フォールバック禁止モード
|
||||
if crate::config::env::phi_fallback_disabled() {
|
||||
let case = if hint.is_some() {
|
||||
"Case A (hint付き)"
|
||||
} else if TypeHintPolicy::is_target(&function.signature.name) {
|
||||
"Case B (P1/P2/P3-A/B hint失敗)"
|
||||
} else {
|
||||
"Case D (P3-C GenericTypeResolver失敗)"
|
||||
};
|
||||
panic!(
|
||||
"[phase82/phi_fallback] disabled but infer_type_from_phi called\n\
|
||||
Function: {}\n\
|
||||
ValueId: {:?}\n\
|
||||
Case: {}",
|
||||
function.signature.name, v, case
|
||||
);
|
||||
}
|
||||
if let Some(mt) = crate::mir::phi_core::if_phi::infer_type_from_phi_with_hint(
|
||||
hint, // Phase 63-6-3: P1 の場合は PHI の type_hint、それ以外は None
|
||||
&function,
|
||||
|
||||
Reference in New Issue
Block a user