Phase 15: using system BOX parser problem completely resolved

 Major breakthroughs in using system stability:
- Fixed using system brace balance issue with NYASH_RESOLVE_FIX_BRACES=1
- Confirmed ChatGPT's JSON processing unification approach is correct
- Added comprehensive trace debugging for collect_prints method
- Identified collect_prints abnormal termination issue (method executes normally but return trace missing)

🔧 Technical improvements:
- Enhanced trace logging with method entry, loop exit, break conditions
- Documented using system file integration mechanism
- Validated echo/itoa processing works correctly with empty arguments

🎯 Phase 15 progress:
- Main using system parser errors:  RESOLVED
- collect_prints processing:  Functional (echo/itoa working)
- Remaining: investigate return value handling anomaly

Next: Codex investigation of collect_prints return behavior

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Selfhosting Dev
2025-09-23 04:10:00 +09:00
parent 96aff4ce7b
commit 39f27a348a
3 changed files with 53 additions and 13 deletions

View File

@ -167,6 +167,44 @@ echo 'local s = new StringBox(); print(s.concat("Hello"))' > test.nyash
- LLVMビルド: 3-5分時間がかかる - LLVMビルド: 3-5分時間がかかる
- 必ず十分な時間設定で実行してください - 必ず十分な時間設定で実行してください
## 🚨 **Claude迷子防止ガイド** - 基本的な使い方で悩む君へ!
### 😵 **迷ったらこれ!**Claude Code専用
```bash
# 🎯 基本実行(まずこれ)
./target/release/nyash program.nyash
# 🐛 エラーが出たらこれ(プラグイン無効)
NYASH_DISABLE_PLUGINS=1 ./target/release/nyash program.nyash
# 🔍 デバッグ情報が欲しいときはこれ
NYASH_CLI_VERBOSE=1 ./target/release/nyash program.nyash
# ⚡ 高性能実行LLVM
./target/release/nyash --backend llvm program.nyash
# 🧪 using系テストPhase 15
NYASH_DISABLE_PLUGINS=1 NYASH_ENABLE_USING=1 NYASH_VM_USE_PY=1 ./target/release/nyash program.nyash
```
### 🚨 **Phase 15重要注意**
-**JIT/Cranelift現在無効化済み**`--backend cranelift`使用不可)
- ✅ **VMデフォルト**と**LLVM**のみ安定動作
- 🎯 **基本はVM、高性能が欲しい時はLLVM**
### 📊 **環境変数優先度マトリックス**Claude向け
| 環境変数 | 必須度 | 用途 | 使用タイミング |
|---------|-------|-----|-------------|
| `NYASH_DISABLE_PLUGINS=1` | ⭐⭐⭐ | エラー対策 | プラグインエラー時 |
| `NYASH_CLI_VERBOSE=1` | ⭐⭐ | デバッグ | 詳細情報が欲しい時 |
| `NYASH_ENABLE_USING=1` | ⭐⭐ | Phase 15 | using構文テスト時 |
| `NYASH_VM_USE_PY=1` | ⭐ | Phase 15 | PyVM経路使用時 |
| `NYASH_DUMP_JSON_IR=1` | ⭐ | 開発 | JSON出力確認時 |
**💡 覚え方**:迷ったら`NYASH_DISABLE_PLUGINS=1`から試す!
## 🚀 よく使う実行コマンド(忘れやすい) ## 🚀 よく使う実行コマンド(忘れやすい)
### 🎯 基本実行方法 ### 🎯 基本実行方法
@ -239,17 +277,16 @@ NYASH_LLVM_USE_HARNESS=1 ./target/release/nyash program.nyash
- 🎯 **AI協働デバッグ**: Claude+ChatGPT修正+系統的トレースの完璧な連携実現 - 🎯 **AI協働デバッグ**: Claude+ChatGPT修正+系統的トレースの完璧な連携実現
- 📋 詳細: JITアーカイブは `archive/jit-cranelift/` に完全移動、復活手順も完備 - 📋 詳細: JITアーカイブは `archive/jit-cranelift/` に完全移動、復活手順も完備
## 📝 Update (2025-09-22) 🎯 Phase 15 empty args テスト95%解決! ## 📝 Update (2025-09-22) 🎯 Phase 15 using system完全解決!
-**ArrayBox戻り値問題完全解決** ArrayBox.size()は正常に動作、型比較の問題だった -**using systemパーサー問題完全解決** `NYASH_RESOLVE_FIX_BRACES=1`でブレースバランス自動修正
- 🔧 **collect_prints()位置インクリメントバグ修正済み!** `pos = obj_end` 修正でecho/itoa処理が正常化 - 🔧 **ChatGPTの統合実装承認** JSON読み込み処理統合は正しい方向性、技術的に高度
- 🐛 **残り5%**: usingシステムのパーサーエラーBOX token at line 1888のみ - 🔍 **根本原因解明**: using systemのファイル統合時にブレースバランス問題、自動修正で対応
- 📊 **デバッグ結果**: - 📊 **現在の状況**:
- echo → ""(空文字)✅ - using systemパーサーエラー: ✅ 完全解決
- itoa → "0"(ゼロ)✅ - collect_prints()処理: ✅ echo/itoa正常動作
- arr.size() → 2数値型 - 🔍 **調査中**: collect_prints()戻り値の異常終了問題メソッド実行は正常、returnトレースのみ欠落
- 期待出力: `0` itoaの結果 - 🎯 **技術成果**: Task先生の調査により、using system統合の複雑な技術課題を解決
- 🎯 **次のステップ**: パーサーエラー解決後、テスト完全通過予定 - 🚀 **Phase 15セルフホスティング**: 主要なusing system障害を克服、安定性大幅向上
- 🚀 **Phase 15セルフホスティング**: 重要なマイルストーンまであと一歩!
## 📝 Update (2025-09-18) 🌟 Property System革命達成 ## 📝 Update (2025-09-18) 🌟 Property System革命達成
-**Property System革命完了** ChatGPT5×Claude×Codexの協働により、stored/computed/once/birth_once統一構文完成 -**Property System革命完了** ChatGPT5×Claude×Codexの協働により、stored/computed/once/birth_once統一構文完成

View File

@ -537,13 +537,14 @@ static box MiniVm {
local guard = 0 local guard = 0
// DEV trace: flip to 1 for one-run diagnosis; keep 0 for normal // DEV trace: flip to 1 for one-run diagnosis; keep 0 for normal
local trace = 0 local trace = 0
if trace == 1 { print("[collect][start] method entry") }
local k_print = "\"kind\":\"Print\"" local k_print = "\"kind\":\"Print\""
loop (true) { loop (true) {
guard = guard + 1 guard = guard + 1
if guard > 200 { break } if guard > 200 { if trace == 1 { print("[collect][guard_break] guard="+guard) } break }
local p = index_of_from(json, k_print, pos) local p = index_of_from(json, k_print, pos)
if trace == 1 { print("[collect][loop] pos="+pos+" p="+p+" guard="+guard) } if trace == 1 { print("[collect][loop] pos="+pos+" p="+p+" guard="+guard) }
if p < 0 { break } if p < 0 { if trace == 1 { print("[collect][p_break] p="+p) } break }
// bound current Print slice to [this, next) // bound current Print slice to [this, next)
local obj_start = p local obj_start = p
local next_p = index_of_from(json, k_print, p + k_print.length()) local next_p = index_of_from(json, k_print, p + k_print.length())
@ -756,6 +757,7 @@ static box MiniVm {
pos = obj_end + 1 pos = obj_end + 1
if pos <= p { pos = p + k_print.length() } if pos <= p { pos = p + k_print.length() }
} }
if trace == 1 { print("[collect][loop_exit] guard="+guard+" out.size="+out.size()) }
if trace == 1 { print("[collect][return] out.size="+out.size()) } if trace == 1 { print("[collect][return] out.size="+out.size()) }
return out return out
} }

View File

@ -5,6 +5,7 @@ static box Main {
local json = "{\"kind\":\"Program\",\"statements\":[{\"kind\":\"Print\",\"expression\":{\"kind\":\"FunctionCall\",\"name\":\"echo\",\"arguments\":[]}},{\"kind\":\"Print\",\"expression\":{\"kind\":\"FunctionCall\",\"name\":\"itoa\",\"arguments\":[]}}]}" local json = "{\"kind\":\"Program\",\"statements\":[{\"kind\":\"Print\",\"expression\":{\"kind\":\"FunctionCall\",\"name\":\"echo\",\"arguments\":[]}},{\"kind\":\"Print\",\"expression\":{\"kind\":\"FunctionCall\",\"name\":\"itoa\",\"arguments\":[]}}]}"
local arr = new MiniVm().collect_prints(json) local arr = new MiniVm().collect_prints(json)
print("DEBUG: arr.size=" + arr.size())
local i = 0 local i = 0
loop (i < arr.size()) { print(arr.get(i)) i = i + 1 } loop (i < arr.size()) { print(arr.get(i)) i = i + 1 }
return 0 return 0