## 問題
- Stage-1 CLI emit_program_json で無限ループ発生
- 初期ホワイトスペーススキップループで ws_cont_init PHIバグ
- ループ条件変数への代入が Header PHI に反映されず
## 根本原因
- Header PHI generation failure
- ws_cont_init = 0 実行後もループ条件で ws_cont_init == 1 が true
## 解決策
- PHI依存を完全排除:loop(ws_cont_init == 1) → loop(i < n)
- 条件付き break だけで制御(continue/break のみ)
- Header PHI に依存しない構造に書き換え
## 変更内容
- lang/src/compiler/parser/parser_box.hako:294-312
- loop(ws_cont_init == 1) → loop(i < n) に変更
- if whitespace { i++; continue } else { break }
- ws_cont_init 変数を完全削除
## Phase 26-H 準備
- この修正により Stage-1 CLI が動作可能に
- JoinIR 実装の前提条件クリア
- PHI問題の暫定回避(根治は JoinIR で行う)
🌟 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Hakorune Compiler — Layout and Responsibilities
Structure (target)
- emit/
- mir_emitter_box.hako — high-level MIR emitter entry
- common/ — shared emit helpers (mir_emit/json_emit/call_emit/header_emit/newbox_emit)
- parser/ — lexer/parser (to be moved from apps/* in later steps)
- builder/, ssa/, rewrite/, pipeline_v2/ — existing compiler stages (move gradually)
Policy
- Compiler lives under
lang/src/compiler/. - VM engines live under
lang/src/vm/engines/(Hakorune/Mini), with shared helpers invm/boxes/. - Keep imports across these boundaries minimal and documented.
Grammar Notes (parser parity)
- Semicolons are accepted as optional statement separators (default ON).
- Both newline and
;delimit statements; trailing};is allowed. - Consecutive
;;are treated as empty statements (no-op). - Env toggle (opt-out): set
NYASH_PARSER_ALLOW_SEMICOLON=0|false|offto disable.
- Both newline and