refactor(normalization): Phase 135 P0 - Extend plan to zero post-loop assigns
Generalize NormalizationPlan suffix detection to accept zero post-loop assignments: Goal: Improve entry point consistency by allowing `loop + assign* + return` (N >= 0) Implementation: - Modified plan_box.rs detection logic (only file changed) - Removed `post_assign_count >= 1` requirement - Unified Phase 131 (loop + return) and Phase 132-133 (loop + assign+ + return) paths Changes: - src/mir/builder/control_flow/normalization/plan_box.rs: - Removed assignment count constraint - Unified pattern detection: `loop + assign* + return` (N >= 0) - apps/tests/phase135_loop_true_break_once_post_empty_return_min.hako (new fixture) - tools/smokes/v2/profiles/integration/apps/phase135_*.sh (new smoke tests) Pattern support: - Phase 131/135: loop + return only (consumed: 2, post_assign_count: 0) ✅ - Phase 132: loop + 1 assign + return (consumed: 3, post_assign_count: 1) ✅ - Phase 133: loop + N assigns + return (consumed: 2+N, post_assign_count: N) ✅ Design principles maintained: - **Minimal change**: Only plan_box.rs modified (execute_box unchanged) - **SSOT**: Detection logic centralized in plan_box.rs - **Box-First**: Responsibility separation preserved (Plan/Execute) Test results: - Unit tests (plan_box): 9/9 PASS (2 new tests added) - Phase 135 VM/LLVM EXE: PASS (exit code 1) - Phase 131 regression: 2/2 PASS (path now unified) - Phase 133 regression: 2/2 PASS - cargo test --lib: PASS Benefits: - Unified entry point for all loop + post patterns - Easier maintenance (single detection logic) - Future extensibility (easy to add new patterns) - Clear separation of Phase 131 and Phase 132-135 paths Default behavior unchanged: Dev-only guard maintained Related: Phase 135 normalization pattern consistency improvement 🤖 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 135 P0: loop(true) break-once with post 0 assigns + return
|
||||
//
|
||||
// Purpose: Test loop(true) { <assign>* ; break } + return (0 assignments)
|
||||
// Expected output: 1
|
||||
//
|
||||
// Structure:
|
||||
// x = 0 // pre-loop init
|
||||
// loop(true) { // condition is Bool literal true
|
||||
// x = 1 // body assignment
|
||||
// break // break at end
|
||||
// }
|
||||
// return x // direct return (NO post-loop assignments)
|
||||
//
|
||||
// Difference from Phase 131:
|
||||
// Phase 131: loop only (no return)
|
||||
// Phase 135: loop + return (0 post assignments)
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
local x
|
||||
x = 0
|
||||
loop(true) {
|
||||
x = 1
|
||||
break
|
||||
}
|
||||
return x
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user