From 415c7ebbccc1f6fda0afb4e295984de0fe9a753e Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Wed, 21 Jun 2017 16:46:56 +0200 Subject: [PATCH] Fix local-exported vars with "--no-scope-shadowing" This used to create copies even then, which meant it couldn't modify them. --- src/env.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/env.cpp b/src/env.cpp index a54f47e0e..ef633e13a 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -182,11 +182,13 @@ void var_stack_t::push(bool new_scope) { // Copy local-exported variables auto top_node = top.get(); - if (!(top_node == this->global_env)) { - for (auto& var : top_node->env) { - if (var.second.exportv) { - // This should copy var - node->env.insert(var); + if (new_scope) { + if (!(top_node == this->global_env)) { + for (auto& var : top_node->env) { + if (var.second.exportv) { + // This should copy var + node->env.insert(var); + } } } }