Files
hakorune/apps/tests/phase200d_digits_simple.hako
nyash-codex 32a91e31ac feat(joinir): Phase 200-B/C/D capture analysis + Phase 201-A reserved_value_ids infra
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>
2025-12-09 18:32:03 +09:00

36 lines
1.1 KiB
Plaintext

// Phase 200-D: Simple digits capture test (Pattern 2 with break)
// This test verifies that captured variables (digits) work in JoinIR Pattern 2.
//
// Key constraints:
// - Loop condition uses only LoopParam (i) and OuterLocal (n)
// - Break condition uses outer-scoped variable (maxIter), NOT body-local
// - digits is captured and used in loop body
static box Main {
main() {
local digits = "0123456789" // Captured var
local s = "12" // Input string
local i = 0
local v = 0
local n = s.length() // n = 2
local maxIter = 10 // Safety limit (outer-scoped, not body-local)
// Pattern 2: loop with break (break condition uses outer var)
loop(i < n) {
// Break if too many iterations (uses outer var, not body-local)
if i > maxIter {
break
}
local ch = s.substring(i, i + 1)
local d = digits.indexOf(ch) // digits: captured
v = v * 10 + d
i = i + 1
}
print(v) // Expected: 12
}
}