bool DatatypeConstructorDecl::isNullHelper() const { return d_ctor == nullptr; }
+bool DatatypeConstructorDecl::isResolved() const
+{
+ return d_ctor == nullptr || d_ctor->isResolved();
+}
+
/* DatatypeDecl ------------------------------------------------------------- */
DatatypeDecl::DatatypeDecl() : d_solver(nullptr), d_dtype(nullptr) {}
CVC5_API_ARG_CHECK_EXPECTED(ctors.size() > 0, ctors)
<< "a datatype declaration with at least one constructor";
CVC5_API_SOLVER_CHECK_DTCTORDECLS(ctors);
+ for (size_t i = 0, size = ctors.size(); i < size; i++)
+ {
+ CVC5_API_CHECK(!ctors[i].isResolved())
+ << "cannot use a constructor for multiple datatypes";
+ }
//////// all checks before this line
DatatypeDecl dtdecl(this, symbol);
for (size_t i = 0, size = ctors.size(); i < size; i++)
*/
bool isNullHelper() const;
+ /**
+ * Is the underlying constructor resolved (i.e. has it been used to declare
+ * a datatype already)?
+ */
+ bool isResolved() const;
+
/**
* The associated solver object.
*/
ASSERT_NO_FATAL_FAILURE(distinct.getOp());
}
+TEST_F(TestApiBlackSolver, doubleUseCons)
+{
+ DatatypeConstructorDecl ctor1 = d_solver.mkDatatypeConstructorDecl("_x21");
+ DatatypeConstructorDecl ctor2 = d_solver.mkDatatypeConstructorDecl("_x31");
+ Sort s3 = d_solver.declareDatatype(std::string("_x17"), {ctor1, ctor2});
+
+ ASSERT_THROW(d_solver.declareDatatype(std::string("_x86"), {ctor1, ctor2}),
+ CVC5ApiException);
+}
+
} // namespace test
} // namespace cvc5