From 5044f8d807ad404dbfbfccc40e37e807ef059193 Mon Sep 17 00:00:00 2001 From: nyash-codex Date: Sun, 16 Nov 2025 17:45:14 +0900 Subject: [PATCH] fix(selfhost): propagate Stage-3 parser flags to child processes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/runner/child_env.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/runner/child_env.rs b/src/runner/child_env.rs index 31383d5d..e216f72d 100644 --- a/src/runner/child_env.rs +++ b/src/runner/child_env.rs @@ -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); + } }