Skip to content

fix array end handling for first variant alternative in parse_into - #1195

Open
Ramya-9353 wants to merge 1 commit into
boostorg:developfrom
Ramya-9353:variant-array-end
Open

fix array end handling for first variant alternative in parse_into#1195
Ramya-9353 wants to merge 1 commit into
boostorg:developfrom
Ramya-9353:variant-array-end

Conversation

@Ramya-9353

Copy link
Copy Markdown
Contributor

Repro: parse_into a std::vector<variant2::variant<std::vector<int>, int>> from [[1],2]; it fails with error::not_array, while the alternatives-swapped variant<int, std::vector<int>> accepts the same document. A variant<std::array<int,3>> parsed from [1] reports success and leaves two elements unwritten; nesting such a variant in a map trips the BOOST_ASSERT(false) path in handler_error_base::on_object_end on debug builds.
Cause: the variant handler's on_array_end tests its int sentinel with !inner_active_, which is only true for index 0, so while the first alternative is mid-array its closing bracket is routed to signal_end and terminates the variant instead of reaching the active alternative. The completeness check of the aborted alternative never runs.
Fix: compare inner_active_ < 0, matching the sentinel checks elsewhere in the file. The added tests fail before the change and pass after.

🤖 Generated with Claude Code

https://claude.ai/code/session_01C7uBZYRF8M5U3w49QLn4nW

@cppalliance-bot

Copy link
Copy Markdown

GCOVR code coverage report https://1195.json.prtest2.cppalliance.org/gcovr/index.html
LCOV code coverage report https://1195.json.prtest2.cppalliance.org/genhtml/index.html
Coverage Diff Report https://1195.json.prtest2.cppalliance.org/diff-report/index.html

Build time: 2026-09-04 18:31:48 UTC

@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.69%. Comparing base (82398f9) to head (a730f74).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1195      +/-   ##
===========================================
- Coverage    93.72%   93.69%   -0.03%     
===========================================
  Files           85       85              
  Lines         8981     8981              
===========================================
- Hits          8417     8415       -2     
- Misses         564      566       +2     
Files with missing lines Coverage Δ
include/boost/json/detail/parse_into.hpp 99.00% <100.00%> (-0.34%) ⬇️

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 82398f9...a730f74. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cppalliance-bot

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants