fix(joinir): Phase 133 P1 - Skip Trim promoted_pairs resolution (defer to TrimLoopLowerer SSOT)

This commit is contained in:
nyash-codex
2025-12-15 13:02:21 +09:00
parent 7b675a6a27
commit b3c832b28a

View File

@ -276,7 +276,17 @@ fn promote_and_prepare_carriers(
promoted_var,
carrier_name,
} => {
// Phase 133 P1: Check if this is a Trim promotion (A-3 pattern)
// Trim promotions are handled by TrimLoopLowerer (apply_trim_and_normalize)
// which provides SSOT for env/join_id, so we defer to that path.
let is_trim_promotion = promoted_carrier.trim_helper().is_some();
// Phase 133 P1: Only add to promoted_pairs for non-Trim promotions
// (e.g., DigitPos/A-4). Trim carriers don't have join_id in carrier_info
// because they use loop_var_name instead of carriers vector.
if !is_trim_promotion {
promoted_pairs.push((promoted_var.clone(), carrier_name.clone()));
}
#[cfg(feature = "normalized_dev")]
{
@ -339,6 +349,13 @@ fn promote_and_prepare_carriers(
helper.carrier_name, helper.original_var, helper.whitespace_chars
),
);
log_pattern2(
verbose,
"phase133",
format!(
"Phase 133 P1: Trim promotion deferred to TrimLoopLowerer (SSOT for env/join_id)"
),
);
} else {
return Err(error_messages::format_error_pattern2_trim_not_safe(
&helper.carrier_name,
@ -347,6 +364,9 @@ fn promote_and_prepare_carriers(
}
}
// Phase 133 P1: Only normalize for non-Trim promotions
// Trim promotions are normalized by TrimLoopLowerer
if !is_trim_promotion {
inputs.break_condition_node = DigitPosConditionNormalizer::normalize(
&inputs.break_condition_node,
&promoted_var,
@ -362,6 +382,7 @@ fn promote_and_prepare_carriers(
),
);
}
}
ConditionPromotionResult::CannotPromote { reason, vars } => {
return Err(error_messages::format_error_pattern2_promotion_failed(
&vars, &reason,