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順序修正
51 lines
1.4 KiB
Plaintext
51 lines
1.4 KiB
Plaintext
// Phase 92 P2-3: Minimal P5b E2E Test
|
|
//
|
|
// This is a MINIMAL test to verify ConditionalStep emission works.
|
|
// Pattern: Loop with break check + conditional increment (P5b escape pattern)
|
|
//
|
|
// Expected behavior:
|
|
// - i=0: not quote, not escape, i=1
|
|
// - i=1: not quote, not escape, i=2
|
|
// - i=2: not quote, IS escape, i=4
|
|
// - i=4: IS quote, break
|
|
// - Output: 4
|
|
|
|
static box Main {
|
|
main() {
|
|
local i = 0
|
|
local len = 10
|
|
local ch = "a"
|
|
local str = "ab\\cd\"ef"
|
|
|
|
loop(i < len) {
|
|
// Body statement: Simulate character access from string
|
|
// In real parser, this would be: ch = str.charAt(i)
|
|
// Here we simplify by checking position
|
|
if i == 2 {
|
|
ch = "\\" // Position 2: backslash
|
|
} else {
|
|
if i == 4 {
|
|
ch = "\"" // Position 4: quote
|
|
} else {
|
|
ch = "a" // Other positions: normal char
|
|
}
|
|
}
|
|
|
|
// Break check (P5b pattern requirement)
|
|
if ch == "\"" {
|
|
break
|
|
}
|
|
|
|
// Escape check with conditional increment (P5b pattern)
|
|
if ch == "\\" {
|
|
i = i + 2 // Escape: skip 2
|
|
} else {
|
|
i = i + 1 // Normal: skip 1
|
|
}
|
|
}
|
|
|
|
print(i)
|
|
return 0
|
|
}
|
|
}
|