Error out if an “initval” block appears after an “endval” block (without the “learnt_in=…” option)

Closes: #104
master
Sébastien Villemot 2023-11-14 14:28:30 +01:00
parent cffbb0f4fd
commit ac35ef6101
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
2 changed files with 10 additions and 0 deletions

View File

@ -187,6 +187,12 @@ void
InitValStatement::checkPass([[maybe_unused]] ModFileStructure &mod_file_struct,
[[maybe_unused]] WarningConsolidation &warnings)
{
if (mod_file_struct.endval_present)
{
cerr << "ERROR: an 'initval' block cannot appear after an 'endval' block" << endl; // See #104
exit(EXIT_FAILURE);
}
set<int> exogs = getUninitializedVariables(SymbolType::exogenous);
set<int> endogs = getUninitializedVariables(SymbolType::endogenous);
@ -253,6 +259,8 @@ void
EndValStatement::checkPass([[maybe_unused]] ModFileStructure &mod_file_struct,
[[maybe_unused]] WarningConsolidation &warnings)
{
mod_file_struct.endval_present = true;
set<int> exogs = getUninitializedVariables(SymbolType::exogenous);
set<int> endogs = getUninitializedVariables(SymbolType::endogenous);

View File

@ -157,6 +157,8 @@ struct ModFileStructure
/* Lists symbol IDs of parameters that appear in a “planner_discount” option.
See dynare#1173 for more details. */
set<int> parameters_in_planner_discount;
// Whether an endval block (without the learnt_it=… option) appears
bool endval_present{false};
// Whether a shocks(surprise) block appears
bool shocks_surprise_present{false};
// Whether a shocks(learnt_in=…) block appears