fix(selfhost): propagate Stage-3 parser flags to child processes

Phase 25.1b selfhost builder stabilization - prevent "Undefined variable: local" in nested compilations

Changes:
- src/runner/child_env.rs:
  - Add Stage-3 parser flag propagation in apply_core_wrapper_env()
  - Propagate NYASH_PARSER_STAGE3, HAKO_PARSER_STAGE3, NYASH_PARSER_ALLOW_SEMICOLON
  - Ensures child processes (inline compiler, using resolution) support 'local' keyword

Context:
- When selfhost builder uses `using` to load modules, inline compiler spawns child processes
- Without this fix, child processes don't inherit Stage-3 flags → "Undefined variable: local"
- Part of HAKO_SELFHOST_BUILDER_FIRST=1 (no fallback) selfhosting strategy

Note: This is partial fix - inline compiler still needs forced Stage-3 mode (next commit)

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-11-16 17:45:14 +09:00
parent fbf4687ea1
commit 5044f8d807

View File

@ -24,6 +24,7 @@ pub fn post_run_exit_if_oob_strict_triggered() -> ! {
/// - Disables plugins to avoid host-side side effects
/// - Disables file-based using resolution (namespace-first policy)
/// - Skips nyash.toml env injection to reduce drift
/// - Propagates Stage-3 parser flags to ensure 'local' keyword support in nested compilations
pub fn apply_core_wrapper_env(cmd: &mut std::process::Command) {
// Remove noisy or recursive toggles
cmd.env_remove("NYASH_USE_NY_COMPILER");
@ -36,4 +37,18 @@ pub fn apply_core_wrapper_env(cmd: &mut std::process::Command) {
cmd.env("NYASH_USING_AST", "0");
cmd.env("NYASH_ALLOW_USING_FILE", "0");
cmd.env("HAKO_ALLOW_USING_FILE", "0");
// Phase 25.1b fix: Propagate Stage-3 parser flags to child processes
// When selfhost builder uses `using` to load modules, the inline compiler
// needs Stage-3 support for `local` keyword. Without this, we get:
// "Undefined variable: local" in nested compilation.
if let Ok(val) = std::env::var("NYASH_PARSER_STAGE3") {
cmd.env("NYASH_PARSER_STAGE3", val);
}
if let Ok(val) = std::env::var("HAKO_PARSER_STAGE3") {
cmd.env("HAKO_PARSER_STAGE3", val);
}
if let Ok(val) = std::env::var("NYASH_PARSER_ALLOW_SEMICOLON") {
cmd.env("NYASH_PARSER_ALLOW_SEMICOLON", val);
}
}