feat(llvm/phi): Phase 277 P1 - fail-fast validation for PHI strict mode

## Summary
Implemented fail-fast validation for PHI ordering and value resolution in strict mode.

## Changes

### P1-1: Strict mode for "PHI after terminator"
- File: `src/llvm_py/phi_wiring/wiring.py::ensure_phi`
- Behavior: `NYASH_LLVM_PHI_STRICT=1` → RuntimeError if PHI created after terminator
- Default: Warning only (no regression)

### P1-2: Strict mode for "fallback 0"
- File: `src/llvm_py/phi_wiring/wiring.py::wire_incomings`
- Behavior: Strict mode forbids silent fallback to 0 (2 locations)
  - Location 1: Unresolvable incoming value
  - Location 2: Type coercion failure
- Error messages point to next debug file: `llvm_builder.py::_value_at_end_i64`

### P1-3: Connect verify_phi_ordering() to execution path
- File: `src/llvm_py/builders/function_lower.py`
- Behavior: Verify PHI ordering after all instructions emitted
- Debug mode: Shows " All N blocks have correct PHI ordering"
- Strict mode: Raises RuntimeError with block list if violations found

## Testing
 Test 1: strict=OFF - passes without errors
 Test 2: strict=ON - passes without errors (no violations in test fixtures)
 Test 3: debug mode - verify_phi_ordering() connected and running

## Scope
- LLVM harness (Python) changes only
- No new environment variables (uses existing 3 from Phase 277 P2)
- No JoinIR/Rust changes (root fix is Phase 279)
- Default behavior unchanged (strict mode opt-in)

## Next Steps
- Phase 278: Remove deprecated env var support
- Phase 279: Root fix - unify "2本のコンパイラ" pipelines

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-22 14:48:37 +09:00
parent 6e749b791e
commit 757193891f
74 changed files with 4178 additions and 575 deletions

View File

@ -1,6 +1,26 @@
# Self Current Task — Now (main)
## 2025-12-22: Phase 277P0/P1— Phase 275/276 残タスク完全実装 ✅
## Current Focus (next)
- Phase 277 P0/P1docs+validation: `docs/development/current/main/phases/phase-277/README.md`
- PHI型推論の導線/責務/SSOT を docs に固定Phase 275/276 の実装を「読める形」にする)
- PHI順序PHI → non-PHI → terminator検証の fail-fast を強化
- Phase 278cleanup: `docs/development/current/main/phases/phase-278/README.md`
- Phase 277 P2 の後方互換旧PHI env varを撤去して、1セットに収束させる
- Phase 279impl: `docs/development/current/main/phases/phase-279/README.md`
- “2本のコンパイラ” にならないように、型伝播パイプラインの入口/順序を SSOT で一本化する
- Phase 273design-first: `docs/development/current/main/30-Backlog.md`
- Pattern を Plan Extractorpureへ降格し、`Plan → Frag → emit_frag()` に収束させる
## Recently Completed (2025-12-22)
- Phase 275 P0A1/B2/C2 coercion SSOT: `docs/development/current/main/phases/phase-275/README.md`
- Phase 276 P0quick wins / type_helper SSOT: `docs/development/current/main/phases/phase-276/README.md`
- Phase 277 P2PHI env var 統合): `docs/development/current/main/phases/phase-277/README.md`
---
## 2025-12-22: Follow-upspost Phase 275/276/277
- 目的: Phase 275/276 で積み残した改善タスクを完全実装デッドコード削除・SSOT使用推進・Void検出
- 達成内容:
@ -19,7 +39,7 @@
-**LLVM Smoke Tests 完全実施**:
- Test 1 (simple Int+Float): ✅ PASS (exit=3, VM/LLVM parity)
- Test 2 (two Int+Float ops): ✅ PASS (exit=3, VM/LLVM parity)
- Test 3 (Float + String): ⚠️ exit=0 (String 問題は Phase 275 範囲外)
- Test 3 (Float + String): C2 では **TypeError** が期待(文字列混在 `+` は禁止)。ここが通るならバグとして扱う
- 効果:
- Float PHI 完全動作VM/LLVM parity 達成)
- SSOT 原則完全適用(型変換・環境変数)
@ -80,9 +100,9 @@
### 過去の Blocker: 型伝播パイプラインの二重化lifecycle vs JoinIR
- 現状、型伝播/PHI 型解決の順序が経路により異なり、同一 fixture が別ルートで壊れ得る(実質 "2本のコンパイラ")。
- 対処SSOT: Phase 276 P0 で型取得ロジックをSSOT化部分対応完了
- Phase 276 本体: type propagation pipeline 完全統一(長期計画)
- 予定: `docs/development/current/main/phases/phase-276/README.md`
- 対処SSOT, short-term: Phase 276 P0 で型取得ロジックをSSOT化部分対応
- 根治SSOT, long-term: Phase 279 で type propagation pipeline の入口/順序を完全統一
- 予定: `docs/development/current/main/phases/phase-279/README.md`
## 2025-12-22Phase 274P1— TypeOpis/asを Rust VM で実行可能にする ✅