From 113b8799f3e1c05ecd0469755a74e2cb964fffe0 Mon Sep 17 00:00:00 2001
From: Houtan Bastani <houtan@dynare.org>
Date: Wed, 13 Sep 2017 10:16:19 +0200
Subject: [PATCH] preprocessor: histval should only accept lag values <= 0.
 closes #1510

---
 ParsingDriver.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ParsingDriver.cc b/ParsingDriver.cc
index 52f1177b..30c4336a 100644
--- a/ParsingDriver.cc
+++ b/ParsingDriver.cc
@@ -546,6 +546,9 @@ ParsingDriver::hist_val(string *name, string *lag, expr_t rhs)
     error("histval: " + *name + " should be an endogenous or exogenous variable");
 
   int ilag = atoi(lag->c_str());
+  if (ilag > 0)
+    error("histval: the lag on " + *name + " should be less than or equal to 0");
+
   pair<int, int> key(symb_id, ilag);
 
   if (mod_file->dynamic_model.minLagForSymbol(symb_id) > ilag - 1)
-- 
GitLab