From d185ff9b2048a8a07d3b1c8983ade61603c82890 Mon Sep 17 00:00:00 2001 From: niansa Date: Sun, 14 Feb 2021 19:03:14 +0100 Subject: [PATCH] Fixed evaluation dereference being cached in function --- main.cpp | 4 ++-- pilang.cpp | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index ff3affd..ff9fd9c 100644 --- a/main.cpp +++ b/main.cpp @@ -28,9 +28,9 @@ int main() { std::cout << " "; } catch (exceptions::exit& e) { return e.code; - } /*catch (exceptions::langException& e) { + } catch (exceptions::langException& e) { std::cout << "E: Language exception: " << e.what() << std::endl; line.clear(); - }*/ + } } } diff --git a/pilang.cpp b/pilang.cpp index 5afca21..4919cd3 100644 --- a/pilang.cpp +++ b/pilang.cpp @@ -321,10 +321,12 @@ namespace Pilang3 { scope[argumentNames[args_idx - 1]] = std::make_shared(args[args_idx - 1]); } env->variableScope.push(scope); // Start new scope - // Execute all evaluations + // Copy, derefer and execute all evaluations for (auto& evaluation : evalChain) { - evaluation->derefer(env); - fres = evaluation->execute(env); + auto thiseval = Evaluation(*evaluation); + thiseval.derefer(env); + fres = thiseval.execute(env); + // Return on return if (fres.type == Variable::id_retval) { auto fresdata = std::get(fres.data); env->variableScope.pop(); // End scope