feat(debug): __mir__.log追加+VM実行テスト - loopバグ確定

## 🔍 func_scanner.hakoに__mir__.log追加
```hako
method skip_whitespace(s, idx) {
  __mir__.log("skip_ws/head", i, n)
  loop(1 == 1) {
    __mir__.log("skip_ws/loop", i, n)  ← 実行されない
    ...
  }
  __mir__.log("skip_ws/exit", i, n)
}
```

## 📊 CLI実行結果(MIRログ)
```
[MIR-LOG] skip_ws/head: %26=Integer(0) %28=Integer(6)
[MIR-LOG] skip_ws/exit: %26=Integer(0) %28=Integer(6)
```
-  i=0, n=6(両方Integer, 値は正しい)
-  `skip_ws/loop`が**一度も出ない**
- → **loop本体が実行されていないことがMIRレベルで確定**

## 🧪 Rustテスト更新
1. **ソースを束ねる**: func_scanner.hako + test file
   - FuncScannerBox関数がmoduleに含まれるように修正
2. **VM実行追加**: execute_module()でバグ再現確認
   - 期待: rc=0 (PASS), 実際: rc=1 (FAIL)

## 🎯 次のステップ
- MIRダンプでLoopForm展開を確認
- VM interpreter/LoopForm実行を調査

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-11-20 08:22:43 +09:00
parent 7ed13f98d5
commit 471052ad8d
2 changed files with 34 additions and 5 deletions

View File

@ -312,15 +312,18 @@ static box FuncScannerBox {
local i = idx
local n = s.length()
print("[skip_ws] i=" + ("" + i) + " n=" + ("" + n))
__mir__.log("skip_ws/head", i, n)
// WORKAROUND: Changed from loop(i < n) to loop with internal if check
// Original: loop(i < n) { ... } was not executing body even when condition was true!
loop(1 == 1) {
__mir__.log("skip_ws/loop", i, n)
print("[skip_ws] LOOP-TOP i=" + ("" + i))
if i >= n { break }
local ch = s.substring(i, i + 1)
print("[skip_ws] LOOP i=" + ("" + i) + " ch='" + ch + "'")
if ch == " " || ch == "\t" || ch == "\n" || ch == "\r" { i = i + 1 } else { break }
}
__mir__.log("skip_ws/exit", i, n)
print("[skip_ws] RETURN i=" + ("" + i))
return i
}