diff --git a/src/memory.cpp b/src/memory.cpp index 9b37351..1f3f620 100644 --- a/src/memory.cpp +++ b/src/memory.cpp @@ -79,6 +79,14 @@ void Memory::update(string identifier, EvalResult value) { scope.vars[identifier].initialized = true; return; } + if (scope.type == ScopeType::Function) { + Closure closure = std::get<1>(std::get(scope.fn->value)); + if (closure.contains(identifier)) { + MemoryVar& var = closure.at(identifier); + var.value = value; + var.initialized = true; + } + } } throw exception();