Fix local-exported vars with "--no-scope-shadowing"

This used to create copies even then, which meant it couldn't modify them.
This commit is contained in:
Fabian Homborg 2017-06-21 16:46:56 +02:00 committed by Kurtis Rader
parent 04205f36be
commit 415c7ebbcc

View file

@ -182,11 +182,13 @@ void var_stack_t::push(bool new_scope) {
// Copy local-exported variables // Copy local-exported variables
auto top_node = top.get(); auto top_node = top.get();
if (!(top_node == this->global_env)) { if (new_scope) {
for (auto& var : top_node->env) { if (!(top_node == this->global_env)) {
if (var.second.exportv) { for (auto& var : top_node->env) {
// This should copy var if (var.second.exportv) {
node->env.insert(var); // This should copy var
node->env.insert(var);
}
} }
} }
} }