refactor(joinir): Phase 78 Quick Wins - PromotedBindingRecorder Box

**Quick Win 1: PromotedBindingRecorder Box Introduction**

- **New file**: `promoted_binding_recorder.rs` (167 lines)
  - Type-safe BindingId recording for promoted variables
  - Centralizes scattered binding_map wiring logic
  - Result-based error handling (BindingRecordError enum)
  - 4 unit tests (1 always-on + 3 feature-gated)
  - Dual impl blocks for feature gate handling

- **Updated DigitPosPromoter**: `loop_body_digitpos_promoter.rs`
  - Replaced 30-line binding_map wiring with 2-line recorder call
  - Added log_promotion_error() helper function
  - Removed scattered eprintln! warnings

- **Updated TrimLoopHelper**: `loop_body_carrier_promoter.rs`
  - Replaced 30-line binding_map wiring with 2-line recorder call
  - Added log_trim_promotion_error() helper function
  - Updated 4 tests to include binding_map field

**Quick Win 2: Error Handling Improvement**

- Replaced eprintln! with Result-based errors
- Added clear error messages via helper functions
- Both promoters now use same error logging pattern
- Testable error paths (3 error tests added)

**Impact**:
- **Code reduction**: ~30 lines deleted (duplicated wiring logic)
- **Maintainability**: Single reusable Box for future promoters
- **Testability**: Error cases now covered by unit tests
- **Consistency**: Unified error message format

**Test Results**:
- Without feature: 959/959 PASS (1 new test added)
- With normalized_dev: 1010/1013 PASS (4 new tests total)
  - 3 failing tests are pre-existing phase49 issues
- All PromotedBindingRecorder tests: 4/4 PASS
- All DigitPosPromoter tests: 6/6 PASS
- All CarrierPromoter tests: 10/10 PASS

**Build Status**:  Clean (0 errors, 0 warnings)

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

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-13 06:33:44 +09:00
parent 7ef9079aae
commit 10e78fa313
4 changed files with 250 additions and 58 deletions

View File

@ -697,3 +697,7 @@ pub mod break_condition_analyzer;
// Phase 200-A: Function Scope Capture Infrastructure
pub mod function_scope_capture;
// Phase 78: PromotedBindingRecorder - Type-safe BindingId recording
pub mod promoted_binding_recorder;
pub use promoted_binding_recorder::{BindingRecordError, PromotedBindingRecorder};