Files
hakorune/apps/tests/minimal_to_i64_void.hako
nyash-codex 4a48d6afa3 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>
2025-11-21 09:02:02 +09:00

35 lines
1.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// minimal_to_i64_void.hako — StringHelpers.to_i64 × Void 最小再現
//
// 目的:
// - StringHelpers.to_i64 に Void 値を渡したときに
// `"" + x` で String + Void 型エラーになるケースを最小コードで再現する。
// - Stage1 CLI とは独立した、純粋な VM 実行ルートでの再現用。
//
// 実行例:
// ./target/release/hakorune apps/tests/minimal_to_i64_void.hako
//
// 期待される挙動(バグ再現時):
// Type error: unsupported binop Add on String(\"\") and Void
//
// 修正後は:
// - 正常に 0 を出力して終了するなど、「Void を安全に扱える」ようにする。
using selfhost.shared.common.string_helpers as StringHelpers
static box Main {
// 戻り値のないメソッド: VM からは Void 相当が返る前提。
method _nop() { }
method main(args) {
// _nop() の結果を x に受け取り、to_i64 に渡す。
local x = me._nop()
// ここで StringHelpers.to_i64(x) が "" + x を評価し、
// x が Void の場合に String + Void 型エラーを起こす。
local n = StringHelpers.to_i64(x)
print("[minimal_to_i64_void] n=" + ("" + n))
return 0
}
}