docs: Phase 117 DONE

Phase 117: if-only nested-if + call merge parity completed.

**Documentation**:
- docs/development/current/main/phases/phase-117/README.md (complete)
- docs/development/current/main/10-Now.md (updated with Phase 117 entry)
- docs/development/current/main/01-JoinIR-Selfhost-INDEX.md (added Phase 117 to index)

**Phase 117 Summary**:
- Verified nested if-only (inner if + outer else) with call merge
- Pattern: 3 call sites (f(1), f(2), f(3)) merge to single variable
- VM/LLVM EXE parity: both produce identical output "2\n3\n4"
- Regression: Phase 116 maintained

**Technical Details**:
- JoinIR Pattern3 (if-only) nested structure validation
- Call merge across nested control flow
- PHI node generation for nested branches
- LLVM EXE plugin integration (StringBox, IntegerBox, ConsoleBox)

**Next Steps**:
Phase 118+ will address more complex nested patterns (if-else nested, loop-if combinations).

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-18 02:55:14 +09:00
parent bc561682f6
commit 2c7f5f7a5e
3 changed files with 95 additions and 6 deletions

View File

@ -70,17 +70,19 @@ JoinIR の箱構造と責務、ループ/if の lowering パターンを把握
- `docs/development/current/main/phases/phase-115/README.md` - `docs/development/current/main/phases/phase-115/README.md`
18. Phase 116: if-only keep+call merge parity片側元値保持、片側 call merge 18. Phase 116: if-only keep+call merge parity片側元値保持、片側 call merge
- `docs/development/current/main/phases/phase-116/README.md` - `docs/development/current/main/phases/phase-116/README.md`
19. Phase 104: loop(true) break-only digitsVM + LLVM EXE 19. Phase 117: if-only nested-if + call merge parityネストif + call merge
- `docs/development/current/main/phases/phase-117/README.md`
20. Phase 104: loop(true) break-only digitsVM + LLVM EXE
- `docs/development/current/main/phases/phase-104/README.md` - `docs/development/current/main/phases/phase-104/README.md`
20. Phase 107: json_cur find_balanced_* depth scanVM + LLVM EXE 21. Phase 107: json_cur find_balanced_* depth scanVM + LLVM EXE
- `docs/development/current/main/phases/phase-107/README.md` - `docs/development/current/main/phases/phase-107/README.md`
21. Phase 108: Pattern2 policy router SSOT入口の薄さを固定 22. Phase 108: Pattern2 policy router SSOT入口の薄さを固定
- `docs/development/current/main/phases/phase-108/README.md` - `docs/development/current/main/phases/phase-108/README.md`
22. Phase 109: error_tags hints SSOTFail-Fast + hint の語彙固定) 23. Phase 109: error_tags hints SSOTFail-Fast + hint の語彙固定)
- `docs/development/current/main/phases/phase-109/README.md` - `docs/development/current/main/phases/phase-109/README.md`
23. MIR BuilderContext 分割の入口) 24. MIR BuilderContext 分割の入口)
- `src/mir/builder/README.md` - `src/mir/builder/README.md`
24. Scope/BindingIdshadowing・束縛同一性の段階移行 25. Scope/BindingIdshadowing・束縛同一性の段階移行
- `docs/development/current/main/phase73-scope-manager-design.md` - `docs/development/current/main/phase73-scope-manager-design.md`
- `docs/development/current/main/PHASE_74_SUMMARY.md` - `docs/development/current/main/PHASE_74_SUMMARY.md`
- `docs/development/current/main/PHASE_75_SUMMARY.md` - `docs/development/current/main/PHASE_75_SUMMARY.md`

View File

@ -1,5 +1,14 @@
# Self Current Task — Now (main) # Self Current Task — Now (main)
## 2025-12-18Phase 117 完了 ✅
**Phase 117: if-only nested-if + call merge parity**
- ネストしたif-only内側if + 外側elseで call 結果 merge を VM/LLVM で固定
- Fixture: phase117_if_only_nested_if_call_merge_min.hako (expected: 2, 3, 4)
- Smoke: VM + LLVM EXE parity 検証済み
- 回帰: Phase 116 維持確認
- 入口: `docs/development/current/main/phases/phase-117/README.md`
## 2025-12-18Phase 116 完了 ✅ ## 2025-12-18Phase 116 完了 ✅
**Phase 116: if-only keep+call merge parity** **Phase 116: if-only keep+call merge parity**

View File

@ -0,0 +1,78 @@
# Phase 117: if-only nested-if + call merge parity
**Status**: ✅ DONE (2025-12-18)
## 背景
Phase 116で「keep + call merge」を固定した後、**ネストされたif内部でのcall merge**が正しく動作するか検証が必要。
特に以下のパターンを検証:
- 外側if (a == 1) の中に内側if (b == 1)
- 内側if の両分岐で異なる引数でf()を呼び出し
- 外側else でも別引数でf()を呼び出し
- すべてのcall結果をvに集約してprint
これはJoinIR Pattern3if-only+ call mergeの**ネスト版**であり、VM/LLVM EXE両方で同じ動作をすることが品質保証の要件。
## 実装
### Fixture
- **ファイル**: `apps/tests/phase117_if_only_nested_if_call_merge_min.hako`
- **構造**: static box Main パターン
- `f(x)`: 単純な関数x + 1を返す
- `g(a, b)`: ネストif + call merge
- a == 1 かつ b == 1 → f(1) → 2
- a == 1 かつ b != 1 → f(2) → 3
- a != 1 → f(3) → 4
- `main()`: 3パターンを順次実行
- **期待出力**: `2\n3\n4`
### VM Smoke Test
- **ファイル**: `tools/smokes/v2/profiles/integration/apps/phase117_if_only_nested_if_call_merge_vm.sh`
- **実行条件**: `NYASH_DISABLE_PLUGINS=1 HAKO_JOINIR_STRICT=1`
- **検証**: `validate_numeric_output 3 "2\n3\n4"`
### LLVM EXE Smoke Test
- **ファイル**: `tools/smokes/v2/profiles/integration/apps/phase117_if_only_nested_if_call_merge_llvm_exe.sh`
- **Required plugins**: FileBox, MapBox, StringBox, ConsoleBox, IntegerBox (Phase 115/116と同じ)
- **検証**: numeric output `2\n3\n4` (3 lines)
## 検証コマンド
```bash
# VM smoke test
bash tools/smokes/v2/profiles/integration/apps/phase117_if_only_nested_if_call_merge_vm.sh
# LLVM EXE smoke test
bash tools/smokes/v2/profiles/integration/apps/phase117_if_only_nested_if_call_merge_llvm_exe.sh
# 回帰確認Phase 116
bash tools/smokes/v2/profiles/integration/apps/phase116_if_only_keep_plus_call_llvm_exe.sh
```
## 技術的詳細
### JoinIR Pattern3if-onlyのネスト
- **外側if**: a == 1 の分岐
- **内側if**: b == 1 の分岐外側then内部にネスト
- **Call merge**: 3箇所のf()呼び出しが最終的に1つのvに集約
### MIR生成の観点
- ネストしたif-onlyが正しくPattern3として認識される
- 各分岐でのcall命令が適切にマージされる
- PHI nodeが正しく生成されるネスト構造を反映
### LLVM EXE固有の検証ポイント
- プラグインStringBox, IntegerBox, ConsoleBoxの正しいリンク
- ネストしたcall mergeのLLVM IR生成
- 実行時のメモリ安全性segfault無し
## 成果
✅ VM/LLVM EXE両方でparity達成
✅ ネストif + call mergeパターンの品質固定
✅ Phase 115/116の退行なし
## Next Steps
Phase 118以降でさらに複雑なネストパターンif-else nested, loop内if等を段階的に固定していく。