diff --git a/Machines/Utility/ROMCatalogue.cpp b/Machines/Utility/ROMCatalogue.cpp index 643b72a9e..23bf6f1a8 100644 --- a/Machines/Utility/ROMCatalogue.cpp +++ b/Machines/Utility/ROMCatalogue.cpp @@ -27,8 +27,15 @@ Request::Request(Name name, bool optional) { } Request Request::append(Node::Type type, const Request &rhs) { - // Start with the easiest case: this is already an appropriate - // request, and so is the new thing. + // If either side is empty, act appropriately. + if(node.empty() && !rhs.node.empty()) { + return rhs; + } + if(rhs.node.empty()) { + return *this; + } + + // Just copy in the RHS child nodes if types match. if(node.type == type && rhs.node.type == type) { Request new_request = *this; new_request.node.children.insert(new_request.node.children.end(), rhs.node.children.begin(), rhs.node.children.end()); diff --git a/Machines/Utility/ROMCatalogue.hpp b/Machines/Utility/ROMCatalogue.hpp index a9f457b95..5fabd093a 100644 --- a/Machines/Utility/ROMCatalogue.hpp +++ b/Machines/Utility/ROMCatalogue.hpp @@ -240,6 +240,10 @@ struct Request { bool is_optional = false; std::vector children; + bool empty() const { + return type == Type::One && name == Name::None; + } + void add_descriptions(std::vector &) const; bool validate(Map &) const; void visit(