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); + } }