From a730f746bcb14e86f3ce97778c79740330bacc9b Mon Sep 17 00:00:00 2001 From: Ramya Eliger Date: Fri, 4 Sep 2026 23:02:41 +0530 Subject: [PATCH 1/3] fix array end handling for first variant alternative in parse_into Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01C7uBZYRF8M5U3w49QLn4nW --- include/boost/json/detail/parse_into.hpp | 2 +- test/parse_into.cpp | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/boost/json/detail/parse_into.hpp b/include/boost/json/detail/parse_into.hpp index 756388c93..6d370b041 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 ); diff --git a/test/parse_into.cpp b/test/parse_into.cpp index 2fa778184..3ac30f182 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} ); + using V = Variant< std::vector< int >, std::tuple< int, std::string, std::map >, From 1a0e3d23f82dd1d3ed550811861db79a4ad43936 Mon Sep 17 00:00:00 2001 From: Ramya Eliger Date: Fri, 18 Sep 2026 18:02:21 +0530 Subject: [PATCH 2/3] exclude into_handler::signal_end from coverage The top handler is never inside an array, so nested handlers have no array end to forward to it. The function was only reached through the variant handler's on_array_end misrouting. --- include/boost/json/detail/parse_into.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/boost/json/detail/parse_into.hpp b/include/boost/json/detail/parse_into.hpp index 6d370b041..f52fc43fc 100644 --- a/include/boost/json/detail/parse_into.hpp +++ b/include/boost/json/detail/parse_into.hpp @@ -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& ) { From bd3af545df52f4e264d1f8b83dbfa47b11913d83 Mon Sep 17 00:00:00 2001 From: Ramya Eliger Date: Fri, 25 Sep 2026 22:57:01 +0530 Subject: [PATCH 3/3] use an array sample in the incomplete-alternative test --- test/parse_into.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parse_into.cpp b/test/parse_into.cpp index 3ac30f182..b311d7771 100644 --- a/test/parse_into.cpp +++ b/test/parse_into.cpp @@ -488,7 +488,7 @@ class parse_into_test // an incomplete array must not satisfy a fixed-size alternative testParseIntoErrors< Variant< std::array > >( - error::exhausted_variants, {1} ); + error::exhausted_variants, {1, 2} ); using V = Variant< std::vector< int >,