From a8fa313ced8e9cef825ea8c6f893a93f4c79eb0b Mon Sep 17 00:00:00 2001
From: sebastien <sebastien@ac1d8469-bf42-47a9-8791-bf33cf982152>
Date: Fri, 17 Oct 2008 12:22:35 +0000
Subject: [PATCH] trunk preprocessor: added error message if model local
 variable (pound sign expression) used outside model scope

git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@2168 ac1d8469-bf42-47a9-8791-bf33cf982152
---
 ParsingDriver.cc | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/ParsingDriver.cc b/ParsingDriver.cc
index 26bb0eda..52e885ec 100644
--- a/ParsingDriver.cc
+++ b/ParsingDriver.cc
@@ -196,6 +196,10 @@ ParsingDriver::add_expression_variable(string *name)
   if (!mod_file->symbol_table.exists(*name))
     mod_file->symbol_table.addSymbol(*name, eModFileLocalVariable);
 
+  // This check must come after the previous one!
+  if (mod_file->symbol_table.getType(*name) == eModelLocalVariable)
+    error("Variable " + *name + " not allowed outside model declaration. Its scope is only inside model.");
+
   NodeID id = data_tree->AddVariable(*name);
 
   delete name;
-- 
GitLab