debug(stage1): Phase 25.1 - MIR Builder 型混乱バグ完全特定
🚨 重大発見: .hakoレベルでは修正不可能なMIR Builderバグ 🔍 根本原因特定: - MIR Builder の型レジストリシステムが型情報を正しく追跡できていない - new ArrayBox() で生成したValueIdが、誤った型として認識される - PHIマージポイントで型情報が失われる/上書きされる 📊 系統的な型混乱パターン: 1. args.size() → ParserBox.size() (本来: ArrayBox.size()) 2. cli_args.length() → ParserBox.length() (本来: ArrayBox.length()) 3. new ArrayBox().size() → LoopOptsBox.size() (本来: ArrayBox.size()) ❌ すべての.hako回避策が失敗: - パラメータ名変更: args → cli_args → cli_args_raw - 新しいArrayBox作成: local x = new ArrayBox() - Fail-Fast Guard追加 → すべて同じ型混乱エラー ✅ 決定的証拠: - __mir__.log が一度も実行されなかった → エラーは MIR生成時に発生(実行時ではない) → .hakoコードの問題ではない 📋 成果物: - __mir__.log マーカー追加 (lang/src/runner/stage1_cli.hako) - stage1_main 入口ログ - env toggles ログ - args.size() 前後ログ - StringHelpers.to_i64 改善 (lang/src/shared/common/string_helpers.hako) - null/Void ガード追加 - デバッグログ追加 - 完全調査レポート: - stage1_mir_builder_type_confusion_bug.md (最終レポート) - stage1_mir_log_investigation.md (詳細調査ログ) 🔧 必要な修正 (推定6-10時間): Phase 1: デバッグトレース追加 (30分) - src/mir/builder/types/mod.rs に NYASH_MIR_TYPE_TRACE Phase 2: トレース実行 (1時間) - 型情報がどこで失われるか特定 Phase 3: 根本修正 (4-8時間) - NewBox生成時の型登録修正 - PHI型伝播ロジック修正 - 型レジストリ整合性チェック追加 Phase 4: 検証 (1時間) - stage1_cli 正常動作確認 🎯 結論: MIR Builder の根本的インフラバグ。SSA変換とPHIノード経由での 型情報追跡に失敗している。.hakoレベルでは回避不可能。 Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Task Assistant <task@anthropic.com>
This commit is contained in:
@ -21,6 +21,12 @@ static box StringHelpers {
|
||||
|
||||
// Parse integer from number or numeric-like string (leading '-' allowed; stops at first non-digit).
|
||||
to_i64(x) {
|
||||
// Optional debug hook: observe incoming values/boxes.
|
||||
// Enable with NYASH_TO_I64_DEBUG=1 when diagnosing numeric coercions.
|
||||
if env.get("NYASH_TO_I64_DEBUG") == "1" {
|
||||
__mir__.log("[string_helpers/to_i64] x", x)
|
||||
}
|
||||
if x == null { return 0 }
|
||||
local s = "" + x
|
||||
local i = 0
|
||||
local neg = 0
|
||||
|
||||
Reference in New Issue
Block a user