From 9af724825c393b3fe209564ddc4d75dfed953b5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Tue, 26 Feb 2013 12:37:35 +0100 Subject: [PATCH] estimated_params: check that no symbol is declared twice in the block Closes #296 --- ComputingTasks.cc | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/ComputingTasks.cc b/ComputingTasks.cc index 92a4b7d5..4ca31ed4 100644 --- a/ComputingTasks.cc +++ b/ComputingTasks.cc @@ -483,6 +483,37 @@ EstimatedParamsStatement::checkPass(ModFileStructure &mod_file_struct, WarningCo // We don't have enough information to compute the numerical value, skip the test } } + + // Check that no parameter/endogenous is declared twice in the block + set already_declared; + set > already_declared_corr; + for (vector::const_iterator it = estim_params_list.begin(); + it != estim_params_list.end(); it++) + { + if (it->type == 3) // Correlation + { + // Use lexical ordering for the pair of symbols + pair x = it->name < it->name2 ? make_pair(it->name, it->name2) : make_pair(it->name2, it->name); + + if (already_declared_corr.find(x) == already_declared_corr.end()) + already_declared_corr.insert(x); + else + { + cerr << "ERROR: in `estimated_params' block, the correlation between " << it->name << " and " << it->name2 << " is declared twice." << endl; + exit(EXIT_FAILURE); + } + } + else + { + if (already_declared.find(it->name) == already_declared.end()) + already_declared.insert(it->name); + else + { + cerr << "ERROR: in `estimated_params' block, the symbol " << it->name << " is declared twice." << endl; + exit(EXIT_FAILURE); + } + } + } } void