From 0b8e3345fc0f527ac7cf2a1560a0951280570d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org> Date: Tue, 20 Jul 2021 14:56:48 +0200 Subject: [PATCH] Ensure that a tag is not declared twice in the same equation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously the first value was silently ignored. It’s better to explicitly forbid this. If this change creates problems (since it’s a change in an undocumented behaviour), we can turn it into a warning. --- src/ParsingDriver.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ParsingDriver.cc b/src/ParsingDriver.cc index c3fc77f4..c615eb48 100644 --- a/src/ParsingDriver.cc +++ b/src/ParsingDriver.cc @@ -279,6 +279,9 @@ ParsingDriver::add_predetermined_variable(const string &name) void ParsingDriver::add_equation_tags(string key, string value) { + if (eq_tags.find(key) != eq_tags.end()) + error("Tag '" + key + "' cannot be declared twice for the same equation"); + eq_tags[key] = value; transform(key.begin(), key.end(), key.begin(), ::tolower); -- GitLab