diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 7a1030c76..629a3edef 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -916,6 +916,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec default: // LCOV_EXCL_LINE JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE } + JSON_ASSERT(m_type == val.type()); set_parents(); assert_invariant(); } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 91b31eda4..c342172b4 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -19190,6 +19190,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec default: // LCOV_EXCL_LINE JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE } + JSON_ASSERT(m_type == val.type()); set_parents(); assert_invariant(); }