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