feat(joinir): Phase 224-E - DigitPos condition normalization
Add DigitPosConditionNormalizer to transform integer comparison to boolean: - `digit_pos < 0` → `!is_digit_pos` This eliminates the type error caused by comparing Bool carrier with Integer: - Before: Bool(is_digit_pos) < Integer(0) → Type error - After: !is_digit_pos → Boolean expression, no type mismatch Implementation: - New Box: digitpos_condition_normalizer.rs (173 lines) - Pattern2 integration: normalize after promotion success - 5 unit tests (all pass) - E2E test passes (type error eliminated) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -374,13 +374,16 @@ Local Region (1000+):
|
||||
- 入出力:
|
||||
- 入力: `DigitPosPromotionRequest`(cond_scope, break_cond/continue_cond, loop_body)
|
||||
- 出力: `DigitPosPromotionResult::Promoted { carrier_info, promoted_var, carrier_name }` または `CannotPromote { reason, vars }`
|
||||
- 現状の制約(Phase 224-continuation で対応予定):
|
||||
- **Promotion は成功**: LoopBodyCondPromoter → DigitPosPromoter → Promoted ✅
|
||||
- **Lowerer integration gap**: lower_loop_with_break_minimal が昇格済み変数を認識せず、break condition AST に元の変数名が残っているため独立チェックでエラー。
|
||||
- **Solution**: Option B(promoted variable tracking)で昇格済み変数リストを lowerer に渡す(1-2h 実装予定)。
|
||||
- **Phase 224-E 完了(AST 条件正規化)**:
|
||||
- **DigitPosConditionNormalizer Box**: `digit_pos < 0` → `!is_digit_pos` の AST 変換。
|
||||
- **実装箇所**: `src/mir/join_ir/lowering/digitpos_condition_normalizer.rs`(173 lines)。
|
||||
- **統合**: Pattern2 で promotion 成功後に自動適用(`pattern2_with_break.rs` line 332-344)。
|
||||
- **単体テスト**: 5/5 PASS(happy path, wrong operator/variable/constant, non-binary-op)。
|
||||
- **E2E テスト**: `phase2235_p2_digit_pos_min.hako` で型エラー解消確認。
|
||||
- **回帰テスト**: digitpos (11 tests), trim (32 tests) 全て PASS。
|
||||
- 参考:
|
||||
- 設計ドキュメント: `docs/development/current/main/phase224-digitpos-promoter-design.md`
|
||||
- 完全サマリ: `docs/development/current/main/PHASE_224_SUMMARY.md`
|
||||
- 設計ドキュメント: `docs/development/current/main/phase224-digitpos-condition-normalizer.md`
|
||||
- 実装サマリ: `docs/development/current/main/PHASE_224_SUMMARY.md`
|
||||
- テストケース: `apps/tests/phase2235_p2_digit_pos_min.hako`
|
||||
|
||||
- **ContinueBranchNormalizer / LoopUpdateAnalyzer**
|
||||
|
||||
Reference in New Issue
Block a user