From bcee9f25a22ab4d9a1211ddeab6b4da251c45adf Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Sun, 10 Oct 2021 20:58:01 +0900 Subject: [PATCH] fix: check if subtable key conflicts --- toml/parser.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/toml/parser.hpp b/toml/parser.hpp index f321e92..62be405 100644 --- a/toml/parser.hpp +++ b/toml/parser.hpp @@ -1459,6 +1459,16 @@ insert_nested_key(typename Value::table_type& root, const Value& v, auto& t = tab->at(k).as_table(); for(const auto& kv : v.as_table()) { + if(tab->at(k).contains(kv.first)) + { + throw syntax_error(format_underline(concat_to_string( + "toml::insert_value: value (\"", + format_dotted_keys(first, last), + "\") already exists."), { + {t.at(kv.first).location(), "already exists here"}, + {v.location(), "this defined twice"} + }), v.location()); + } t[kv.first] = kv.second; } detail::change_region(tab->at(k), key_reg);