Phase 200-B: FunctionScopeCaptureAnalyzer implementation - analyze_captured_vars_v2() with structural loop matching - CapturedEnv for immutable function-scope variables - ParamRole::Condition for condition-only variables Phase 200-C: ConditionEnvBuilder extension - build_with_captures() integrates CapturedEnv into ConditionEnv - fn_body propagation through LoopPatternContext to Pattern 2 Phase 200-D: E2E verification - capture detection working for base, limit, n etc. - Test files: phase200d_capture_minimal.hako, phase200d_capture_in_condition.hako Phase 201-A: MirBuilder reserved_value_ids infrastructure - reserved_value_ids: HashSet<ValueId> field in MirBuilder - next_value_id() skips reserved IDs - merge/mod.rs sets/clears reserved IDs around JoinIR merge Phase 201: JoinValueSpace design document - Param/Local/PHI disjoint regions design - API: alloc_param(), alloc_local(), reserve_phi() - Migration plan for Pattern 1-4 lowerers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
39 lines
1.2 KiB
Plaintext
39 lines
1.2 KiB
Plaintext
// Phase 200-D: Minimal capture test (Pattern 2)
|
|
// This test verifies that captured variables work in JoinIR Pattern 2
|
|
// without using substring or other unsupported methods.
|
|
//
|
|
// Key points:
|
|
// - base/offset are captured (function-scoped constants)
|
|
// - No substring/indexOf in body-local init (Phase 193 limitation)
|
|
// - Simple accumulation using captured value
|
|
// - Break condition: i == 100 (never true, just to trigger Pattern 2)
|
|
|
|
static box Main {
|
|
main() {
|
|
local base = 10 // Captured var (used in multiplication)
|
|
local offset = 5 // Captured var (used in addition)
|
|
|
|
local i = 0
|
|
local v = 0
|
|
local n = 3 // Loop 3 times
|
|
|
|
// Pattern 2: loop with break (break never fires)
|
|
loop(i < n) {
|
|
// Simple break condition that never fires
|
|
if i == 100 {
|
|
break
|
|
}
|
|
|
|
// Use captured variable in accumulation
|
|
// v = v + base
|
|
// For i=0: v = 0 + 10 = 10
|
|
// For i=1: v = 10 + 10 = 20
|
|
// For i=2: v = 20 + 10 = 30
|
|
v = v + base
|
|
i = i + 1
|
|
}
|
|
|
|
print(v) // Expected: 30
|
|
}
|
|
}
|