diff --git a/preprocessor/ParsingDriver.cc b/preprocessor/ParsingDriver.cc
index 285bbcf7c63949b672e59ef93ec368b74005172a..a299beb89ed65cbaaa3a1a9d38c5aef37f51b6c1 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;