🔧 Hotfix 7 (Enhanced): ValueId receiver alias tracking for nested loops

- Problem: Pinned receiver variables in loops cause undefined ValueId errors
- Enhanced fix: Update all receiver aliases (me + all __pin$N$@recv levels)
- Handles nested loops by updating previous pin levels
- Test status: Partial improvement, ValueId(50) → ValueId(40)
- Further investigation needed for complete fix

Files modified:
- src/mir/phi_core/loopform_builder.rs (emit_header_phis)
This commit is contained in:
nyash-codex
2025-11-19 00:02:41 +09:00
parent 263affe379
commit 80f8a7bc8c
17 changed files with 983 additions and 277 deletions

View File

@ -0,0 +1,38 @@
// loopssa_breakfinder_min.hako — Minimal LoopSSA/BreakFinder JSON test harness
//
// 目的:
// - StageB を経由せずに、LoopSSA + BreakFinderBox + PhiInjectorBox の経路だけを
// 小さな Program(JSON v0) 文字列で通すミニハーネスだよ。
// - まずは「単純な loop_header/loop_exit パターンで正常に動く」ことを確認する足場として使う。
// - 将来的に StageB 最小サンプルから抽出した JSON をここに貼り替えることで、
// ValueId(50) 系の問題を再現しやすくすることを想定しているよ。
//
// JSON 形状(簡略版):
// {
// "kind":"Program",
// "functions":[
// {
// "name":"main",
// "blocks":[
// {"id":0,"loop_header":0,"loop_exit":2},
// {"id":1},
// {"id":2}
// ]
// }
// ]
// }
//
using lang.compiler.builder.ssa.loopssa as LoopSSA
static box Main {
method main(args) {
local json = "{\"kind\":\"Program\",\"functions\":[{\"name\":\"main\",\"blocks\":[{\"id\":0,\"loop_header\":0,\"loop_exit\":2},{\"id\":1},{\"id\":2}]}]}"
// LoopSSA v2 を直接呼び出すよLoopSSA EXIT PHI パスのみ)
local out = LoopSSA.stabilize_merges(json)
print(out)
return 0
}
}