From 033e6efa28d141a97fec2e2c2365b99a9b722c9c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Wed, 18 Nov 2020 17:47:37 +0100
Subject: [PATCH] =?UTF-8?q?Do=20not=20crash=20when=20unknown=20symbol=20is?=
 =?UTF-8?q?=20passed=20to=20=E2=80=9Cirf=5Fshocks=E2=80=9D=20option?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Closes: #57
(cherry picked from commit 4b8290faa59b0928e8355d53d15b2188f13f30be)
---
 src/ParsingDriver.cc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/ParsingDriver.cc b/src/ParsingDriver.cc
index bee717bb..c61a1f19 100644
--- a/src/ParsingDriver.cc
+++ b/src/ParsingDriver.cc
@@ -1413,8 +1413,12 @@ ParsingDriver::option_symbol_list(string name_option)
     {
       vector<string> shocks = symbol_list.get_symbols();
       for (auto &shock : shocks)
-        if (mod_file->symbol_table.getType(shock) != SymbolType::exogenous)
-          error("Variables passed to irf_shocks must be exogenous. Caused by: " + shock);
+        {
+          if (!mod_file->symbol_table.exists(shock))
+            error("Unknown symbol: " + shock);
+          if (mod_file->symbol_table.getType(shock) != SymbolType::exogenous)
+            error("Variables passed to irf_shocks must be exogenous. Caused by: " + shock);
+        }
     }
 
   if (name_option.compare("ms.parameters") == 0)
-- 
GitLab