diff options
author | Andrew Reynolds <andrew.j.reynolds@gmail.com> | 2020-08-11 21:53:13 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-11 21:53:13 -0500 |
commit | 8b1f36ef24beaf3fa0708c28c53042a5c823c79c (patch) | |
tree | 81b5398a7c01b9936e0db883ff3684cc03ef5328 /src/expr/node_manager.cpp | |
parent | 1c06ccdb1228fc7ef14440e1f29cf016cf5756c9 (diff) |
Final preparations for changing API to use the Node-level datatype (#4863)
This includes all fixes encountered while fixing unit tests with the Term -> Node version of Datatypes in the API.
After all pending PRs are merged, the next step will be to convert the new API to use e.g. CVC4::DType instead of CVC4::Datatype everywhere.
Diffstat (limited to 'src/expr/node_manager.cpp')
-rw-r--r-- | src/expr/node_manager.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/expr/node_manager.cpp b/src/expr/node_manager.cpp index c72de9564..bcddc23f5 100644 --- a/src/expr/node_manager.cpp +++ b/src/expr/node_manager.cpp @@ -582,6 +582,33 @@ std::vector<TypeNode> NodeManager::mkMutualDatatypeTypes( paramTypes, paramReplacements); } + // Check the datatype has been resolved properly. + for (size_t i = 0, ncons = dt.getNumConstructors(); i < ncons; i++) + { + const DTypeConstructor& c = dt[i]; + TypeNode testerType CVC4_UNUSED = c.getTester().getType(); + Assert(c.isResolved() && testerType.isTester() && testerType[0] == ut) + << "malformed tester in datatype post-resolution"; + TypeNode ctorType CVC4_UNUSED = c.getConstructor().getType(); + Assert(ctorType.isConstructor() + && ctorType.getNumChildren() == c.getNumArgs() + 1 + && ctorType.getRangeType() == ut) + << "malformed constructor in datatype post-resolution"; + // for all selectors... + for (size_t j = 0, nargs = c.getNumArgs(); j < nargs; j++) + { + const DTypeSelector& a = c[j]; + TypeNode selectorType = a.getType(); + Assert(a.isResolved() && selectorType.isSelector() + && selectorType[0] == ut) + << "malformed selector in datatype post-resolution"; + // This next one's a "hard" check, performed in non-debug builds + // as well; the other ones should all be guaranteed by the + // CVC4::DType class, but this actually needs to be checked. + AlwaysAssert(!selectorType.getRangeType().isFunctionLike()) + << "cannot put function-like things in datatypes"; + } + } } for (NodeManagerListener* nml : d_listeners) |