Do not exit when value/model/unsat-core/proof is requested at wrong time, for bug...
authorajreynol <andrew.j.reynolds@gmail.com>
Mon, 10 Jul 2017 22:40:56 +0000 (17:40 -0500)
committerajreynol <andrew.j.reynolds@gmail.com>
Mon, 10 Jul 2017 22:41:03 +0000 (17:41 -0500)
src/smt/smt_engine.cpp

index 6960c4684ab96468bcb7bdc3382b0a44356eba77..f6b17e4cbde7c5b7f6337788fa7bf3e892c38996 100644 (file)
@@ -4775,7 +4775,9 @@ Expr SmtEngine::getValue(const Expr& ex) const throw(ModalException, TypeCheckin
      d_problemExtended) {
     const char* msg =
       "Cannot get value unless immediately preceded by SAT/INVALID or UNKNOWN response.";
-    throw ModalException(msg);
+    //throw ModalException(msg);
+    Warning() << CommandFailure(msg);
+    return ex;
   }
 
   // Substitute out any abstract values in ex.
@@ -4884,7 +4886,9 @@ CVC4::SExpr SmtEngine::getAssignment() {
     const char* msg =
       "Cannot get the current assignment unless immediately "
       "preceded by SAT/INVALID or UNKNOWN response.";
-    throw ModalException(msg);
+    //throw ModalException(msg);
+    Warning() << CommandFailure(msg);
+    return SExpr(vector<SExpr>());
   }
 
   if(d_assignments == NULL) {
@@ -4979,7 +4983,9 @@ Model* SmtEngine::getModel() {
     const char* msg =
       "Cannot get the current model unless immediately "
       "preceded by SAT/INVALID or UNKNOWN response.";
-    throw ModalException(msg);
+    //throw ModalException(msg);
+    Warning() << CommandFailure(msg);
+    return NULL;
   }
   if(!options::produceModels()) {
     const char* msg =
@@ -5239,7 +5245,9 @@ UnsatCore SmtEngine::getUnsatCore() {
   if(d_status.isNull() ||
      d_status.asSatisfiabilityResult() != Result::UNSAT ||
      d_problemExtended) {
-    throw ModalException("Cannot get an unsat core unless immediately preceded by UNSAT/VALID response.");
+    //throw ModalException("Cannot get an unsat core unless immediately preceded by UNSAT/VALID response.");
+    Warning() << CommandFailure("Cannot get an unsat core unless immediately preceded by UNSAT/VALID response.");
+    return UnsatCore();
   }
 
   d_proofManager->traceUnsatCore();// just to trigger core creation
@@ -5263,7 +5271,9 @@ Proof* SmtEngine::getProof() {
   if(d_status.isNull() ||
      d_status.asSatisfiabilityResult() != Result::UNSAT ||
      d_problemExtended) {
-    throw ModalException("Cannot get a proof unless immediately preceded by UNSAT/VALID response.");
+    //throw ModalException("Cannot get a proof unless immediately preceded by UNSAT/VALID response.");
+    Warning() << CommandFailure("Cannot get a proof unless immediately preceded by UNSAT/VALID response.");
+    return NULL;
   }
 
   return ProofManager::getProof(this);