feat(control_tree): Phase 133 P0 - Multiple post-loop assigns support
Extend Phase 132's loop(true) + post-loop to accept multiple assignments:
Goal: `x=0; loop(true){ x=1; break }; x=x+2; x=x+3; return x` → exit code 6
Implementation:
- Extended loop_true_break_once.rs pattern detection (len() == 2 → len() >= 2)
- Added iterative assignment lowering (for loop over post_nodes)
- Reused Phase 130's lower_assign_stmt for each assignment
- Maintained ExitMeta DirectValue mode (PHI-free)
Changes:
- apps/tests/phase133_loop_true_break_once_post_multi_add_min.hako (new fixture)
- tools/smokes/v2/profiles/integration/apps/phase133_*_multi_add_*.sh (new smokes)
- src/mir/control_tree/normalized_shadow/loop_true_break_once.rs (+30 lines)
- docs/development/current/main/phases/phase-133/README.md (new documentation)
- docs/development/current/main/10-Now.md (Phase 133 entry added)
Scope (Phase 130 baseline):
- ✅ x = <int literal>
- ✅ x = y (variable copy)
- ✅ x = x + <int literal> (increment)
- ❌ Function calls / general expressions (future phases)
Design principles:
- Minimal change: ~30 lines added
- SSOT preservation: env_post_k remains single source of truth
- Reuse: Leveraged existing lower_assign_stmt
- Fail-Fast: Contract violations trigger freeze_with_hint
Test results:
- cargo test --lib: 1176 PASS
- Phase 133 VM: PASS (exit code 6)
- Phase 133 LLVM EXE: PASS (exit code 6)
- Phase 132 regression: PASS (exit code 3)
- Phase 131 regression: PASS (exit code 1)
- Phase 97 regression: PASS
Architecture maintained:
- 5-function structure unchanged (main/loop_step/loop_body/k_exit/post_k)
- PHI-free DirectValue mode
- Zero changes to ExitMeta, merge logic, or JoinIR contracts
Related: Phase 133 loop(true) + multiple post-loop assignments
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -0,0 +1,28 @@
|
||||
// Phase 133-P0: loop(true) break-once with multiple post-loop assignments
|
||||
//
|
||||
// Purpose: Test loop(true) { <assign>* ; break }; <assign>*; return in Normalized shadow
|
||||
// Expected output: 6
|
||||
//
|
||||
// Structure:
|
||||
// x = 0 // pre-loop init
|
||||
// loop(true) { // condition is Bool literal true
|
||||
// x = 1 // body assignment
|
||||
// break // break at end
|
||||
// }
|
||||
// x = x + 2 // first post-loop assignment (1 + 2 = 3)
|
||||
// x = x + 3 // second post-loop assignment (3 + 3 = 6)
|
||||
// return x // return updated value
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
local x
|
||||
x = 0
|
||||
loop(true) {
|
||||
x = 1
|
||||
break
|
||||
}
|
||||
x = x + 2
|
||||
x = x + 3
|
||||
return x
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user