From fc2eca936d8bf3f3033d0aab72185cff39b97d62 Mon Sep 17 00:00:00 2001 From: Nicholas Smith Date: Thu, 20 Jun 2024 09:53:06 -0400 Subject: [PATCH] Duplicate check in evaluator (#244) fixes #234 --- src/correction.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/correction.cc b/src/correction.cc index 6bc3669..b41c738 100644 --- a/src/correction.cc +++ b/src/correction.cc @@ -832,12 +832,18 @@ CorrectionSet::CorrectionSet(const JSONObject& json) { for (const auto& item : json.getRequired("corrections")) { if ( ! item.IsObject() ) { throw std::runtime_error("Expected Correction object"); } auto corr = std::make_shared(item.GetObject()); + if ( corrections_.find(corr->name()) != corrections_.end() ) { + throw std::runtime_error("Duplicate Correction name: " + corr->name()); + } corrections_[corr->name()] = corr; } if (auto items = json.getOptional("compound_corrections")) { for (const auto& item : *items) { if ( ! item.IsObject() ) { throw std::runtime_error("Expected CompoundCorrection object"); } auto corr = std::make_shared(item.GetObject(), *this); + if ( compoundcorrections_.find(corr->name()) != compoundcorrections_.end() ) { + throw std::runtime_error("Duplicate CompoundCorrection name: " + corr->name()); + } compoundcorrections_[corr->name()] = corr; } }