From 62807f81653b45bf18e16d0adc86ba0e1190c410 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Fri, 28 Feb 2014 18:01:03 +0100
Subject: [PATCH] Verify types of the symbols in
 estimated_params{,_init,_bounds} statements.

Closes #624
(cherry picked from commit 9973c0f8fc6845bc6010aa4d85a237135361fa39)
---
 preprocessor/ParsingDriver.cc | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/preprocessor/ParsingDriver.cc b/preprocessor/ParsingDriver.cc
index 5e519491bb..aa8b3796bf 100644
--- a/preprocessor/ParsingDriver.cc
+++ b/preprocessor/ParsingDriver.cc
@@ -1214,8 +1214,23 @@ ParsingDriver::add_estimated_params_element()
   if (estim_params.name != "dsge_prior_weight")
     {
       check_symbol_existence(estim_params.name);
-      if (estim_params.name2.size() > 0)
-        check_symbol_existence(estim_params.name2);
+      SymbolType type = mod_file->symbol_table.getType(estim_params.name);
+      switch (estim_params.type)
+        {
+        case 1:
+          if (type != eEndogenous && type != eExogenous)
+            error(estim_params.name + " must be an endogenous or an exogenous variable");
+          break;
+        case 2:
+          check_symbol_is_parameter(&estim_params.name);
+          break;
+        case 3:
+          check_symbol_existence(estim_params.name2);
+          SymbolType type2 = mod_file->symbol_table.getType(estim_params.name2);
+          if ((type != eEndogenous && type != eExogenous) || type != type2)
+            error(estim_params.name + " and " + estim_params.name2 + " must either be both endogenous variables or both exogenous");
+          break;
+        }
     }
   estim_params_list.push_back(estim_params);
   estim_params.init(*data_tree);
-- 
GitLab