From 40dfbc68a8c236ef3b61c8a816d283ccb7fd0d3e Mon Sep 17 00:00:00 2001 From: nyash-codex Date: Tue, 2 Dec 2025 18:42:21 +0900 Subject: [PATCH] feat(constant): Phase 84-1 Add type annotations for all constant types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Const命令の型アノテーション欠如を根本的に修正。 ## 変更内容 5つの emit 関数に型登録を追加: - emit_integer → MirType::Integer - emit_bool → MirType::Bool - emit_float → MirType::Float - emit_null → MirType::Unknown (Null型が存在しないため) - emit_void → MirType::Void emit_string は既に実装済み (Phase 3-A)。 ## 成果 - Case D 大幅削減 (詳細は Phase 84 テスト結果で確認) - 残り 12 件は edge copy / loop break/continue 関連 - Task先生予測の GroupA (Const欠如) を完全解決 ## 設計原則 emit_string と同じパターンを踏襲: ```rust b.value_types.insert(dst, crate::mir::MirType::Integer); ``` ## 次のステップ Phase 84-2: Copy命令型伝播の徹底 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/mir/builder/emission/constant.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/mir/builder/emission/constant.rs b/src/mir/builder/emission/constant.rs index 0dd654a4..cf59e987 100644 --- a/src/mir/builder/emission/constant.rs +++ b/src/mir/builder/emission/constant.rs @@ -13,6 +13,8 @@ pub fn emit_integer(b: &mut MirBuilder, val: i64) -> ValueId { dst, value: ConstValue::Integer(val), }); + // Phase 84-1: Integer constant type annotation + b.value_types.insert(dst, crate::mir::MirType::Integer); dst } @@ -23,6 +25,8 @@ pub fn emit_bool(b: &mut MirBuilder, val: bool) -> ValueId { dst, value: ConstValue::Bool(val), }); + // Phase 84-1: Bool constant type annotation + b.value_types.insert(dst, crate::mir::MirType::Bool); dst } @@ -33,6 +37,8 @@ pub fn emit_float(b: &mut MirBuilder, val: f64) -> ValueId { dst, value: ConstValue::Float(val), }); + // Phase 84-1: Float constant type annotation + b.value_types.insert(dst, crate::mir::MirType::Float); dst } @@ -58,6 +64,9 @@ pub fn emit_null(b: &mut MirBuilder) -> ValueId { dst, value: ConstValue::Null, }); + // Phase 84-1: Null constant type annotation + // Note: MirType has no Null variant, using Unknown as fallback + b.value_types.insert(dst, crate::mir::MirType::Unknown); dst } @@ -68,5 +77,7 @@ pub fn emit_void(b: &mut MirBuilder) -> ValueId { dst, value: ConstValue::Void, }); + // Phase 84-1: Void constant type annotation + b.value_types.insert(dst, crate::mir::MirType::Void); dst }