From 2b5cc50791a0dead1f0d151414456d859183a375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org> Date: Fri, 11 Apr 2025 17:51:43 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Gracefully=20error=20out=20when?= =?UTF-8?q?=20a=20PAC=20model=20is=20not=20used=20in=20a=20pac=5Fexpectati?= =?UTF-8?q?on=20operator?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By the way, also improve the check for when the pac_expectation is used two times on the same model. (cherry picked from commit 7f22b38a230c3ad1afc76e1c796adccdf4f2538d) --- src/DynamicModel.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc index ea1e6c05..446ed3ef 100644 --- a/src/DynamicModel.cc +++ b/src/DynamicModel.cc @@ -1,5 +1,5 @@ /* - * Copyright © 2003-2024 Dynare Team + * Copyright © 2003-2025 Dynare Team * * This file is part of Dynare. * @@ -1814,7 +1814,7 @@ DynamicModel::analyzePacEquationStructure(const string& name, map<string, string for (auto& equation : equations) if (equation->containsPacExpectation(name)) { - if (!pac_eq_name[name].empty()) + if (pac_eq_name.contains(name)) { cerr << "It is not possible to use 'pac_expectation(" << name << ")' in several equations." << endl; @@ -1913,6 +1913,13 @@ DynamicModel::analyzePacEquationStructure(const string& name, map<string, string move(additive_vars_params_and_constants), move(optim_additive_vars_params_and_constants)}; } + + if (!pac_eq_name.contains(name)) + { + cerr << "ERROR: the model does not contain the 'pac_expectation(" << name << ")' operator." + << endl; + exit(EXIT_FAILURE); + } } int -- GitLab