summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>2021-04-08 13:22:29 -0500
committerGitHub <noreply@github.com>2021-04-08 18:22:29 +0000
commit3d83a435f3d9108c6457d4058ba5262d0d72634e (patch)
tree3f4aea07663cebcfff2159332cab24f7a444150d /src
parentcd8fd2e4909513b4253ce8f9aa272eb87ae6bf83 (diff)
Use exceptions when constructing malformed datatypes (#6303)
Fixes #5150.
Diffstat (limited to 'src')
-rw-r--r--src/expr/node_manager.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/expr/node_manager.cpp b/src/expr/node_manager.cpp
index 4b95e08df..dd372a81d 100644
--- a/src/expr/node_manager.cpp
+++ b/src/expr/node_manager.cpp
@@ -599,9 +599,11 @@ std::vector<TypeNode> NodeManager::mkMutualDatatypeTypes(
typeNode = mkTypeNode(kind::PARAMETRIC_DATATYPE, params);
}
- AlwaysAssert(nameResolutions.find(dtp->getName()) == nameResolutions.end())
- << "cannot construct two datatypes at the same time "
- "with the same name";
+ if (nameResolutions.find(dtp->getName()) != nameResolutions.end())
+ {
+ throw Exception(
+ "cannot construct two datatypes at the same time with the same name");
+ }
nameResolutions.insert(std::make_pair(dtp->getName(), typeNode));
dtts.push_back(typeNode);
}
@@ -624,9 +626,11 @@ std::vector<TypeNode> NodeManager::mkMutualDatatypeTypes(
std::string name = ut.getAttribute(expr::VarNameAttr());
std::map<std::string, TypeNode>::const_iterator resolver =
nameResolutions.find(name);
- AlwaysAssert(resolver != nameResolutions.end())
- << "cannot resolve type " + name
- + "; it's not among the datatypes being defined";
+ if (resolver == nameResolutions.end())
+ {
+ throw Exception("cannot resolve type " + name
+ + "; it's not among the datatypes being defined");
+ }
// We will instruct the Datatype to substitute "ut" (the
// unresolved SortType used as a placeholder in complex types)
// with "(*resolver).second" (the TypeNode we created in the
@@ -679,8 +683,10 @@ std::vector<TypeNode> NodeManager::mkMutualDatatypeTypes(
// This next one's a "hard" check, performed in non-debug builds
// as well; the other ones should all be guaranteed by the
// cvc5::DType class, but this actually needs to be checked.
- AlwaysAssert(!selectorType.getRangeType().isFunctionLike())
- << "cannot put function-like things in datatypes";
+ if (selectorType.getRangeType().isFunctionLike())
+ {
+ throw Exception("cannot put function-like things in datatypes");
+ }
}
}
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback