refactor(stage1): Phase 25.4-B準備 - Stage-1 CLI env処理改善

🎯 目的: Stage-1 CLI の env/トグル処理を整理・改善

 改善内容:
- stage1_cli.hako: 関数名修正・簡略化
  - パラメータ名を cli_args_raw に統一
  - __mir__.log マーカー整備(デバッグ用)
  - env処理のコメント改善

- string_helpers.hako: to_i64 改善
  - null/Void ガード追加
  - NYASH_TO_I64_DEBUG 対応
  - NYASH_TO_I64_FORCE_ZERO トグル準備

- tools/stage1_debug.sh: デバッグ改善
  - NYASH_TO_I64_DEBUG フラグ追加
  - NYASH_TO_I64_FORCE_ZERO フラグ追加
  - ログ観測の改善

- apps/tests/minimal_to_i64_void.hako: テストケース追加
  - Void値の to_i64 処理確認用

📋 Phase 25.4-B への準備:
- 次フェーズで Stage1CliConfigBox を導入予定
- env.get() を Config 箱に集約する基盤完成
- 既存動作は維持(Fail-Fast + テスト緑キープ)

🎯 効果:
- デバッグ観測性向上
- Void/null 処理の安全性向上
- 将来の Config 箱化への準備完了

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-11-21 09:02:02 +09:00
parent 28a312ea0d
commit 4a48d6afa3
4 changed files with 42 additions and 8 deletions

View File

@ -26,6 +26,9 @@ static box StringHelpers {
if env.get("NYASH_TO_I64_DEBUG") == "1" {
__mir__.log("[string_helpers/to_i64] x", x)
}
// Fail-close for unexpected boxes (e.g., Void) when explicitly requested.
// This avoids String + Void type errors during Stage-1 CLI bring-up.
if env.get("NYASH_TO_I64_FORCE_ZERO") == "1" { return 0 }
if x == null { return 0 }
local s = "" + x
local i = 0