fix: report an error if a table is inserted to aot

This commit is contained in:
ToruNiina 2022-06-22 21:48:37 +09:00
parent 2a987ac9ea
commit 8e95891af1

View File

@ -1716,6 +1716,29 @@ insert_nested_key(typename Value::table_type& root, const Value& v,
{v.location(), "inserting this"}
}), v.location());
}
if(a.empty())
{
throw syntax_error(format_underline(concat_to_string(
"toml::insert_value: table (\"",
format_dotted_keys(first, last), "\") conflicts with"
" existing value"), {
{tab->at(k).location(), std::string("this array is not insertable")},
{v.location(), std::string("appending it to the statically sized array")}
}), v.location());
}
if(const auto ptr = detail::get_region(a.at(0)))
{
if(ptr->str().substr(0,2) != "[[")
{
throw syntax_error(format_underline(concat_to_string(
"toml::insert_value: a table (\"",
format_dotted_keys(first, last), "\") cannot be "
"inserted to an existing inline array-of-tables"), {
{tab->at(k).location(), std::string("this array of table has a static size")},
{v.location(), std::string("appending it to the statically sized array")}
}), v.location());
}
}
tab = std::addressof(a.back().as_table());
}
else