From d008113d69137b4600e61758df1721c534c6a9c1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Wed, 27 Nov 2019 17:26:16 +0100
Subject: [PATCH] Forbid exogenous and exogenous deterministic variables in
 STEADY_STATE operator

Closes: dynare#825
---
 src/ParsingDriver.cc | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/ParsingDriver.cc b/src/ParsingDriver.cc
index 0aea25ad..58c1902f 100644
--- a/src/ParsingDriver.cc
+++ b/src/ParsingDriver.cc
@@ -2902,6 +2902,15 @@ ParsingDriver::add_erf(expr_t arg1)
 expr_t
 ParsingDriver::add_steady_state(expr_t arg1)
 {
+  // Forbid exogenous variables, see dynare#825
+  set<int> r;
+  arg1->collectVariables(SymbolType::exogenous, r);
+  if (r.size() > 0)
+    error("Exogenous variables are not allowed in the context of the STEADY_STATE() operator.");
+  arg1->collectVariables(SymbolType::exogenousDet, r);
+  if (r.size() > 0)
+    error("Exogenous deterministic variables are not allowed in the context of the STEADY_STATE() operator.");
+
   return data_tree->AddSteadyState(arg1);
 }
 
-- 
GitLab