Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/boost/json/detail/parse_into.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1602,7 +1602,7 @@ class converting_handler<variant_conversion_tag, T, P>

bool on_array_end( system::error_code& ec )
{
if( !inner_active_ )
if( inner_active_ < 0 )
return signal_end(ec);

BOOST_JSON_INVOKE_INNER( array_end_handler_event{}, ec );
Expand Down
12 changes: 12 additions & 0 deletions test/parse_into.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,18 @@ class parse_into_test
"five",
std::map<std::string, double>{ {"one", 1}, {"pi", 3.14} }));

// the closing bracket of an array that belongs to an alternative has to
// be handed to that alternative, not treated as the end of the array
// the variant itself is an element of
testParseInto< Variant< std::vector<std::vector<int>> > >(
std::vector<std::vector<int>>{ {1, 2}, {3} } );
testParseInto< std::vector< Variant<std::vector<int>, int> > >(
{ std::vector<int>{1}, std::vector<int>{2} } );
#if defined(BOOST_DESCRIBE_CXX14)
testParseIntoErrors< Variant<X, int> >(
error::exhausted_variants, object{ {"z", array{ array{0} }} } );
#endif // BOOST_DESCRIBE_CXX14

testParseIntoErrors< Variant<Monostate> >(
error::exhausted_variants, "a" );
testParseIntoErrors< Variant<int> >(
Expand Down
Loading