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:
@ -40,21 +40,18 @@ Semicolons and ASI (Automatic Semicolon Insertion)
|
||||
- Ambiguous continuations; parser must Fail‑Fast with a clear message.
|
||||
|
||||
Truthiness (boolean context)
|
||||
- `Bool` → itself
|
||||
- `Integer` → `0` is false; non‑zero is true
|
||||
- `String` → empty string is false; otherwise true
|
||||
- `Array`/`Map` → non‑null is true (size is not consulted)
|
||||
- `null`/`void` → false
|
||||
- SSOT: `reference/language/types.md`(runtime truthiness)
|
||||
- 実行上は `Bool/Integer/Float/String/Void` が中心。`BoxRef` は一部のコアBoxのみ許可され、その他は `TypeError`(Fail-Fast)。
|
||||
|
||||
Equality and Comparison
|
||||
- `==` and `!=` compare primitive values (Integer/Bool/String). No implicit cross‑type coercion.
|
||||
- Box/Instance comparisons should use explicit methods (`equals`), or be normalized by the builder.
|
||||
- Compare operators `< <= > >=` are defined on integers (MVP).
|
||||
- SSOT: `reference/language/types.md`(`==`/`!=` と `< <= > >=` の runtime 仕様)
|
||||
- `==` は一部の cross-kind(`Integer↔Bool`, `Integer↔Float`)を best-effort で扱う。その他は `false`。
|
||||
- `< <= > >=` は `Integer/Float/String` の **同型同士**のみ(異型は `TypeError`)。
|
||||
|
||||
String and Numeric `+`
|
||||
- If either side is `String`, `+` is string concatenation.
|
||||
- If both sides are numeric, `+` is addition.
|
||||
- Other mixes are errors (dev: warn; prod: error) — keep it explicit(必要なら `str(x)` を使う)。
|
||||
- SSOT: `reference/language/types.md`(runtime `+` 仕様)
|
||||
- `Integer+Integer`, `Float+Float` は加算。片側が `String` なら文字列連結(相手は文字列化)。
|
||||
- それ以外(例: `Integer+Bool`, `Integer+Float`)は `TypeError`(Fail-Fast)。
|
||||
|
||||
Blocks and Control
|
||||
- `if (cond) { ... } [else { ... }]`
|
||||
|
||||
Reference in New Issue
Block a user