diff --git a/src/DynamicModel.cc b/src/DynamicModel.cc index c0177d18e0007b66f5afbdbe204d4a120887b01d..7c25804a8b8c4cef5524c8507f29965c74eb51dd 100644 --- a/src/DynamicModel.cc +++ b/src/DynamicModel.cc @@ -7179,3 +7179,15 @@ DynamicModel::substituteVarExpectation(const map<string, expr_t> &subst_table) for (auto &equation : equations) equation = dynamic_cast<BinaryOpNode *>(equation->substituteVarExpectation(subst_table)); } + +void +DynamicModel::checkNoRemainingPacExpectation() const +{ + for (size_t eq = 0; eq < equations.size(); eq++) + if (equations[eq]->containsPacExpectation()) + { + cerr << "ERROR: in equation " << equation_tags.getTagValueByEqnAndKey(eq, "name") + << ", the pac_expectation operator references an unknown pac_model" << endl; + exit(EXIT_FAILURE); + } +} diff --git a/src/DynamicModel.hh b/src/DynamicModel.hh index 1fd3caf0d7788c77e4ff6940dc790f6ace68ad7d..51b5fae1f8994ec4e31307e6c4e0b241ad7ada99 100644 --- a/src/DynamicModel.hh +++ b/src/DynamicModel.hh @@ -557,6 +557,10 @@ public: //! Fills eval context with values of model local variables and auxiliary variables void fillEvalContext(eval_context_t &eval_context) const; + /*! Checks that all pac_expectation operators have been substituted, error + out otherwise */ + void checkNoRemainingPacExpectation() const; + auto getStaticOnlyEquationsInfo() const { diff --git a/src/ModFile.cc b/src/ModFile.cc index 049ac4563719100894ef8d5731fb7f3b96a4031b..cf940e5f033943a3db03b0c9937cbfe68ff5b034 100644 --- a/src/ModFile.cc +++ b/src/ModFile.cc @@ -502,6 +502,7 @@ ModFile::transformPass(bool nostrict, bool stochastic, bool compute_xrefs, bool eqtag_and_lag, nonstationary, pms->growth); dynamic_model.substitutePacExpectation(pms->name); } + dynamic_model.checkNoRemainingPacExpectation(); dynamic_model.addEquationsForVar();