fix(mir-builder): static method arity mismatch根治 - Phase 25.x

**問題**:
- ParserStmtBox.parse_using/4 に5引数が渡される
- me.method呼び出しで instance/static 判別なし
- static method に誤って receiver 追加

**修正**:
- MeCallPolicyBox: params[0]の型で instance/static 判別
- Instance method: receiver 追加
- Static method: receiver なし
- Arity検証(NYASH_ME_CALL_ARITY_STRICT=1)

**ドキュメント**:
- docs/reference/environment-variables.md 新規作成
- docs/development/architecture/mir-logs-observability.md 更新

**テスト**:
- src/tests/mir_stage1_cli_emit_program_min.rs 追加
- 既存 stage1 テスト全てパス

Phase: 25.x
This commit is contained in:
nyash-codex
2025-11-21 11:16:38 +09:00
parent b92d9f335d
commit c344451087
15 changed files with 702 additions and 53 deletions

View File

@ -147,15 +147,38 @@ static box Stage1Cli {
// and create a fresh ArrayBox from environment variables instead
local args_safe = new ArrayBox()
// Config box: Parse all env vars into structured config
local cfg = Stage1CliConfigBox.from_env()
local mode = cfg.get("mode")
local debug = cfg.get("debug")
// 現状: MIR 型レジストリの制約により MapBox ベースの ConfigBox は本線では使用しない。
// env から直接読み取り、Stage1CliConfigBox は将来の構造化用として温存する。
// mode 判定env-only
local mode = "disabled"
if env.get("STAGE1_EMIT_PROGRAM_JSON") == "1" {
mode = "emit_program_json"
} else if env.get("STAGE1_EMIT_MIR_JSON") == "1" {
mode = "emit_mir_json"
} else if env.get("NYASH_USE_STAGE1_CLI") == "1" {
mode = "run"
}
// backend と入力まわり
local backend = env.get("STAGE1_BACKEND")
if backend == null { backend = "vm" }
backend = "" + backend
local source = env.get("STAGE1_SOURCE")
local source_text = env.get("STAGE1_SOURCE_TEXT")
local prog_path = env.get("STAGE1_PROGRAM_JSON")
local debug = env.get("STAGE1_CLI_DEBUG")
// Log entry point for debugging
if debug == "1" {
__mir__.log("[stage1_main] args_safe at entry", args_safe)
print("[stage1-cli/debug] stage1_main ENTRY: mode=" + ("" + mode) + " backend=" + ("" + cfg.get("backend")))
print("[stage1-cli/debug] stage1_main ENTRY: mode=" + ("" + mode) + " backend=" + backend)
__mir__.log("[stage1_main] env-config",
mode,
backend,
source,
prog_path)
}
// Early exit if CLI is disabled
@ -166,21 +189,6 @@ static box Stage1Cli {
return 97
}
// Log config toggles before dispatch
if debug == "1" {
__mir__.log("[stage1_main] config",
cfg.get("mode"),
cfg.get("backend"),
cfg.get("source_path"),
cfg.get("program_json_path"))
}
// Extract config fields
local source = cfg.get("source_path")
local source_text = cfg.get("source_text")
local prog_path = cfg.get("program_json_path")
local backend = cfg.get("backend")
// Dispatch by mode
if mode == "emit_program_json" {
if source == null || source == "" {