@@ -463,16 +463,15 @@ evaluatePattern' ::
463
463
EquationT io Pattern
464
464
evaluatePattern' pat@ Pattern {term, constraints, ceilConditions} = withPatternContext pat $ do
465
465
solver <- (. smtSolver) <$> getConfig
466
- -- check the pattern's constraints for consistency, reporting an error if they are Bottom
467
- withContext CtxConstraint
468
- . withContext CtxDetail
469
- . withTermContext (coerce $ collapseAndBools constraints)
470
- $ pure ()
471
- consistent <- withContext CtxConstraint $ SMT. isSat solver constraints
472
- withContext CtxConstraint $ do
473
- logMessage $
474
- " Constraints consistency check returns: " <> show consistent
475
-
466
+ -- check the pattern's constraints for satisfiability to ensure they are consistent
467
+ consistent <-
468
+ withContext CtxConstraint $ do
469
+ withContext CtxDetail . withTermContext (coerce $ collapseAndBools constraints) $ pure ()
470
+ consistent <- SMT. isSat solver constraints
471
+ withContext CtxConstraint $
472
+ logMessage $
473
+ " Constraints consistency check returns: " <> show consistent
474
+ pure consistent
476
475
case consistent of
477
476
Right False -> do
478
477
-- the constraints are unsatisfiable, which means that the patten is Bottom
@@ -482,23 +481,21 @@ evaluatePattern' pat@Pattern{term, constraints, ceilConditions} = withPatternCon
482
481
-- continue to preserver the old behaviour.
483
482
withContext CtxConstraint . logWarn . Text. pack $
484
483
" Constraints consistency UNKNOWN: " <> show consistent
485
- continue
484
+ pure ()
486
485
Left other ->
487
486
-- fail hard on SMT error other than @SMT.SMTSolverUnknown@
488
487
liftIO $ Exception. throw other
489
- Right True -> do
488
+ Right True ->
490
489
-- constraints are consistent, continue
491
- continue
492
- where
493
- continue = do
494
- newTerm <- withTermContext term $ evaluateTerm' BottomUp term `catch_` keepTopLevelResults
495
- -- after evaluating the term, evaluate all (existing and
496
- -- newly-acquired) constraints, once
497
- traverse_ simplifyAssumedPredicate . predicates =<< getState
498
- -- this may yield additional new constraints, left unevaluated
499
- evaluatedConstraints <- predicates <$> getState
500
- pure Pattern {constraints = evaluatedConstraints, term = newTerm, ceilConditions}
490
+ pure ()
501
491
492
+ newTerm <- withTermContext term $ evaluateTerm' BottomUp term `catch_` keepTopLevelResults
493
+ -- after evaluating the term, evaluate all (existing and newly-acquired) constraints, once
494
+ traverse_ simplifyAssumedPredicate . predicates =<< getState
495
+ -- this may yield additional new constraints, left unevaluated
496
+ evaluatedConstraints <- predicates <$> getState
497
+ pure Pattern {constraints = evaluatedConstraints, term = newTerm, ceilConditions}
498
+ where
502
499
-- when TooManyIterations exception occurred while evaluating the top-level term,
503
500
-- i.e. not in a recursive evaluation of a side-condition,
504
501
-- it is safe to keep the partial result and ignore the exception.
0 commit comments