mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-17 17:58:09 +08:00
fix: reopening table implicitly defined by aot
This commit is contained in:
@@ -1305,6 +1305,8 @@ std::string format_dotted_keys(InputIterator first, const InputIterator last)
|
|||||||
// forward decl for is_valid_forward_table_definition
|
// forward decl for is_valid_forward_table_definition
|
||||||
result<std::pair<std::vector<key>, region>, std::string>
|
result<std::pair<std::vector<key>, region>, std::string>
|
||||||
parse_table_key(location& loc);
|
parse_table_key(location& loc);
|
||||||
|
result<std::pair<std::vector<key>, region>, std::string>
|
||||||
|
parse_array_table_key(location& loc);
|
||||||
template<typename Value>
|
template<typename Value>
|
||||||
result<std::pair<typename Value::table_type, region>, std::string>
|
result<std::pair<typename Value::table_type, region>, std::string>
|
||||||
parse_inline_table(location& loc);
|
parse_inline_table(location& loc);
|
||||||
@@ -1420,6 +1422,21 @@ bool is_valid_forward_table_definition(const Value& fwd, const Value& inserting,
|
|||||||
// the keys are not equivalent. it is allowed.
|
// the keys are not equivalent. it is allowed.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
// nested array-of-table definition implicitly defines tables.
|
||||||
|
// those tables can be reopened.
|
||||||
|
if(const auto atabkeys = parse_array_table_key(def))
|
||||||
|
{
|
||||||
|
// table keys always contains all the nodes from the root.
|
||||||
|
const auto& tks = atabkeys.unwrap().first;
|
||||||
|
if(std::size_t(std::distance(key_first, key_last)) == tks.size() &&
|
||||||
|
std::equal(tks.begin(), tks.end(), key_first))
|
||||||
|
{
|
||||||
|
// the keys are equivalent. it is not allowed.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// the keys are not equivalent. it is allowed.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if(const auto dotkeys = parse_key(def)) // a.b.c = "foo"
|
if(const auto dotkeys = parse_key(def)) // a.b.c = "foo"
|
||||||
{
|
{
|
||||||
// consider the following case.
|
// consider the following case.
|
||||||
|
Reference in New Issue
Block a user