diff --git a/src/ExprNode.cc b/src/ExprNode.cc
index 5bed724364aa3e5f2bfd0f0ade3b11fef1188b33..58d4d888584397d11f831f94bc4d9ca01bbebc40 100644
--- a/src/ExprNode.cc
+++ b/src/ExprNode.cc
@@ -1211,11 +1211,13 @@ VariableNode::writeOutput(ostream &output, ExprNodeOutputType output_type,
           cerr << "VariableNode::writeOutput: Impossible case" << endl;
           exit(EXIT_FAILURE);
         }
+    case SymbolType::unusedEndogenous:
+      cerr << "ERROR: You cannot use an unused endogenous variable in an expression" << endl;
+      exit(EXIT_FAILURE);
     case SymbolType::externalFunction:
     case SymbolType::trend:
     case SymbolType::logTrend:
     case SymbolType::statementDeclaredVariable:
-    case SymbolType::unusedEndogenous:
     case SymbolType::endogenousVAR:
       cerr << "VariableNode::writeOutput: Impossible case" << endl;
       exit(EXIT_FAILURE);