feat(llvm): Phase 131-15 - print/concat segfault 根治修正

## P1-1/P1-2: TypeFacts 優先化
- binop.py: operand facts が dst_type ヒントより優先
- mir_json_emit.rs: Unknown 時に dst_type を出さない
- function_lower.py: value_types を metadata から読み込み

## P2: handle concat 統一(根治)
- print シグネチャ修正: i64(i64) → void(i8*)
- Mixed concat を handle ベースに統一:
  - concat_si/concat_is → concat_hh
  - box.from_i64 で integer を handle 化
  - Everything is Box 哲学に統一
- legacy 関数は互換性のために保持

## 結果
-  print("Result: " + 3) → Result: 3
-  segfault 解消
-  Everything is Box 統一

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-15 01:36:34 +09:00
parent 7f57a1bb05
commit a955dd6b18
9 changed files with 234 additions and 88 deletions

View File

@ -303,8 +303,8 @@ pub fn emit_mir_json_for_harness(
B::Or => "|",
};
let mut obj = json!({"op":"binop","operation": op_s, "lhs": lhs.as_u32(), "rhs": rhs.as_u32(), "dst": dst.as_u32()});
// Phase 131-11-E: dst_type hint based on RESULT type (not operand types)
// Use the dst type from metadata, which has been corrected by repropagate_binop_types
// Phase 131-15-P1: dst_type only when type is KNOWN (not Unknown)
// Operand TypeFacts take priority over dst_type hint in Python
if matches!(op, B::Add) {
let dst_type = f.metadata.value_types.get(dst);
match dst_type {
@ -316,8 +316,12 @@ pub fn emit_mir_json_for_harness(
// Explicitly mark as i64 for integer addition
obj["dst_type"] = json!("i64");
}
Some(MirType::Unknown) | None => {
// Unknown: DO NOT emit dst_type
// Let Python side infer from operand TypeFacts
}
_ => {
// Unknown/other: default to i64 (conservative)
// Other known types: use conservative i64
obj["dst_type"] = json!("i64");
}
}
@ -688,8 +692,8 @@ pub fn emit_mir_json_for_harness_bin(
B::Or => "|",
};
let mut obj = json!({"op":"binop","operation": op_s, "lhs": lhs.as_u32(), "rhs": rhs.as_u32(), "dst": dst.as_u32()});
// Phase 131-11-E: dst_type hint based on RESULT type (not operand types)
// Use the dst type from metadata, which has been corrected by repropagate_binop_types
// Phase 131-15-P1: dst_type only when type is KNOWN (not Unknown)
// Operand TypeFacts take priority over dst_type hint in Python
if matches!(op, B::Add) {
let dst_type = f.metadata.value_types.get(dst);
match dst_type {
@ -701,8 +705,12 @@ pub fn emit_mir_json_for_harness_bin(
// Explicitly mark as i64 for integer addition
obj["dst_type"] = json!("i64");
}
Some(MirType::Unknown) | None => {
// Unknown: DO NOT emit dst_type
// Let Python side infer from operand TypeFacts
}
_ => {
// Unknown/other: default to i64 (conservative)
// Other known types: use conservative i64
obj["dst_type"] = json!("i64");
}
}