wip(mir): StaticCompiler receiver正規化の部分的修正 - 将来の根治に向けた基盤整備
【修正内容】
1. src/mir/builder/calls/guard.rs
- receiver型情報がない場合のpass-through処理追加
- ME-CALL として後段処理に委譲
2. src/mir/builder/ssa/local.rs
- receiver kind で型情報がない場合、origin から型を推論
- value_types への伝播を強化
【現状】
- 完全な根治には至っていない(MIR builder設計レベルの複雑な依存関係)
- .hako側workaround (51d53c29) が実用的な解決策として機能中
【根本原因】
- value_origin_newbox に ParserBox が保持される
- value_types に実際の型(String等)が欠落
- receiver に型情報がないまま StaticCompiler Method に解決される問題
【今後の方向性】
- MIR builder の型伝播システム全体の見直しが必要
- Phase 25.1: Stage-1 bridge receiver bug (partial fix)
This commit is contained in:
@ -59,11 +59,11 @@ impl<'a> CalleeGuardBox<'a> {
|
||||
{
|
||||
// Only apply guard if box_kind is StaticCompiler
|
||||
if box_kind == CalleeBoxKind::StaticCompiler {
|
||||
// Check if receiver has a Box type
|
||||
if let Some(MirType::Box(receiver_box)) = self.value_types.get(&recv) {
|
||||
let trace_enabled =
|
||||
std::env::var("NYASH_CALLEE_RESOLVE_TRACE").ok().as_deref() == Some("1");
|
||||
|
||||
// Check if receiver has a Box type
|
||||
if let Some(MirType::Box(receiver_box)) = self.value_types.get(&recv) {
|
||||
// If receiver box type matches the static box name, this is a me-call
|
||||
// Let it through for static method lowering (don't normalize)
|
||||
if receiver_box == box_name {
|
||||
@ -97,6 +97,20 @@ impl<'a> CalleeGuardBox<'a> {
|
||||
certainty,
|
||||
box_kind: CalleeBoxKind::RuntimeData, // Switch to runtime
|
||||
});
|
||||
} else {
|
||||
// StaticCompiler Method but receiver has NO Box type
|
||||
// → Pass through as ME-CALL (let downstream handle it)
|
||||
if trace_enabled {
|
||||
eprintln!("[static-runtime-guard] StaticCompiler receiver has NO Box type:");
|
||||
eprintln!(
|
||||
" {}.{} receiver %{} has no type info",
|
||||
box_name, method, recv.0
|
||||
);
|
||||
eprintln!(" → Passing through as ME-CALL (downstream will resolve)");
|
||||
}
|
||||
|
||||
// Pass through unchanged - let finalize_method_receiver() handle it
|
||||
return Ok(callee);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,7 +116,13 @@ pub fn ensure(builder: &mut MirBuilder, v: ValueId, kind: LocalKind) -> ValueId
|
||||
builder.value_types.insert(loc, t);
|
||||
}
|
||||
if let Some(cls) = builder.value_origin_newbox.get(&v).cloned() {
|
||||
builder.value_origin_newbox.insert(loc, cls);
|
||||
builder.value_origin_newbox.insert(loc, cls.clone());
|
||||
|
||||
// CRITICAL FIX: For receiver kind, if type is missing but origin exists,
|
||||
// infer MirType::Box from origin
|
||||
if kind == LocalKind::Recv && builder.value_types.get(&loc).is_none() {
|
||||
builder.value_types.insert(loc, crate::mir::MirType::Box(cls));
|
||||
}
|
||||
}
|
||||
builder.local_ssa_map.insert(key, loc);
|
||||
loc
|
||||
|
||||
Reference in New Issue
Block a user