A案実装: debug_verify_phi_inputs呼び出し前にCFG predecessorを更新
修正箇所(7箇所):
- src/mir/builder/phi.rs:50, 73, 132, 143
- src/mir/builder/ops.rs:273, 328, 351
根本原因:
- Branch/Jump命令でsuccessorは即座に更新
- predecessorはupdate_cfg()で遅延再構築
- PHI検証が先に実行されてpredecessor未更新でpanic
解決策:
- 各debug_verify_phi_inputs呼び出し前に
if let Some(func) = self.current_function.as_mut() {
func.update_cfg();
}
を挿入してCFGを同期
影響: if/else文、論理演算子(&&/||)のPHI生成が正常動作
20 lines
1.1 KiB
Plaintext
20 lines
1.1 KiB
Plaintext
using "lang/src/vm/mini_vm_lib.hako" as MiniVm
|
|
|
|
static box Main {
|
|
main(args) {
|
|
// Mixed shapes (loader-centric)
|
|
// 1) echo() with empty args -> ""
|
|
// 2) string literal with quotes inside
|
|
// 3) itoa() with empty args -> "0"
|
|
// 4) BinaryOp 8+9
|
|
// 5) int literal 4
|
|
local json = "{\"kind\":\"Program\",\"statements\":[{\"kind\":\"Print\",\"expression\":{\"kind\":\"FunctionCall\",\"name\":\"echo\",\"arguments\":[]}},{\"kind\":\"Print\",\"expression\":{\"kind\":\"Literal\",\"value\":{\"type\":\"string\",\"value\":\"C\"}}},{\"kind\":\"Print\",\"expression\":{\"kind\":\"FunctionCall\",\"name\":\"itoa\",\"arguments\":[]}},{\"kind\":\"Print\",\"expression\":{\"kind\":\"BinaryOp\",\"operator\":\"+\",\"left\":{\"kind\":\"Literal\",\"value\":{\"type\":\"int\",\"value\":8}},\"right\":{\"kind\":\"Literal\",\"value\":{\"type\":\"int\",\"value\":9}}}},{\"kind\":\"Print\",\"expression\":{\"kind\":\"Literal\",\"value\":{\"type\":\"int\",\"value\":4}}}]}"
|
|
|
|
local arr = new MiniVm().collect_prints(json)
|
|
local i = 0
|
|
loop (i < arr.length()) { print(arr.get(i)) i = i + 1 }
|
|
return 0
|
|
}
|
|
}
|
|
// migrated from .nyash to .hako (branding)
|