@@ -102,7 +102,7 @@ catch_ (EquationT op) hdlr = EquationT $ do
102
102
103
103
data EquationFailure
104
104
= IndexIsNone Term
105
- | TooManyIterations Int Int Term Term
105
+ | TooManyIterations Int Term Term
106
106
| EquationLoop [Term ]
107
107
| TooManyRecursions [Term ]
108
108
| SideConditionFalse Predicate
@@ -114,10 +114,9 @@ instance Pretty (PrettyWithModifiers mods EquationFailure) where
114
114
pretty (PrettyWithModifiers f) = case f of
115
115
IndexIsNone t ->
116
116
" Index 'None' for term " <> pretty' @ mods t
117
- TooManyIterations depth count start end ->
117
+ TooManyIterations count start end ->
118
118
vsep
119
119
[ " Unable to finish evaluation in " <> pretty count <> " iterations"
120
- , " at recursion depth " <> pretty depth
121
120
, " Started with: " <> pretty' @ mods start
122
121
, " Stopped at: " <> pretty' @ mods end
123
122
]
@@ -235,9 +234,6 @@ popRecursion = do
235
234
throw $ InternalError " Trying to pop an empty recursion stack"
236
235
else eqState $ put s{recursionStack = tail s. recursionStack}
237
236
238
- getRecusionDepth :: LoggerMIO io => EquationT io Int
239
- getRecusionDepth = (length . (. recursionStack)) <$> getState
240
-
241
237
toCache :: Monad io => CacheTag -> Term -> Term -> EquationT io ()
242
238
toCache tag orig result = eqState . modify $ \ s -> s{cache = updateCache tag s. cache}
243
239
where
@@ -335,7 +331,6 @@ iterateEquations direction preference startTerm = do
335
331
config <- getConfig
336
332
currentCount <- countSteps
337
333
when (coerce currentCount > config. maxIterations) $ do
338
- currentRecursionDepth <- getRecusionDepth
339
334
-- FIXME if this exception is caught in evaluatePattern',
340
335
-- then CtxAbort is a wrong context for it.
341
336
-- We should emit this log entry somewhere else.
@@ -349,7 +344,7 @@ iterateEquations direction preference startTerm = do
349
344
logMessage . renderOneLineText $
350
345
" Final term:" <+> pretty' @ mods currentTerm
351
346
throw $
352
- TooManyIterations currentRecursionDepth currentCount startTerm currentTerm
347
+ TooManyIterations currentCount startTerm currentTerm
353
348
pushTerm currentTerm
354
349
-- simplify the term using the LLVM backend first
355
350
llvmResult <- llvmSimplify currentTerm
@@ -452,12 +447,11 @@ evaluatePattern' pat@Pattern{term, ceilConditions} = withPatternContext pat $ do
452
447
-- i.e. not in a recursive evaluation of a side-condition,
453
448
-- it is safe to keep the partial result and ignore the exception.
454
449
-- Otherwise we would be throwing away useful work.
450
+ -- The exceptions thrown in recursion is caught in applyEquation.checkConstraint
455
451
keepTopLevelResults :: LoggerMIO io => EquationFailure -> EquationT io Term
456
452
keepTopLevelResults = \ case
457
- err@ (TooManyIterations recursionDepth _ _ partialResult) ->
458
- case recursionDepth of
459
- 0 -> pure partialResult
460
- _ -> throw err
453
+ TooManyIterations _ _ partialResult ->
454
+ pure partialResult
461
455
err -> throw err
462
456
463
457
-- evaluate the given predicate assuming all others
0 commit comments