From 247bcb071417e4f4ce19cff7336f57e846f239aa Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Tue, 11 Dec 2018 22:17:28 +0900 Subject: [PATCH] show error message for inhomogenous array --- toml/parser.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/toml/parser.hpp b/toml/parser.hpp index c36dd53..97dadee 100644 --- a/toml/parser.hpp +++ b/toml/parser.hpp @@ -868,6 +868,13 @@ parse_array(location& loc) if(auto val = parse_value(loc)) { + if(!retval.empty() && retval.front().type() != val.as_ok().type()) + { + throw syntax_error(format_underline( + "[error] toml::parse_array: type of elements should be the " + "same each other.", region(loc, first, loc.iter()), + "inhomogenous types")); + } retval.push_back(std::move(val.unwrap())); } else