Phase 92 P2-2完了:ConditionalStepのcondition(ch == '\\'など)でbody-local変数をサポート ## 主要変更 ### 1. condition_lowerer.rs拡張 - `lower_condition_to_joinir`に`body_local_env`パラメータ追加 - 変数解決優先度:ConditionEnv → LoopBodyLocalEnv - すべての再帰ヘルパー(comparison, logical_and, logical_or, not, value_expression)対応 ### 2. conditional_step_emitter.rs修正 - `emit_conditional_step_update`に`body_local_env`パラメータ追加 - condition loweringにbody-local環境を渡す ### 3. loop_with_break_minimal.rs修正 - break condition loweringをbody-local init の**後**に移動(line 411) - header_break_lowering::lower_break_conditionにbody_local_env渡す - emit_conditional_step_updateにbody_local_env渡す(line 620) ### 4. header_break_lowering.rs修正 - `lower_break_condition`に`body_local_env`パラメータ追加 - scope_managerにbody-local環境を渡す ### 5. 全呼び出し箇所修正 - expr_lowerer.rs (2箇所) - method_call_lowerer.rs (2箇所) - loop_with_if_phi_if_sum.rs (3箇所) - loop_with_continue_minimal.rs (1箇所) - carrier_update_emitter.rs (1箇所・legacy) ## アーキテクチャ改善 ### Break Condition Lowering順序修正 旧: Header → **Break Cond** → Body-local Init 新: Header → **Body-local Init** → Break Cond 理由:break conditionが`ch == '\"'`のようにbody-local変数を参照する場合、body-local initが先に必要 ### 変数解決優先度(Phase 92 P2-2) 1. ConditionEnv(ループパラメータ、captured変数) 2. LoopBodyLocalEnv(body-local変数like `ch`) ## テスト ### ビルド ✅ cargo build --release成功(30 warnings、0 errors) ### E2E ⚠️ body-local promotion問題でブロック(Phase 92範囲外) - Pattern2はbody-local変数をcarrier promotionする必要あり - 既存パターン(A-3 Trim, A-4 DigitPos)に`ch = get_char(i)`が該当しない - **Phase 92 P2-2目標(condition loweringでbody-local変数サポート)は達成** ## 次タスク(Phase 92 P3以降) - body-local variable promotion拡張(Pattern2で`ch`のような変数を扱う) - P5b E2Eテスト完全動作確認 ## Phase 92 P2-2完了 ✅ Body-local変数のcondition lowering対応完了 ✅ ConditionalStepでbody-local変数参照可能 ✅ Break condition lowering順序修正
39 lines
1.0 KiB
Plaintext
39 lines
1.0 KiB
Plaintext
// Phase 92 P2-3: Simplest P5b E2E Test (no body-local variables)
|
|
//
|
|
// This test uses position-based checks instead of a 'ch' variable
|
|
// to avoid the body-local variable complexity for initial testing.
|
|
//
|
|
// Pattern: Loop with break check + conditional increment (P5b escape pattern)
|
|
//
|
|
// Expected behavior:
|
|
// - i=0: not quote (0!=4), not escape (0!=2), i=1
|
|
// - i=1: not quote (1!=4), not escape (1!=2), i=2
|
|
// - i=2: not quote (2!=4), IS escape (2==2), i=4
|
|
// - i=4: IS quote (4==4), break
|
|
// - Output: 4
|
|
|
|
static box Main {
|
|
main() {
|
|
local i = 0
|
|
local len = 10
|
|
|
|
loop(i < len) {
|
|
// Break check (simulated: position 4 is quote)
|
|
if i == 4 {
|
|
break
|
|
}
|
|
|
|
// Escape check with conditional increment (P5b pattern)
|
|
// Position 2 is escape character
|
|
if i == 2 {
|
|
i = i + 2 // Escape: skip 2
|
|
} else {
|
|
i = i + 1 // Normal: skip 1
|
|
}
|
|
}
|
|
|
|
print(i)
|
|
return 0
|
|
}
|
|
}
|