diff --git a/include/boost/json/detail/parse_into.hpp b/include/boost/json/detail/parse_into.hpp index 756388c93..f52fc43fc 100644 --- a/include/boost/json/detail/parse_into.hpp +++ b/include/boost/json/detail/parse_into.hpp @@ -1601,7 +1601,7 @@ class converting_handler 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 ); @@ -1864,10 +1864,14 @@ class into_handler return true; } + // LCOV_EXCL_START + // the top handler is never inside an array, so nested handlers have no + // array end to forward to it bool signal_end(system::error_code&) { return true; } + // LCOV_EXCL_STOP bool on_document_begin( system::error_code& ) { diff --git a/test/parse_into.cpp b/test/parse_into.cpp index 2fa778184..b311d7771 100644 --- a/test/parse_into.cpp +++ b/test/parse_into.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -479,6 +480,16 @@ class parse_into_test testParseInto< std::vector< Variant > >( {1, 2, 3, "four", 5, "six", "seven", 8}); + // an array-like first alternative nested in a composite + testParseInto< std::vector< Variant, int> > >( + { std::vector{1}, 2 } ); + testParseInto< std::map, int> > >( + { { "a", std::vector{1, 2} }, { "b", 3 } } ); + + // an incomplete array must not satisfy a fixed-size alternative + testParseIntoErrors< Variant< std::array > >( + error::exhausted_variants, {1, 2} ); + using V = Variant< std::vector< int >, std::tuple< int, std::string, std::map >,