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>
This commit is contained in:
nyash-codex
2025-12-10 15:00:20 +09:00
parent 9dbf053781
commit 89a769198a
9 changed files with 1962 additions and 40 deletions

View File

@ -778,6 +778,9 @@ pub mod error_messages;
// Phase 171-C: LoopBodyLocal Carrier Promotion
pub mod loop_body_carrier_promoter;
// Phase 223-3: LoopBodyLocal Condition Promotion (for Pattern4)
pub mod loop_body_cond_promoter;
// Phase 171-C-5: Trim Pattern Helper
pub mod trim_loop_helper;
pub use trim_loop_helper::TrimLoopHelper;