From 68850536e6debfe40b55879455e16f55d2aff8bc Mon Sep 17 00:00:00 2001
From: Houtan Bastani <houtan@dynare.org>
Date: Tue, 5 Mar 2019 15:20:32 +0100
Subject: [PATCH] stop processing if we substitute a unary op with a lead.
 closes #20

---
 src/ExprNode.cc | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/ExprNode.cc b/src/ExprNode.cc
index ced32d14..27b1253a 100644
--- a/src/ExprNode.cc
+++ b/src/ExprNode.cc
@@ -3489,6 +3489,12 @@ UnaryOpNode::substituteUnaryOpNodes(DataTree &static_datatree, diff_table_t &nod
   if (it == nodes.end())
     return buildSimilarUnaryOpNode(argsubst, datatree);
 
+  if (arg->maxLead() > 0)
+    {
+      cerr << "Cannot substitue unary operations that contain leads" << endl;
+      exit(EXIT_FAILURE);
+    }
+
   string unary_op = "";
   switch (op_code)
     {
-- 
GitLab