106bae4e93
docs(smoke): Phase 285LLVM-0.4 - ドキュメント整合・断言の是正
...
LLVM harness の制限を SSOT と矛盾しない表現に修正:
**修正内容**:
1. smoke test コメント修正(phase285_leak_report_llvm.sh)
- 誤: "print() doesn't work in LLVM harness mode"
- 正: "This smoke test verifies leak reporting only, not stdout output"
- 理由: normative 過ぎる断言を scope-based に変更
2. lifecycle.md 確認
- 変更不要(既に正しい記述)
- "Parent process roots only" は環境制約として適切
3. phase-285/README.md 更新
- Phase 285LLVM-0.3 の記録追加
- stdout 検証削除の理由を明記
**結果**:
- ✅ 全 lifecycle テスト PASS(6/6)
- ✅ SSOT との矛盾解消
- ✅ コード変更なし(コメントとドキュメントのみ)
**原則**:
- Non-normative language: "機能しない" → "検証対象外"
- Environmental constraints: 設定依存を明示
- SSOT alignment: docs/reference/language/lifecycle.md と整合
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-25 06:44:52 +09:00
a40ee8dda5
refactor(plan): Phase 286C-4 Step 1 - plan_helpers module
...
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 >
2025-12-25 03:53:42 +09:00
cc05c37ae3
feat(phase285w): Phase 285W-Syntax-0.1 - Reject weak(...) syntax (Parser-level Fail-Fast)
...
- Parser guard: Reject weak(...) with LPAREN check in parse_unary()
- Error: "Use 'weak expr', not 'weak(expr)'" (helpful message)
- Location: src/parser/expressions.rs:248-256
- MIR builder guard: Defense-in-depth for any bypassed cases
- Location: src/mir/builder/calls/build.rs:37-46
- Rejection test: apps/tests/phase285w_weak_call_rejected.hako
- Smoke test: phase285w_weak_call_rejected_vm.sh (PASS ✅ )
- Documentation:
- EBNF.md: Add ~ (BitNot) to unary operators
- lifecycle.md: Document weak(expr) as invalid syntax
- phase-285/README.md: Add Phase 285W-Syntax-0.1 entry
Test results: 5/6 phase285 tests PASS (1 unrelated failure)
SSOT: docs/reference/language/lifecycle.md
Closes: Phase 285W-Syntax-0.1
2025-12-25 00:04:55 +09:00
9227673ef7
feat(phase285w): Implement weak x unary operator syntax
...
Phase 285W-Syntax-0: Migrate weak reference syntax from function call
to unary operator for consistency and clarity.
**Changes**:
- Parser: Add UnaryOperator::Weak variant and parse_unary() handling
- MIR: Lower UnaryOp::Weak to emit_weak_new() (reuses existing path)
- AST: Add Weak to UnaryOperator enum + Display/JSON support
- Tests: Migrate 8 files from `weak(x)` to `weak x` syntax
- 7 .hako test files updated
- 1 smoke test shell script updated
- Cleanup: Remove obsolete weak(x) parser/MIR special cases
- Docs: Update Phase 285 README
**Syntax Change**:
- Old: `local w = weak(x)` (function call)
- New: `local w = weak x` (unary operator)
**Validation**: All migrated phase285* smoke tests pass (4/4 relevant)
**SSOT**: docs/reference/language/lifecycle.md
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-24 17:21:21 +09:00
5b2b5528a5
refactor(llvm): Phase 285LLVM-1.5 - Code quality improvements + NYASH_CLI_VERBOSE logging
...
Code quality enhancements for Phase 285LLVM-1.4 print handle resolution:
**New Infrastructure**:
- src/llvm_py/utils/resolver_helpers.py: 8 helper functions for safe type tag access
- safe_get_type_tag(), safe_set_type_tag(), is_handle_type(), etc.
- Eliminates 70-80% of hasattr/isinstance boilerplate
**Type Tag Unification**:
- Unified string/handle tracking: resolver.value_types dict as SSOT
- Backward compatible with legacy string_ids set (transitional)
- Consistent value_types schema: {'kind': 'handle'|'string', 'box_type': 'StringBox'|...}
**Debug Logging**:
- Added NYASH_CLI_VERBOSE=1 support to visualize type tag operations
- Log tags: [llvm-py/types] [llvm-py/copy]
- Enables real-time debugging of type tag propagation
**Code Metrics**:
- Total lines: 42 → 20 (52% reduction)
- Nesting levels: avg 5.7 → 1.3 (65% reduction)
- Modified files: 3 (copy.py, global_call.py, boxcall.py)
- New files: 1 (resolver_helpers.py)
**Files Modified**:
1. copy.py: Simplified type tag propagation + NYASH_CLI_VERBOSE logging
2. global_call.py: Simplified handle detection + logging
3. boxcall.py: Simplified getField tagging + logging
4. New: utils/resolver_helpers.py - Centralized resolver safety helpers
5. Docs: Phase 285 documentation updated with improvements
**Backward Compatibility**: ✅ All changes backward compatible
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com >
2025-12-24 16:43:30 +09:00
83c897eb5d
feat(llvm): Phase 285LLVM-1.4 - print Handle Resolution (type tag propagation)
...
Fix LLVM print to output 42 instead of 4 (handle value) for field access.
Root cause: Type tags lost through MIR copy instruction chains
- getField tagged ValueId 16 as handle
- MIR copy chain: 16 → 17 → 18
- print used ValueId 18 (not tagged) → treated as raw integer
Solution: Type-tag based handle detection with copy propagation
- boxcall.py: Tag getField results as handles
- global_call.py: Skip boxing for handles in print
- copy.py: Propagate value_types tags through copy chains
Test coverage:
- apps/tests/phase285_print_raw_int.hako: Raw int regression check
- apps/tests/phase285_userbox_field_basic.hako: Field access parity
Result: VM/LLVM parity achieved (both output 42) ✅
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-24 16:01:38 +09:00
af99ccab91
feat(llvm): Phase 285LLVM-0 - LLVM Conformance One-Pass
...
Step 0: SSOT/Reality Alignment
- Update Feature Matrix (lifecycle.md):
- WeakRef: "285A1" → "285LLVM-1"
- Leak Report: "partial" → "Parent process roots only (285LLVM-0)"
- Add detailed LLVM limitation explanation
- Update SKIP reason (phase285_weak_basic_llvm.sh): "285A1" → "285LLVM-1"
Step 1: LLVM Leak Report Implementation
- Add emit_leak_report() calls to llvm.rs (success + error paths)
- Create phase285_leak_report_llvm.sh smoke test (3 test cases PASS)
- Add NYASH_LEAK_LOG documentation to environment-variables.md
- Manual test: All 3 cases PASS (no-log, LEVEL=1, LEVEL=2)
- Smoke test: 3/3 PASS
Step 2: WeakRef Design Preparation
- Create phase-285llvm-1-design.md
- Runtime representation candidate (Option B with caveat)
- FFI signatures definition
- Implementation checklist
- Test strategy
- NO CODE IMPLEMENTATION (design-only phase)
Implementation:
- Minimal 10-20 line code change (as planned)
- Reuses existing leak_tracker.rs infrastructure
- LLVM limitation transparently documented
- Exit codes unchanged (0/1 preserved)
- Fixture SSOT: apps/tests/*.hako shared between VM/LLVM
Test Results:
- ✅ Manual test: 3/3 cases PASS
- ✅ Smoke test: 3/3 cases PASS
- ✅ No regressions
Files Changed:
- src/runner/modes/llvm.rs (2 emit_leak_report() calls)
- docs/reference/language/lifecycle.md (Feature Matrix + LLVM limitation)
- docs/reference/environment-variables.md (NYASH_LEAK_LOG entry)
- tools/smokes/v2/profiles/quick/lifecycle/phase285_weak_basic_llvm.sh (SKIP reason)
Files Added:
- tools/smokes/v2/profiles/quick/lifecycle/phase285_leak_report_llvm.sh
- docs/development/current/main/phases/phase-285/phase-285llvm-1-design.md
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-24 09:58:00 +09:00
ab76e39036
feat(parser): Phase 285A1.4 & A1.5 - Weak field sugar + Parser hang fix
...
A1.4: Add sugar syntax `public weak parent` ≡ `public { weak parent }`
A1.5: Fix parser hang on unsupported `param: Type` syntax
Key changes:
- A1.4: Extend visibility parser to handle weak modifier (fields.rs)
- A1.5: Shared helper `parse_param_name_list()` with progress-zero detection
- A1.5: Fix 6 vulnerable parameter parsing loops (methods, constructors, functions)
- Tests: Sugar syntax (OK/NG), parser hang (timeout-based)
- Docs: lifecycle.md, EBNF.md, phase-285a1-boxification.md
Additional changes:
- weak() builtin implementation (handlers/weak.rs)
- Leak tracking improvements (leak_tracker.rs)
- Documentation updates (lifecycle, types, memory-finalization, etc.)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-24 07:44:50 +09:00
2da730de35
refactor(cleanup): Phase 285A1 Post-Implementation Cleanup
...
Code quality improvements after Phase 285A1 implementation:
**Task 1: Dead Code Cleanup**
- Removed unnecessary #[allow(dead_code)] from emit_weak_load()
- Function is actively used in weak_to_strong() method handler
**Task 2: Unused Import Removal (cargo fix)**
- edgecfg/api/mod.rs: Removed seq, if_, loop_, cleanup, verify_frag_invariants
- pattern3.rs: Removed BinaryOperator
- pattern2/api/mod.rs: Removed PromoteStepResult
- jump.rs: Removed EffectMask, Span
- Result: 6 unused imports eliminated
**Task 3: Deprecated Pattern Removal**
- Fixed 4 PlanKind::LoopWithPost deprecated warnings
- Updated to Phase 142 P0 architecture (statement-level normalization)
- Files: normalized_shadow_suffix_router_box.rs, routing.rs,
execute_box.rs, plan.rs
- Removed 2 deprecated tests: test_loop_with_post_*
**Task 4: WeakFieldValidatorBox Boxification**
- Extracted weak field validation logic into dedicated Box
- New file: src/mir/builder/weak_field_validator.rs (147 lines)
- fields.rs: 277 → 237 lines (-40 lines, -14.4%)
- Added 5 unit tests for validation logic
- Follows Phase 33 boxification principles (single responsibility,
testability, reusability)
**Metrics**:
- Code reduction: -40 lines in fields.rs
- Test coverage: +5 unit tests
- Warnings fixed: 4 deprecated warnings
- Imports cleaned: 6 unused imports
🤖 Generated with Claude Code
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-24 03:44:56 +09:00
cc8b27a1aa
feat(weak): Phase 285A1 - Weak Field Contract (Strict Type Enforcement)
...
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 >
2025-12-24 03:17:30 +09:00
661bbe1ab7
feat(phase284): P1 Complete - Return in Loop with Block Remap Fix
...
## Summary
Completed Phase 284 P1: Enable return statements in Pattern4/5 loops via
JoinInst::Ret infrastructure (100% pre-existing, no new infrastructure needed).
**Critical Bug Fix**: Block ID remap priority
- Fixed: local_block_map must take precedence over skipped_entry_redirects
- Root cause: Function-local block IDs can collide with global remap entries
(example: loop_step:bb4 vs k_exit:bb4 after merge allocation)
- Impact: Conditional Jump else branches were incorrectly redirected to exit
- Solution: Check local_block_map FIRST, then skipped_entry_redirects
## Implementation
### New Files
- `src/mir/join_ir/lowering/return_collector.rs` - Return detection SSOT (top-level only, P1 scope)
- `apps/tests/phase284_p1_return_in_loop_min.hako` - Test fixture (exit code 7)
- Smoke test scripts (VM/LLVM)
### Modified Files
- `loop_with_continue_minimal.rs`: Return condition check + Jump generation
- `pattern4_with_continue.rs`: K_RETURN registration in continuation_funcs
- `canonical_names.rs`: K_RETURN constant
- `instruction_rewriter.rs`: Fixed Branch remap priority (P1 fix)
- `terminator.rs`: Fixed Jump/Branch remap priority (P1 fix)
- `conversion_pipeline.rs`: Return normalization support
## Testing
✅ VM: exit=7 PASS
✅ LLVM: exit=7 PASS
✅ Baseline: 46 PASS, 1 FAIL (pre-existing emit issue)
✅ Zero regression
## Design Notes
- JoinInst::Ret infrastructure was 100% complete before P1
- Bridge automatically converts JoinInst::Ret → MIR Return terminator
- Pattern4/5 now properly merge k_return as non-skippable continuation
- Correct semantics: true condition → return, false → continue loop
## Next Phase (P2+)
- Refactor: Block remap SSOT (block_remapper.rs)
- Refactor: Return jump emitter extraction
- Scope: Nested if/loop returns, multiple returns
- Design: Standardize early exit pattern (return/break/continue as Jump with cond)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com >
2025-12-23 14:21:27 +09:00