@@ -830,16 +830,15 @@ void RPCResult::ToSections(Sections& sections, const OuterType outer_type, const
830830 return ;
831831 }
832832 case Type::OBJ_DYN:
833- case Type::OBJ_EMPTY: {
834- sections.PushSection ({indent + maybe_key + " {}" , Description (" empty JSON object" )});
835- return ;
836- }
837833 case Type::OBJ: {
834+ if (m_inner.empty ()) {
835+ sections.PushSection ({indent + maybe_key + " {}" , Description (" empty JSON object" )});
836+ return ;
837+ }
838838 sections.PushSection ({indent + maybe_key + " {" , Description (" json object" )});
839839 for (const auto & i : m_inner) {
840840 i.ToSections (sections, OuterType::OBJ, current_indent + 2 );
841841 }
842- CHECK_NONFATAL (!m_inner.empty ());
843842 if (m_type == Type::OBJ_DYN && m_inner.back ().m_type != Type::ELISION) {
844843 // If the dictionary keys are dynamic, use three dots for continuation
845844 sections.PushSection ({indent_next + " ..." , " " });
@@ -883,14 +882,24 @@ bool RPCResult::MatchesType(const UniValue& result) const
883882 return UniValue::VARR == result.getType ();
884883 }
885884 case Type::OBJ_DYN:
886- case Type::OBJ_EMPTY:
887885 case Type::OBJ: {
888886 return UniValue::VOBJ == result.getType ();
889887 }
890888 } // no default case, so the compiler can warn about missing cases
891889 CHECK_NONFATAL (false );
892890}
893891
892+ void RPCResult::CheckInnerDoc () const
893+ {
894+ if (m_type == Type::OBJ) {
895+ // May or may not be empty
896+ return ;
897+ }
898+ // Everything else must either be empty or not
899+ const bool inner_needed{m_type == Type::ARR || m_type == Type::ARR_FIXED || m_type == Type::OBJ_DYN};
900+ CHECK_NONFATAL (inner_needed != m_inner.empty ());
901+ }
902+
894903std::string RPCArg::ToStringObj (const bool oneline) const
895904{
896905 std::string res;
0 commit comments