From 8ae7f81fd990d261058de21312ff0e0c290fde90 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Fri, 22 Feb 2019 17:30:09 +0100
Subject: [PATCH] Fix bug with var_expectation nodes introduced in
 38152c34a478e2ecc1094d3d210dd4cf12a7edd4

We must provide a return value for
VarExpectationNode::maxLagWithDiffsExpanded().

Return zero, which will lead to the right overall result even if it is not
strictly the right choice (see the comment in the code).
---
 src/ExprNode.cc | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/ExprNode.cc b/src/ExprNode.cc
index b9affd46..4843c1b8 100644
--- a/src/ExprNode.cc
+++ b/src/ExprNode.cc
@@ -8775,8 +8775,14 @@ VarExpectationNode::maxLag() const
 int
 VarExpectationNode::maxLagWithDiffsExpanded() const
 {
-  cerr << "VarExpectationNode::maxLagWithDiffsExpanded not implemented." << endl;
-  exit(EXIT_FAILURE);
+  /* This node will be substituted by lagged variables, so in theory we should
+     return a strictly positive value. But from here this value is not easy to
+     compute.
+     We return 0, because currently this function is only called from
+     DynamicModel::setLeadsLagsOrig(), and the maximum lag will nevertheless be
+     correctly computed because the maximum lag of the VAR will be taken into
+     account via the corresponding equations. */
+  return 0;
 }
 
 expr_t
@@ -9238,6 +9244,7 @@ PacExpectationNode::maxLag() const
 int
 PacExpectationNode::maxLagWithDiffsExpanded() const
 {
+  // Same comment as in VarExpectationNode::maxLagWithDiffsExpanded()
   return 0;
 }
 
-- 
GitLab