Files
hakorune/apps/tests/phase193_init_method_call.hako
nyash-codex 996925ebaf fix(joinir): Phase 196 Select double-remap bug in instruction_rewriter
Root cause: PHI inputs were being remapped twice in instruction_rewriter.rs
- Line 304: remap_instruction() already remapped JoinIR → Host ValueIds
- Line 328: remap_value() attempted to remap again → undefined ValueIds

Fix: Only remap block IDs, use already-remapped ValueIds as-is

Test results:
- phase195_sum_count.hako → 93  (multi-carrier P3)
- loop_if_phi.hako → sum=9  (single-carrier P3)
- loop_min_while.hako → 0,1,2  (Pattern 1)
- joinir_min_loop.hako → RC:0  (Pattern 2)
- No [joinir/freeze], no regressions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-09 14:45:04 +09:00

42 lines
1.4 KiB
Plaintext

// Phase 193: MethodCall in Body-Local Init Expression
//
// Test: local digit_str = i.toString() (simplified from indexOf)
//
// NOTE: This is a placeholder test demonstrating the Phase 193 infrastructure.
// The original design targeted digits.indexOf(ch), but that requires outer scope
// variables in ConditionEnv, which would need Pattern 2/3 enhancements (Phase 194+).
//
// For Phase 193, we test that:
// 1. MethodCall in body-local init expressions can be lowered to JoinIR
// 2. The receiver can be resolved from ConditionEnv (loop param)
// 3. BoxCall instruction is correctly emitted
//
// This verifies the core Phase 193 implementation is working.
//
// Expected behavior:
// - i = 0, 1, 2 (loop iterations)
// - toString() converts each to string
// - Result: prints string concatenation (actual output may vary due to BoxCall behavior)
// - The key success criterion is that MethodCall is lowered without error
static box Main {
main() {
local result = ""
local i = 0
loop(i < 10) {
if i >= 3 {
break
}
// Phase 193 target: MethodCall in body-local init
// Receiver (i) is in ConditionEnv as loop parameter
local digit_str = i.toString()
result = result + digit_str
i = i + 1
}
print(result) // Output varies (BoxCall behavior dependent)
return 0
}
}