Fix VM: string handler no longer hijacks length() on non-strings; ArrayBox.length returns correct values (fixes json_lint loop). Add string-literal reader init guard earlier

This commit is contained in:
nyash-codex
2025-11-01 19:26:49 +09:00
parent 756af0da6c
commit 25b6bd3ae1
3 changed files with 30 additions and 7 deletions

View File

@ -120,7 +120,17 @@ pub fn seal_incomplete_phis_with<O: LoopPhiOps>(
let value_after = ops
.get_variable_at_block(&phi.var_name, latch_id)
.ok_or_else(|| format!("Variable {} not found at latch block", phi.var_name))?;
phi.known_inputs.push((latch_id, value_after));
// 🔧 ループ不変変数の自己参照PHI問題を修正
// value_afterがPHI自身の場合ループ内で変更されていない変数は、
// preheaderの値を使用する
let latch_value = if value_after == phi.phi_id {
// ループ不変変数preheaderの値を使用
phi.known_inputs[0].1 // preheaderからの初期値
} else {
value_after
};
phi.known_inputs.push((latch_id, latch_value));
ops.debug_verify_phi_inputs(block_id, &phi.known_inputs);
ops.emit_phi_at_block_start(block_id, phi.phi_id, phi.known_inputs)?;