Skip to content

Commit 32b08b7

Browse files
committed
Do not fail on Unknown pattern constraints
1 parent f368038 commit 32b08b7

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

booster/library/Booster/Pattern/ApplyEquations.hs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -472,19 +472,26 @@ evaluatePattern' pat@Pattern{term, ceilConditions} = withPatternContext pat $ do
472472
throw . SideConditionFalse . collapseAndBools $ pat.constraints
473473
Left unknwon@SMT.SMTSolverUnknown{} -> do
474474
-- unlikely case of an Unknown response to a consistency check.
475-
-- What to do here? fail hard for now.
476-
liftIO $ Exception.throw unknwon
477-
Left other -> liftIO $ Exception.throw other -- fail hard on other SMT errors
475+
-- What to do here? continue for now to preserver the old behaviour.
476+
withPatternContext pat . logWarn . Text.pack $
477+
"Constraints consistency check returns: " <> show unknwon
478+
continue
479+
Left other ->
480+
-- fail hard on SMT error other than @SMT.SMTSolverUnknown@
481+
liftIO $ Exception.throw other
478482
Right True -> do
479483
-- constrains are consistent, continue
480-
newTerm <- withTermContext term $ evaluateTerm' BottomUp term `catch_` keepTopLevelResults
481-
-- after evaluating the term, evaluate all (existing and
482-
-- newly-acquired) constraints, once
483-
traverse_ simplifyAssumedPredicate . predicates =<< getState
484-
-- this may yield additional new constraints, left unevaluated
485-
evaluatedConstraints <- predicates <$> getState
486-
pure Pattern{constraints = evaluatedConstraints, term = newTerm, ceilConditions}
484+
continue
487485
where
486+
continue = do
487+
newTerm <- withTermContext term $ evaluateTerm' BottomUp term `catch_` keepTopLevelResults
488+
-- after evaluating the term, evaluate all (existing and
489+
-- newly-acquired) constraints, once
490+
traverse_ simplifyAssumedPredicate . predicates =<< getState
491+
-- this may yield additional new constraints, left unevaluated
492+
evaluatedConstraints <- predicates <$> getState
493+
pure Pattern{constraints = evaluatedConstraints, term = newTerm, ceilConditions}
494+
488495
-- when TooManyIterations exception occurred while evaluating the top-level term,
489496
-- i.e. not in a recursive evaluation of a side-condition,
490497
-- it is safe to keep the partial result and ignore the exception.

0 commit comments

Comments
 (0)