feat(env): Phase 71-73 - SSA fix + Stage-3 ENV consolidation

## Phase 71-SSA: StageBDriverBox birth warning 解消
- Fixed false-positive dev verify warning for static boxes
- StageBDriverBox is a static box, so it doesn't follow NewBox→birth pattern
- Modified lifecycle.rs to skip StageBDriverBox from birth() requirement

## Phase 73-A: Stage-3 legacy ENV 統一化
- Consolidated NYASH_PARSER_STAGE3 and HAKO_PARSER_STAGE3 → NYASH_FEATURES=stage3
- Updated 20 test files (46 direct replacements)
- Special handling for parser_stage3.rs compat layer and mir_static_main_args_loop.rs
- All test files now use unified NYASH_FEATURES=stage3

## Phase 72-73: ENV inventory documented
- Created phase72-73-env-inventory.md with complete usage analysis
- Identified 113 direct ENV reads requiring SSOT consolidation
- Prioritized Phase 72 (JoinIR EXPERIMENT SSOT) and Phase 73 (Stage-3 cleanup)

## Phase 74-SSA: Minimal reproduction for static box delegation
- Created parser_box_minimal.hako and ssa_static_delegation_min.hako
- Investigated spawn failure in selfhost compiler (arguments too long)
- Root cause: NYASH_NY_COMPILER_EMIT_ONLY=1 defaults to emit-only mode

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-02 12:36:28 +09:00
parent 29e09c1491
commit e656958033
24 changed files with 880 additions and 69 deletions

View File

@ -387,8 +387,9 @@ impl super::MirBuilder {
args,
} = &insns[idx]
{
// StageB dev verify OFF のときは StageBDriverBox の birth 警告のみスキップ
if !stageb_dev_verify_on && box_type == "StageBDriverBox" {
// Phase 71-SSA 71-11.2: StageBDriverBox is a static box → skip birth warning unconditionally
// Static boxes don't follow NewBox→birth pattern by design
if box_type == "StageBDriverBox" {
idx += 1;
continue;
}

View File

@ -25,8 +25,8 @@ use crate::mir::MirCompiler;
use crate::parser::NyashParser;
fn ensure_stage3_env() {
std::env::set_var("NYASH_PARSER_STAGE3", "1");
std::env::set_var("HAKO_PARSER_STAGE3", "1");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_PARSER_ALLOW_SEMICOLON", "1");
std::env::set_var("NYASH_DISABLE_PLUGINS", "1");
std::env::set_var("HAKO_MIR_BUILDER_METHODIZE", "0");
@ -100,8 +100,8 @@ static box Main {
}
// cleanup
std::env::remove_var("NYASH_PARSER_STAGE3");
std::env::remove_var("HAKO_PARSER_STAGE3");
std::env::remove_var("NYASH_FEATURES");
std::env::remove_var("NYASH_FEATURES");
std::env::remove_var("NYASH_PARSER_ALLOW_SEMICOLON");
std::env::remove_var("NYASH_DISABLE_PLUGINS");
std::env::remove_var("HAKO_MIR_BUILDER_METHODIZE");

View File

@ -18,7 +18,7 @@ use crate::mir::{MirCompiler, MirPrinter, MirVerifier};
use crate::parser::NyashParser;
fn ensure_stage3_env() {
std::env::set_var("NYASH_PARSER_STAGE3", "1");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_PARSER_ALLOW_SEMICOLON", "1");
}

View File

@ -22,8 +22,8 @@ mod tests {
#[test]
fn vm_exec_continue_skips_body() {
// Phase 59b: Stage-3 parser required for local variable declarations
std::env::set_var("NYASH_PARSER_STAGE3", "1");
std::env::set_var("HAKO_PARSER_STAGE3", "1");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_FEATURES", "stage3");
let code = r#"
local i = 0
@ -46,8 +46,8 @@ mod tests {
#[test]
fn vm_exec_break_inside_if() {
// Phase 59b: Stage-3 parser required for local variable declarations
std::env::set_var("NYASH_PARSER_STAGE3", "1");
std::env::set_var("HAKO_PARSER_STAGE3", "1");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_FEATURES", "stage3");
let code = r#"
local i = 0

View File

@ -17,8 +17,8 @@ fn mir_funcscanner_parse_params_trim_min_verify_and_vm() {
let test_file = "lang/src/compiler/tests/funcscanner_parse_params_trim_min.hako";
// Align parser env to Stage3 + using 経路(既存の skip_ws 系と揃えておく)。
std::env::set_var("NYASH_PARSER_STAGE3", "1");
std::env::set_var("HAKO_PARSER_STAGE3", "1");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_ENABLE_USING", "1");
std::env::set_var("HAKO_ENABLE_USING", "1");
std::env::set_var("NYASH_PARSER_ALLOW_SEMICOLON", "1");
@ -92,8 +92,8 @@ fn mir_funcscanner_parse_params_trim_min_verify_and_vm() {
);
// Cleanup env vars
std::env::remove_var("NYASH_PARSER_STAGE3");
std::env::remove_var("HAKO_PARSER_STAGE3");
std::env::remove_var("NYASH_FEATURES");
std::env::remove_var("NYASH_FEATURES");
std::env::remove_var("NYASH_ENABLE_USING");
std::env::remove_var("HAKO_ENABLE_USING");
std::env::remove_var("NYASH_PARSER_ALLOW_SEMICOLON");

View File

@ -16,8 +16,8 @@ fn mir_funcscanner_skip_ws_direct_vm() {
let test_file = "lang/src/compiler/tests/funcscanner_skip_ws_min.hako";
// Enable required env vars for Stage-3 + using
std::env::set_var("NYASH_PARSER_STAGE3", "1");
std::env::set_var("HAKO_PARSER_STAGE3", "1");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_ENABLE_USING", "1");
std::env::set_var("HAKO_ENABLE_USING", "1");
std::env::set_var("NYASH_PARSER_ALLOW_SEMICOLON", "1");
@ -118,8 +118,8 @@ fn mir_funcscanner_skip_ws_direct_vm() {
}
// Cleanup env vars
std::env::remove_var("NYASH_PARSER_STAGE3");
std::env::remove_var("HAKO_PARSER_STAGE3");
std::env::remove_var("NYASH_FEATURES");
std::env::remove_var("NYASH_FEATURES");
std::env::remove_var("NYASH_ENABLE_USING");
std::env::remove_var("HAKO_ENABLE_USING");
std::env::remove_var("NYASH_PARSER_ALLOW_SEMICOLON");

View File

@ -11,8 +11,8 @@ fn mir_funcscanner_skip_ws_min_verify_and_vm() {
let test_file = "lang/src/compiler/tests/funcscanner_skip_ws_min.hako";
// Stage-3 + using
std::env::set_var("NYASH_PARSER_STAGE3", "1");
std::env::set_var("HAKO_PARSER_STAGE3", "1");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_ENABLE_USING", "1");
std::env::set_var("HAKO_ENABLE_USING", "1");
std::env::set_var("NYASH_DISABLE_PLUGINS", "1");
@ -32,8 +32,8 @@ fn mir_funcscanner_skip_ws_min_verify_and_vm() {
let mut vm = VM::new();
vm.execute_module(&compiled.module).expect("VM exec failed");
std::env::remove_var("NYASH_PARSER_STAGE3");
std::env::remove_var("HAKO_PARSER_STAGE3");
std::env::remove_var("NYASH_FEATURES");
std::env::remove_var("NYASH_FEATURES");
std::env::remove_var("NYASH_ENABLE_USING");
std::env::remove_var("HAKO_ENABLE_USING");
std::env::remove_var("NYASH_DISABLE_PLUGINS");

View File

@ -19,7 +19,7 @@ use crate::mir::{MirCompiler, MirPrinter, MirVerifier};
use crate::parser::NyashParser;
fn ensure_stage3_env() {
std::env::set_var("NYASH_PARSER_STAGE3", "1");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_PARSER_ALLOW_SEMICOLON", "1");
std::env::set_var("NYASH_ENABLE_USING", "1");
}

View File

@ -16,8 +16,8 @@ fn mir_funcscanner_trim_min_verify_and_vm() {
let test_file = "lang/src/compiler/tests/funcscanner_trim_min.hako";
// Stage3 + using 系のパーサ設定を揃える(他の FuncScanner 系テストと同じ)。
std::env::set_var("NYASH_PARSER_STAGE3", "1");
std::env::set_var("HAKO_PARSER_STAGE3", "1");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_ENABLE_USING", "1");
std::env::set_var("HAKO_ENABLE_USING", "1");
std::env::set_var("NYASH_PARSER_ALLOW_SEMICOLON", "1");
@ -87,8 +87,8 @@ fn mir_funcscanner_trim_min_verify_and_vm() {
}
// Cleanup env vars
std::env::remove_var("NYASH_PARSER_STAGE3");
std::env::remove_var("HAKO_PARSER_STAGE3");
std::env::remove_var("NYASH_FEATURES");
std::env::remove_var("NYASH_FEATURES");
std::env::remove_var("NYASH_ENABLE_USING");
std::env::remove_var("HAKO_ENABLE_USING");
std::env::remove_var("NYASH_PARSER_ALLOW_SEMICOLON");

View File

@ -12,7 +12,7 @@ use crate::parser::NyashParser;
#[test]
fn mir_locals_copy_instructions_emitted() {
std::env::set_var("NYASH_PARSER_STAGE3", "1");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_PARSER_ALLOW_SEMICOLON", "1");
let src = r#"
@ -102,7 +102,7 @@ static box TestLocals {
#[test]
fn mir_locals_uninitialized() {
std::env::set_var("NYASH_PARSER_STAGE3", "1");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_PARSER_ALLOW_SEMICOLON", "1");
let src = r#"

View File

@ -31,7 +31,7 @@ return (new StringBox("Hello")).length()
/// Minimal smoke for MirInstruction::DebugLog
#[test]
fn mir_debuglog_minimal_printer_and_verifier() {
std::env::set_var("NYASH_PARSER_STAGE3", "1");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_PARSER_ALLOW_SEMICOLON", "1");
std::env::set_var("NYASH_MIR_DEBUG_LOG", "1");

View File

@ -2,7 +2,7 @@ use crate::mir::MirPrinter;
use crate::parser::NyashParser;
fn ensure_stage3_env() {
std::env::set_var("NYASH_PARSER_STAGE3", "1");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_PARSER_ALLOW_SEMICOLON", "1");
}
use crate::ast::ASTNode;

View File

@ -3,7 +3,7 @@ use crate::mir::{MirCompiler, MirPrinter, MirVerifier};
use crate::parser::NyashParser;
fn ensure_stage3_env() {
std::env::set_var("NYASH_PARSER_STAGE3", "1");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_PARSER_ALLOW_SEMICOLON", "1");
}

View File

@ -47,8 +47,8 @@ static box Main {
#[test]
fn mir_stageb_string_utils_skip_ws_compile() {
// Enable Stage-3 parser for 'local' keyword
std::env::set_var("NYASH_PARSER_STAGE3", "1");
std::env::set_var("HAKO_PARSER_STAGE3", "1");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_FEATURES", "stage3");
let src = make_minimal_src();
let ast: ASTNode = NyashParser::parse_from_string(&src).expect("parse should succeed");
@ -75,8 +75,8 @@ static box Main {
#[ignore] // 修正前用テストcommit b00cc8d5 で再現)
fn mir_stageb_string_utils_skip_ws_exec_reproduce_void_lt_zero() {
// Enable Stage-3 parser
std::env::set_var("NYASH_PARSER_STAGE3", "1");
std::env::set_var("HAKO_PARSER_STAGE3", "1");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_FEATURES", "stage3");
let src = make_minimal_src();
let ast: ASTNode = NyashParser::parse_from_string(&src).expect("parse ok");
@ -113,8 +113,8 @@ static box Main {
#[test]
fn mir_stageb_string_utils_skip_ws_exec_success() {
// Enable Stage-3 parser
std::env::set_var("NYASH_PARSER_STAGE3", "1");
std::env::set_var("HAKO_PARSER_STAGE3", "1");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_FEATURES", "stage3");
let src = make_minimal_src();
let ast: ASTNode = NyashParser::parse_from_string(&src).expect("parse ok");

View File

@ -28,8 +28,8 @@ fn load_fixture_with_string_helpers() -> String {
#[test]
fn mir_static_main_box_emits_canonical_static_methods() {
// Enable Stage3 + using for the fixture.
std::env::set_var("NYASH_PARSER_STAGE3", "1");
std::env::set_var("HAKO_PARSER_STAGE3", "1");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_PARSER_ALLOW_SEMICOLON", "1");
std::env::set_var("NYASH_ENABLE_USING", "1");
std::env::set_var("HAKO_ENABLE_USING", "1");
@ -59,8 +59,8 @@ fn mir_static_main_box_emits_canonical_static_methods() {
/// Execute the minimal fixture with Void-returning _nop() and confirm it lowers without SSA/arity drift.
#[test]
fn mir_static_main_box_executes_void_path_with_guard() {
std::env::set_var("NYASH_PARSER_STAGE3", "1");
std::env::set_var("HAKO_PARSER_STAGE3", "1");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_PARSER_ALLOW_SEMICOLON", "1");
std::env::set_var("NYASH_ENABLE_USING", "1");
std::env::set_var("HAKO_ENABLE_USING", "1");

View File

@ -1,7 +1,7 @@
use crate::parser::NyashParser;
fn enable_stage3() {
std::env::set_var("NYASH_PARSER_STAGE3", "1");
std::env::set_var("NYASH_FEATURES", "stage3");
// Accept blockpostfix under Stage3 gate
std::env::set_var("NYASH_BLOCK_CATCH", "1");
}

View File

@ -1,7 +1,7 @@
use crate::parser::NyashParser;
fn enable_stage3() {
std::env::set_var("NYASH_PARSER_STAGE3", "1");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_BLOCK_CATCH", "1");
}

View File

@ -1,7 +1,7 @@
use crate::parser::NyashParser;
fn enable_stage3() {
std::env::set_var("NYASH_PARSER_STAGE3", "1");
std::env::set_var("NYASH_FEATURES", "stage3");
}
#[test]

View File

@ -1,7 +1,7 @@
use crate::parser::NyashParser;
fn enable_stage3() {
std::env::set_var("NYASH_PARSER_STAGE3", "1");
std::env::set_var("NYASH_FEATURES", "stage3");
std::env::set_var("NYASH_METHOD_CATCH", "1");
}