Implement ANF transformation for impure expressions to fix evaluation order: Phase 145 P0 (Skeleton): - Add anf/ module with contract/plan/execute 3-layer separation - AnfDiagnosticTag, AnfOutOfScopeReason, AnfPlan enums - Stub execute_box (always returns Ok(None)) - 11 unit tests pass Phase 145 P1 (Minimal success): - String.length() whitelist implementation - BinaryOp + MethodCall pattern: x + s.length() → t = s.length(); result = x + t - Exit code 12 verification (VM + LLVM EXE) - 17 unit tests pass Phase 145 P2 (Generalization): - Recursive ANF for compound expressions - Left-to-right, depth-first evaluation order - Patterns: x + s.length() + z, s1.length() + s2.length() - ANF strict mode (HAKO_ANF_STRICT=1) - Diagnostic tags (joinir/anf/*) - 21 unit tests pass, 0 regression Also includes Phase 143 P2 (else symmetry) completion. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
29 lines
676 B
Plaintext
29 lines
676 B
Plaintext
// Phase 143 P1: loop(true) + if + continue minimal test
|
|
//
|
|
// Pattern: loop(true) { if(cond_pure) continue }
|
|
// Expected: non-terminating (Phase 143 P1 scope)
|
|
//
|
|
// This test verifies:
|
|
// - loop(true) is recognized
|
|
// - Pure condition (counter < 1) is lowerable
|
|
// - Continue path executes (jumps to loop_step instead of k_exit)
|
|
// - Infinite loop with continue (never exits via condition)
|
|
//
|
|
// Smoke contract:
|
|
// - VM/LLVM runs should time out (expected), not fail fast.
|
|
|
|
static box Main {
|
|
main() {
|
|
local counter
|
|
counter = 0
|
|
|
|
loop(true) {
|
|
if counter < 1 {
|
|
continue
|
|
}
|
|
}
|
|
|
|
return 100
|
|
}
|
|
}
|