test(stageb): 最小再現ケース+Rustテスト追加 - using読み込み問題発見

## 🔍 新規ファイル
1. **funcscanner_skip_ws_min.hako**: 最小再現ケース
   - FuncScannerBox.skip_whitespace直接呼び出しテスト
   - 期待: idx=3(3空白スキップ)
   - 実際: idx=0(loop不実行でFAIL)

2. **mir_funcscanner_skip_ws.rs**: Rustレベルテスト
   - MIRコンパイル + 検証
   - 関数存在確認

## 🐛 重大発見
### 問題: using経由モジュールが読み込まれない
```
[test] Module has 2 functions
[test] ALL available functions:
[test]   - main
[test]   - condition_fn
```
- `using lang.compiler.entry.func_scanner as FuncScannerBox`宣言済み
- でもFuncScannerBox.skip_whitespace/2が**モジュールに存在しない**
- CLI実行時は動作 → Rustテスト環境特有の問題?

### 2層の問題構造
1. **本命バグ**: loop(1==1)が実行されない(CLI実行で再現済み)
2. **新発見**: usingモジュール読み込み未実装(Rustテスト環境)

## 📊 次のステップ
- using systemのコンパイル時モジュール解決を調査
- または別アプローチでloop バグに直接アプローチ

🤖 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:16:35 +09:00
parent 0dc8510daf
commit 7ed13f98d5
3 changed files with 145 additions and 1 deletions

View File

@ -0,0 +1,54 @@
// funcscanner_skip_ws_min.hako
// Minimal reproduction case for FuncScannerBox.skip_whitespace loop bug
//
// Purpose:
// - Test both "direct FuncScanner call" and "Stage-B delegate call"
// - Use __mir__.log to observe loop execution at MIR level
// - Compare behavior between pure static call and delegated call
using lang.compiler.entry.func_scanner as FuncScannerBox
// Test 1: Direct static call to FuncScannerBox.skip_whitespace
static box Main {
main(args) {
local s = " abc"
print("[test1/direct] input: '" + s + "' idx=0")
local idx = FuncScannerBox.skip_whitespace(s, 0)
print("[test1/direct] result idx=" + ("" + idx))
print("[test1/direct] expected: idx=3 (skip 3 spaces)")
if idx == 3 {
print("[test1/direct] PASS")
return 0
} else {
print("[test1/direct] FAIL: expected 3, got " + ("" + idx))
return 1
}
}
}
// Test 2: Delegate call via StageBFuncScannerBox (closer to Stage-B path)
// NOTE: Commenting out for now - need to verify if this path works
// using lang.compiler.entry.compiler_stageb as StageBMod
//
// static box Main2 {
// main(args) {
// local s = " abc"
// print("[test2/stageb] input: '" + s + "' idx=0")
//
// local idx = StageBMod.StageBFuncScannerBox._skip_whitespace(s, 0)
//
// print("[test2/stageb] result idx=" + ("" + idx))
// print("[test2/stageb] expected: idx=3")
//
// if idx == 3 {
// print("[test2/stageb] PASS")
// return 0
// } else {
// print("[test2/stageb] FAIL: expected 3, got " + ("" + idx))
// return 1
// }
// }
// }