Files
hakorune/apps/tests/phase223_p4_skip_whitespace_min.hako

40 lines
1.3 KiB
Plaintext
Raw Normal View History

feat(joinir): Phase 223-3 - LoopBodyCondPromoter implementation Implements LoopBodyLocal condition promotion for Pattern4/continue patterns. Previously, loops with LoopBodyLocal in conditions would Fail-Fast. Now, safe Trim/skip_whitespace patterns (Category A-3) are promoted and lowering continues. ## Implementation - **LoopBodyCondPromoter Box** (loop_body_cond_promoter.rs) - extract_continue_condition(): Extract if-condition from continue branches - try_promote_for_condition(): Thin wrapper delegating to LoopBodyCarrierPromoter - ConditionPromotionRequest/Result API for Pattern2/4 integration - **Pattern4 Integration** (pattern4_with_continue.rs) - Analyze both header condition + continue condition - On promotion success: merge carrier_info → continue lowering - On promotion failure: Fail-Fast with clear error message - **Unit Tests** (5 tests, all PASS) - test_cond_promoter_skip_whitespace_pattern - test_cond_promoter_break_condition - test_cond_promoter_non_substring_pattern - test_cond_promoter_no_scope_shape - test_cond_promoter_no_body_locals - **E2E Test** (phase223_p4_skip_whitespace_min.hako) - Category A-3 pattern: local ch = s.substring(...); if ch == " " { continue } - Verifies promotion succeeds and Pattern4 lowering proceeds ## Documentation - joinir-architecture-overview.md: Updated LoopBodyCondPromoter section (Phase 223-3 完了) - CURRENT_TASK.md: Added Phase 223-3 completion summary - PHASE_223_SUMMARY.md: Phase overview and status tracking - phase223-loopbodylocal-condition-*.md: Design docs and inventory ## Achievement - **Before**: LoopBodyLocal in condition → Fail-Fast - **Now**: Trim/skip_whitespace patterns promoted → Pattern4 lowering continues - **Remaining**: Phase 172+ JoinIR Trim lowering for complete RC correctness 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-10 15:00:20 +09:00
// Phase 223-3 E2E Test: Pattern4 skip_whitespace minimal test
//
// Tests that LoopBodyLocal in continue condition can be promoted
// and Pattern4 lowering continues successfully (no Fail-Fast).
//
// Pattern: Category A-3 (_skip_whitespace)
// - Single LoopBodyLocal (ch) in continue condition
// - Definition: local ch = s.substring(...)
// - Condition: ch == " " || ch == "\t" || ch == "\n" || ch == "\r"
// - Action: pos = pos + 1; continue
//
// Phase 223-3 Achievement:
// - Previously: Fail-Fast with "[cf_loop/pattern4] Cannot promote LoopBodyLocal"
// - Now: Promotion succeeds, Pattern4 lowering continues
//
// NOTE: Full correct execution (RC=2) requires Phase 172+ JoinIR Trim lowering.
// This test verifies promotion works, not final execution correctness.
static box SkipWhitespaceP4Test {
main() {
local s = " ab"
local pos = 0
local n = 4
loop(pos < n) {
local ch = s.substring(pos, pos + 1)
if ch == " " || ch == "\t" || ch == "\n" || ch == "\r" {
pos = pos + 1
continue
}
break
}
// Phase 223-3: Promotion success allows lowering to proceed
// Expected final value after Phase 172+: pos = 2
print(pos)
return pos
}
}