diff --git a/src/config/env/joinir_dev.rs b/src/config/env/joinir_dev.rs index eb29cdea..d164ffe2 100644 --- a/src/config/env/joinir_dev.rs +++ b/src/config/env/joinir_dev.rs @@ -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") +} diff --git a/src/mir/builder/lifecycle.rs b/src/mir/builder/lifecycle.rs index e0990873..43b5116d 100644 --- a/src/mir/builder/lifecycle.rs +++ b/src/mir/builder/lifecycle.rs @@ -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,