From 7729c4382df67c3d3482f08228d323a8d3564c5e Mon Sep 17 00:00:00 2001
From: sebastien <sebastien@ac1d8469-bf42-47a9-8791-bf33cf982152>
Date: Mon, 27 Oct 2008 13:09:01 +0000
Subject: [PATCH] 4.0: merged r2168 changeset (forbid usage of model local
 variables outside model scope)

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

diff --git a/preprocessor/ParsingDriver.cc b/preprocessor/ParsingDriver.cc
index 285bbcf7c6..a299beb89e 100644
--- a/preprocessor/ParsingDriver.cc
+++ b/preprocessor/ParsingDriver.cc
@@ -207,6 +207,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