2025-12-16 17:08:15 +09:00
|
|
|
|
# Phase 92: Lowering (ConditionalStep / P5b Escape)
|
|
|
|
|
|
|
|
|
|
|
|
## Status
|
|
|
|
|
|
- ✅ P0: Contract + skeleton-to-lowering wiring (foundations)
|
|
|
|
|
|
- ✅ P1: Boxification / module isolation (ConditionalStep emitter)
|
|
|
|
|
|
- 🔶 P2: Wire emitter into Pattern2 + enable E2E
|
2025-12-16 21:37:07 +09:00
|
|
|
|
- ✅ P3: BodyLocal 1変数(read-only)を Pattern2 条件で許可(Fail-Fast)
|
2025-12-16 17:08:15 +09:00
|
|
|
|
|
|
|
|
|
|
## Goal
|
|
|
|
|
|
- Phase 91 で認識した P5b(escape skip: +1 / +2 の条件付き更新)を、JoinIR lowering まで落とせるようにする。
|
|
|
|
|
|
- 既定挙動は不変。Fail-Fast を維持し、未対応は理由付きで止める。
|
|
|
|
|
|
|
|
|
|
|
|
## P0(完了)
|
|
|
|
|
|
|
|
|
|
|
|
- P0-1: ConditionalStep 契約(SSOT)
|
|
|
|
|
|
- 実装/記録: `src/mir/loop_canonicalizer/skeleton_types.rs`(契約コメント)
|
|
|
|
|
|
- 記録: `docs/development/current/main/phases/phase-92/p0-2-skeleton-to-context.md`
|
|
|
|
|
|
- P0-2: Skeleton → lowering への配線(Option A)
|
|
|
|
|
|
- `LoopPatternContext` に skeleton を optional に通した(後に P1 で境界を整理)
|
|
|
|
|
|
- P0-3: ConditionalStep を JoinIR(Select 等)で表現する基盤を追加
|
|
|
|
|
|
|
|
|
|
|
|
## P1(完了): 箱化・モジュール化
|
|
|
|
|
|
|
|
|
|
|
|
- ConditionalStep lowering を 1 箱に隔離
|
|
|
|
|
|
- `src/mir/join_ir/lowering/common/conditional_step_emitter.rs`
|
|
|
|
|
|
- `src/mir/join_ir/lowering/common.rs` から export
|
|
|
|
|
|
- 目的: Pattern2 本体を肥大化させず、条件付き更新の責務を emitter に閉じ込める
|
|
|
|
|
|
- 境界の整理(SSOT)
|
|
|
|
|
|
- routing 層から skeleton を取り除き、Pattern2 側で skeleton/recognizer 情報の取得を内部化
|
|
|
|
|
|
- recognizer は cond/delta 抽出に限定(スコープ/寿命の判断を混ぜない)
|
|
|
|
|
|
- E2E fixture
|
|
|
|
|
|
- `test_pattern5b_escape_minimal.hako` は用意済み(body-local 対応後に実行固定)
|
|
|
|
|
|
|
|
|
|
|
|
## P2(次): E2E を通す(最小1本)
|
|
|
|
|
|
|
|
|
|
|
|
### P2-1: Pattern2 で emitter を実際に使用する
|
|
|
|
|
|
- Pattern2 lowerer の update emission で `ConditionalStep` を検出したら emitter に委譲する
|
|
|
|
|
|
- AST 再検出を増やさない(canonicalizer/recognizer の SSOT を使う)
|
|
|
|
|
|
|
|
|
|
|
|
### P2-2: body-local 変数(`ch`)問題を解く
|
|
|
|
|
|
- recognizer は cond/delta 抽出に限定し、スコープ/寿命の扱いは Skeleton 側へ寄せる
|
|
|
|
|
|
|
|
|
|
|
|
### P2-3: E2E fixture を 1 本だけ通す
|
|
|
|
|
|
- `test_pattern5b_escape_minimal.hako`(Phase 91 の最小fixture)
|
|
|
|
|
|
|
2025-12-16 21:37:07 +09:00
|
|
|
|
## P3(完了): BodyLocal 1変数対応(Fail-Fast付き)
|
|
|
|
|
|
|
|
|
|
|
|
- 目的: `ch` のような read-only body-local(毎回再計算)を Pattern2 の break/escape 条件で参照できるようにする
|
|
|
|
|
|
- 新規箱: `src/mir/join_ir/lowering/common/body_local_slot.rs`
|
|
|
|
|
|
- 許可: 条件に出る LoopBodyLocal が 1つ、top-level `local <name> = <expr>`、break guard `if` より前、代入なし
|
|
|
|
|
|
- 禁止: 複数、代入あり、定義が break guard より後、top-level 以外(分岐内など)
|
|
|
|
|
|
- 破ると `error_tags::freeze(...)` で理由付き停止
|
|
|
|
|
|
|
2025-12-16 17:08:15 +09:00
|
|
|
|
## Acceptance
|
|
|
|
|
|
- `NYASH_JOINIR_DEV=1 HAKO_JOINIR_STRICT=1` で parity が green のまま
|
|
|
|
|
|
- E2E が 1 本通る(まずは VM でOK)
|
|
|
|
|
|
- 既定挙動不変(フラグOFFで無影響)
|