diff --git a/src/operations/node.cpp b/src/operations/node.cpp index 75f7d1b..426da01 100644 --- a/src/operations/node.cpp +++ b/src/operations/node.cpp @@ -214,11 +214,13 @@ Value* eval_expression(Node* node, Environment* env) { std::cerr << "Error: Symbol " << node->id << " not found." << std::endl; return 0; } - return get_value(var); + // Change to return copy of value [TODO] + return new Value(*get_value(var)); break; //---------- case VALUE: - return node->value; + // Change to return copy of value [TODO] + return new Value(*node->value); break; //---------- default: diff --git a/src/variables/environment.hpp b/src/variables/environment.hpp index ac035a4..fdeba84 100644 --- a/src/variables/environment.hpp +++ b/src/variables/environment.hpp @@ -12,11 +12,9 @@ class Environment { std::vector vars; Environment() { } ~Environment() { - // Currently this deletes the values of local environment which messes up - // double(double(5)) - // for (uint i = 0; i < size(vars); i++) { - // delete vars[i]; - // } + for (uint i = 0; i < size(vars); i++) { + delete vars[i]; + } } };