Skip to content

Commit 1b82c66

Browse files
committed
Do not fail on Unknown pattern constraints
1 parent 7501ba3 commit 1b82c66

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

booster/library/Booster/Pattern/ApplyEquations.hs

+17-10
Original file line numberDiff line numberDiff line change
@@ -444,19 +444,26 @@ evaluatePattern' pat@Pattern{term, ceilConditions} = withPatternContext pat $ do
444444
throw . SideConditionFalse . collapseAndBools $ pat.constraints
445445
Left unknwon@SMT.SMTSolverUnknown{} -> do
446446
-- unlikely case of an Unknown response to a consistency check.
447-
-- What to do here? fail hard for now.
448-
liftIO $ Exception.throw unknwon
449-
Left other -> liftIO $ Exception.throw other -- fail hard on other SMT errors
447+
-- What to do here? continue for now to preserver the old behaviour.
448+
withPatternContext pat . logWarn . Text.pack $
449+
"Constraints consistency check returns: " <> show unknwon
450+
continue
451+
Left other ->
452+
-- fail hard on SMT error other than @SMT.SMTSolverUnknown@
453+
liftIO $ Exception.throw other
450454
Right True -> do
451455
-- constrains are consistent, continue
452-
newTerm <- withTermContext term $ evaluateTerm' BottomUp term `catch_` keepTopLevelResults
453-
-- after evaluating the term, evaluate all (existing and
454-
-- newly-acquired) constraints, once
455-
traverse_ simplifyAssumedPredicate . predicates =<< getState
456-
-- this may yield additional new constraints, left unevaluated
457-
evaluatedConstraints <- predicates <$> getState
458-
pure Pattern{constraints = evaluatedConstraints, term = newTerm, ceilConditions}
456+
continue
459457
where
458+
continue = do
459+
newTerm <- withTermContext term $ evaluateTerm' BottomUp term `catch_` keepTopLevelResults
460+
-- after evaluating the term, evaluate all (existing and
461+
-- newly-acquired) constraints, once
462+
traverse_ simplifyAssumedPredicate . predicates =<< getState
463+
-- this may yield additional new constraints, left unevaluated
464+
evaluatedConstraints <- predicates <$> getState
465+
pure Pattern{constraints = evaluatedConstraints, term = newTerm, ceilConditions}
466+
460467
-- when TooManyIterations exception occurred while evaluating the top-level term,
461468
-- i.e. not in a recursive evaluation of a side-condition,
462469
-- it is safe to keep the partial result and ignore the exception.

0 commit comments

Comments
 (0)