Phase 212.5 で発見した「ループ内 if が Pattern 1 に誤ルーティング」問題を修正。 構造ベース if 検出により、単一キャリアの if-update パターンも Pattern 3 へ正しくルーティング可能に。 ## Changes ### 1. AST Feature Extractor (ast_feature_extractor.rs) - **Added**: `detect_if_in_body()` function - Detects ANY if statement in loop body (not just if-else) - Enables structural if detection vs carrier-count heuristic - **Modified**: `extract_features()` - Uses `detect_if_in_body()` for `has_if` detection - Removes dependency on carrier count for if detection ### 2. Loop Pattern Classification (loop_pattern_detection/mod.rs) - **Modified**: `classify()` function - Pattern 3: `carrier_count > 1` → `has_if && carrier_count >= 1` - Pattern 1: `!has_if_else_phi` → `!has_if` - Now routes single-carrier if-update patterns to Pattern 3 ## Verification Test case: `apps/tests/phase212_if_sum_min.hako` ### Before (Phase 212): - ❌ Routed to Pattern 1 (wrong) - ❌ if statement disappeared in MIR - ❌ Carriers: only `i` (sum missing) ### After (Phase 212.5): - ✅ Routed to Pattern 3 (correct!) - ✅ MIR contains PHI nodes: `%31 = phi [%25, bb9], [%29, bb10]` - ✅ Carriers: `i`, `sum`, `count` detected Pattern routing log: ``` [joinir/pattern3] Generated JoinIR for Loop with If-Else PHI [joinir/pattern3] Carriers: i (counter), sum (accumulator), count (counter) ``` ## Known Limitation Pattern 3 lowerer (`lower_loop_with_if_phi_pattern`) is currently a test-only hardcoded implementation: - Loop condition: `i <= 5` (hardcoded) - If condition: `i % 2 == 1` (hardcoded) - Update logic: `sum + i` (hardcoded) This is why `phase212_if_sum_min.hako` produces RC=0 instead of RC=2. Pattern routing is complete; AST-based lowerer generalization is Phase 213. ## Documentation - `docs/development/current/main/phase212-5-implementation-complete.md` - Complete implementation report with verification details 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Nyash Development Documentation 🔧
開発者向けの進行中タスクと開発計画ドキュメントです。
📂 ディレクトリ構造
current/
CURRENT_TASK.md- 現在進行中のタスク- アクティブな開発作業の詳細
- 最新の実装状況
roadmap/
- phases/ - フェーズ別開発計画
- phase-8/ - AST→MIR変換
- phase-9/ - VM/JIT実装
- phase-10/ - AOT最適化
- native-plan/ - ネイティブビルド計画
- 実行バックエンド統合
- パフォーマンス目標
proposals/
- RFC(Request for Comments)
- 新機能提案
- 設計ディスカッション
🎯 重要な参照先
- 進行状況:
current/CURRENT_TASK.md - 開発計画:
roadmap/phases/ - 技術提案:
proposals/
📝 注意事項
このディレクトリの内容は開発中であり、頻繁に変更されます。
安定した仕様はreference/を参照してください。