Updated implementation status to reflect actual working features:
- ✅ print() output displays
- ✅ .reset command works
- ✅ Implicit local binding compiles
- ⏳ Variable persistence (deferred to Phase 288.1+)
Known limitations documented:
- Variable access across lines not yet working
- _ variable stored but not accessible yet
- Expression auto-display deferred
Accurate current behavior examples added.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Root cause: toString/stringify/str were being rewritten to Global/Method calls
with class inference, causing Main.toString/0 to be called for primitives.
Fix (Box-First + Legacy Deletion):
1. ✅ MIR Builder - toString normalization (special.rs)
- ALWAYS emit BoxCall with method_id=0 for toString/stringify/str
- Do NOT rewrite to Global(Class.str/0) or Method calls
- DELETED 70+ lines of complex class inference logic
- Primitive guard with method name filter (known.rs)
2. ✅ JSON Serializer - method_id output (mir_json_emit.rs)
- Include method_id field in BoxCall JSON for LLVM
3. ✅ LLVM Backend - universal slot #0 support
- Extract method_id from JSON (instruction_lower.py)
- Box primitives via nyash.box.from_i64 (boxcall.py)
- Invoke toString via plugin system with method_id=0
- ⚠️ TODO: Add nyash.integer.tostring_h to kernel
Test Results:
✅ VM: local x = 1; print(x.toString()) → "1" (PASS)
✅ VM: array_length test (boxed Integer) → PASS
⚠️ LLVM: Compiles successfully, needs kernel function
SSOT: slot_registry - toString is ALWAYS universal slot #0
Legacy Deleted:
- special.rs: Complex class inference rewrite (~70 lines)
- special.rs: Unique suffix fallback for toString
- special.rs: Main box special handling
Files changed:
- src/mir/builder/rewrite/special.rs (try_early_str_like_to_dst)
- src/mir/builder/rewrite/known.rs (primitive guards x4)
- src/runner/mir_json_emit.rs (method_id serialization x2)
- src/llvm_py/builders/instruction_lower.py (method_id extraction)
- src/llvm_py/instructions/boxcall.py (slot #0 handler)
- docs/reference/language/quick-reference.md (toString SSOT)
🎊 Generated with Claude Code
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Create helper functions to support plan_rewrites() extraction:
- build_local_block_map(): Build block ID mapping for a function
- sync_spans(): Synchronize instruction spans after rewriting
These pure functions will be used by both the current monolithic
merge_and_rewrite() and the new plan_rewrites() function.
Progress: Step 1/4 (helpers) complete
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Goal: Prevent regression where deprecated env vars warn even when unset
Changes:
- tools/smokes/v2/profiles/quick/env/phase286_deprecated_env_warnings.sh
* Test Case 1: Unset env → No warnings (防止: 未設定で警告)
* Test Case 2: NYASH_MACRO_TOPLEVEL_ALLOW=1 → Warning expected
* Test Case 3: NYASH_MACRO_BOX_CHILD_RUNNER=1 → Warning expected
* Uses env -u to truly unset variables (empty string counts as "set")
- docs/reference/environment-variables.md
* Added "Deprecated 警告動作 (Phase 286A)" section
* Clarified: warnings only appear when env var is explicitly set
* Warning format: [macro][compat] <変数名> is deprecated; <推奨アクション>
Test Results:
✅ All 3 test cases pass
✅ Quick smoke: 45/46 tests pass (1 known failure unrelated)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Remove automatic WeakNew conversion and enforce strict compile-time type
checking for weak field assignments. Only 3 assignment types allowed:
1. Result of weak(x) call (WeakRef type)
2. Existing WeakRef variable (e.g., me.parent = other.parent)
3. Void/null (clear operation)
**Implementation**:
- Added MirType::WeakRef to type system (src/mir/types.rs)
- Track WeakRef type in emit_weak_new() even in pure mode
- Weak field reads return WeakRef without auto-upgrade
- Removed automatic WeakNew conversion from field writes
- Implemented check_weak_field_assignment() with actionable errors
- Fixed null literal type tracking (Phase 285A1.1: Unknown → Void)
**Testing**:
- 5 test fixtures (3 OK, 2 NG cases) - all passing
- Smoke test: phase285_weak_field_vm.sh
- Error messages guide users to use weak() or null
**Documentation**:
- Updated lifecycle.md SSOT with weak field contract
🤖 Generated with Claude Code
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
## 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>
- Fix: Call with Callee::Method now includes receiver in used_values()
- Prevents DCE from eliminating Copy instructions that define receivers
- Pattern 3 (loop_if_phi.hako) now works correctly (sum=9)
- Add: NYASH_DCE_TRACE=1 for debugging eliminated instructions
- Shows which pure instructions DCE removes and from which block
- Cleanup: Consolidate Call used_values to single source of truth
- Early return in methods.rs handles all Call variants
- Removed duplicate match arm (now unreachable!())
- ChatGPT's suggestion for cleaner architecture
- Docs: Phase 166 analysis of inst_meta layer architecture
- Identified CSE pass callee bug (to be fixed next)
- Improvement proposals for CallLikeInst
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Remove src/config/env/hako_check.rs entirely (file deleted)
- Comment out hako_check module in src/config/env.rs with Phase 124 markers
- Mark NYASH_HAKO_CHECK_JOINIR as deleted in environment-variables.md
- Document reason: JoinIR-only consolidation makes flag unnecessary
Phase 124 Task 2/5 complete
Add NYASH_CLI_VERBOSE>=2 observation logs to trace the Ny compiler
child process path (NYASH_USE_NY_COMPILER=1):
- Log when spawning child process
- Log when receiving Program(JSON v0)
- Log before/after maybe_dump_mir with dump path info
- Report whether MIR dump file was created
Key finding: apps/selfhost/compiler/compiler.hako doesn't exist,
so the preferred child process route never fires. This explains
why RUST_MIR_DUMP_PATH doesn't create files in Ny compiler path.
Also update environment-variables.md with:
- NYASH_CLI_VERBOSE=2 level documentation
- Ny compiler observation template for Phase 29
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Root Cause:
- Else blocks were not propagating variable assignments to outer scope
- Bug 1 (if_form.rs): PHI materialization happened before variable_map reset,
causing PHI nodes to be lost
- Bug 2 (phi.rs): Variable merge didn't check if else branch modified variables
Changes:
- src/mir/builder/if_form.rs:93-127
- Reordered: reset variable_map BEFORE materializing PHI nodes
- Now matches then-branch pattern (reset → materialize → execute)
- Applied to both "else" and "no else" branches for consistency
- src/mir/builder/phi.rs:137-154
- Added else_modified_var check to detect variable modifications
- Use modified value from else_var_map_end_opt when available
- Fall back to pre-if value only when truly not modified
Test Results:
✅ Simple block: { x=42 } → 42
✅ If block: if 1 { x=42 } → 42
✅ Else block: if 0 { x=99 } else { x=42 } → 42 (FIXED!)
✅ Stage-B body extraction: "return 42" correctly extracted (was null)
Impact:
- Else block variable assignments now work correctly
- Stage-B compiler body extraction restored
- Selfhost builder path can now function
- Foundation for Phase 21.x progress
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Unify standard method calls to emit_unified_call; route via RouterPolicy and apply rewrite::{special,known} at a single entry.\n- Stabilize emit-time invariants: LocalSSA finalize + BlockSchedule PHI→Copy→Call ordering; metadata propagation on copies.\n- Known rewrite default ON (userbox only, strict guards) with opt-out flag NYASH_REWRITE_KNOWN_DEFAULT=0.\n- Expand TypeAnnotation whitelist (is_digit_char/is_hex_digit_char/is_alpha_char/Map.has).\n- Docs: unified-method-resolution design note; Quick Reference normalization note; selfhosting/quickstart.\n- Tools: add tools/selfhost_smoke.sh (dev-only).\n- Keep behavior unchanged for Unknown/core/user-instance via BoxCall fallback; all tests green (quick/integration).
- Fix condition_fn resolution: Value call path + dev safety + stub injection
- VM bridge: handle Method::birth via BoxCall; ArrayBox push/get/length/set direct bridge
- Receiver safety: pin receiver in method_call_handlers to avoid undefined use across blocks
- Local vars: materialize on declaration (use init ValueId; void for uninit)
- Prefer legacy BoxCall for Array/Map/String/user boxes in emit_box_or_plugin_call (stability-first)
- Test runner: update LLVM hint to llvmlite harness (remove LLVM_SYS_180_PREFIX guidance)
- Docs/roadmap: update CURRENT_TASK with unified default-ON + guards
Note: NYASH_DEV_BIRTH_INJECT_BUILTINS=1 can re-enable builtin birth() injection during migration.