Fixes phantom carrier detection that blocked AST-based if-sum lowerer.
## Problem
Name-based heuristic in loop_update_summary.rs created phantom "count"
carrier even when variable didn't exist, causing:
1. counter_count() = 2 (i + phantom "count") instead of 1
2. is_simple_if_sum_pattern() = false
3. AST-based lowerer never activates (falls back to legacy)
4. Result: RC=0 instead of expected values
## Solution
Assignment-based carrier detection:
### New API (recommended)
```rust
pub fn analyze_loop_updates_from_ast(
loop_body_ast: &[ASTNode]
) -> LoopUpdateSummary
```
- Extracts only variables with actual assignments in loop body
- Classifies by RHS structure (not name)
- Eliminates phantom carriers completely
### Changes
1. **Added**: `extract_assigned_variables()` - AST walker for assignments
2. **Added**: `find_assignment_rhs()` - RHS expression extraction
3. **Added**: `classify_update_kind_from_rhs()` - Structure-based classification
4. **Added**: `is_likely_loop_index()` - Name heuristic for disambiguation
5. **Deprecated**: `analyze_loop_updates()` - Legacy name-based API (3 call sites remain)
### Verification
Before:
```
variable_map = {i, sum, defs, len}
→ Phantom "count" detected
→ counter_count() = 2
→ is_simple_if_sum_pattern() = false
```
After:
```
assigned_vars = {i, sum} // Only assigned!
→ No phantom carriers
→ counter_count() = 1
→ accumulation_count() = 1
→ is_simple_if_sum_pattern() = true ✅
```
## Files Modified
**Core Fix**:
- src/mir/join_ir/lowering/loop_update_summary.rs (+116 lines)
- New assignment-based API
- Phantom carrier elimination
**Integration**:
- src/mir/builder/control_flow/joinir/patterns/pattern_pipeline.rs (+3 lines)
- Updated is_if_sum_pattern() to use new API
## Test Results
- ✅ Phantom carrier bug fixed
- ✅ AST lowerer activates correctly
- ⚠️ 3 deprecation warnings (expected, legacy call sites)
- ⏳ phase212/218 still RC=0 (blocked by condition variable support)
## Design Principles
1. **No Phantom Carriers**: Only variables with actual assignments
2. **Assignment-Based Detection**: LHS from AST assignments only
3. **Structure-Based Classification**: RHS patterns + name disambiguation
## Next Steps
Phase 220: Condition variable extraction and wiring to enable
phase212/218 tests to pass with correct RC values.
🤖 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/を参照してください。