Remove legacy hardcoded 'sum' carrier validation that was blocking array_filter patterns with different accumulator names (e.g., 'out'). Before: Pattern3 required carrier named 'sum' to exist After: Pattern3 uses carrier_info generically (any carrier name works) Test results: - phase49_joinir_array_filter_smoke: PASS ✅ - phase49_joinir_array_filter_fallback: PASS ✅ - phase49_joinir_array_filter_ab_comparison: PASS ✅ - Full suite: 909/909 PASS, 0 FAIL Also: Archive old roadmap documentation (67k lines moved to docs/archive/) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2.6 KiB
2.6 KiB
Phase 195: Pattern 4 (Loop with Continue) Implementation Plan
Status: Historical
Status: Deferred (not yet implemented)
Overview
Pattern 4 handles loops with continue statements that skip to the next iteration. This is the most complex loop pattern due to additional control flow requirements.
Why Deferred?
-
Continue semantics require additional PHI and control flow analysis
- Continue creates an additional edge to the loop header
- Requires phi nodes for both continue and normal paths
- More complex than break (which exits the loop)
-
Pattern 3 covers most practical cases
- Pattern 1: Simple while loops
- Pattern 2: Loops with break
- Pattern 3: Loops with if + PHI (most common complex pattern)
- Pattern 4: Loops with continue (less common in practice)
-
Lower priority than break/if patterns
- Break patterns (Pattern 2) are more common
- If + PHI patterns (Pattern 3) handle complex control flow
- Continue can often be refactored using if statements
Example Use Case
local i = 0
local sum = 0
loop(i < 10) {
i = i + 1
if (i % 2 == 0) {
continue // Skip even numbers
}
sum = sum + i
}
// sum = 25 (1+3+5+7+9)
Implementation Requirements
When implemented, Pattern 4 lowering will need to:
- Detect continue statements in the loop body
- Generate PHI nodes for continue target (loop header)
- Handle carrier variables (i, sum) across continue boundaries
- Generate exit PHI nodes for final values after loop
Control Flow Diagram
header
|
v
body
|
/----+----\
/ \
v v
continue normal
| |
\-----+-------/
|
v
latch
|
/---+---\
/ \
v v
loop exit
Workaround
Until Pattern 4 is implemented, use Pattern 3 (if + PHI) instead:
local i = 0
local sum = 0
loop(i < 10) {
i = i + 1
if (not (i % 2 == 0)) { // Invert condition
sum = sum + i
}
}
Migration Path
- Pattern 1: Simple while loops (no break/continue)
- Pattern 2: Loops with break
- Pattern 3: Loops with if + PHI
- Pattern 4: (FUTURE) Loops with continue statements
Related Files
src/mir/builder/control_flow/joinir/patterns/pattern4_with_continue.rs- Stub implementationsrc/mir/join_ir/lowering/loop_with_continue_minimal.rs- Lowering logic (TODO)
Timeline
- Phase 195+: Implementation planned but deferred
- Priority: Lower than Pattern 1-3
- Complexity: High (additional control flow edges)