Skip to content

Commit a29d02f

Browse files
Revert "Revert "Stop execution on ErrorBottomTotalFunction (#2088)" (#2111)" (#2112)
This reverts commit a45859f. Co-authored-by: Andrei Burdușa <53746396+andreiburdusa@users.noreply.github.com>
1 parent 3575937 commit a29d02f

File tree

6 files changed

+46
-9
lines changed

6 files changed

+46
-9
lines changed

kore/src/Kore/Log/ErrorBottomTotalFunction.hs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ module Kore.Log.ErrorBottomTotalFunction
1111

1212
import Prelude.Kore
1313

14+
import Control.Monad.Catch
15+
( Exception (..)
16+
, MonadThrow
17+
, throwM
18+
)
1419
import qualified Generics.SOP as SOP
1520
import qualified GHC.Generics as GHC
1621

@@ -45,16 +50,21 @@ instance Pretty ErrorBottomTotalFunction where
4550
, "has resulted in \\bottom."
4651
]
4752

53+
instance Exception ErrorBottomTotalFunction where
54+
toException = toException . SomeEntry
55+
fromException exn =
56+
fromException exn >>= \entry -> fromEntry entry
57+
4858
instance Entry ErrorBottomTotalFunction where
4959
entrySeverity _ = Error
5060
helpDoc _ = "errors raised when a total function is undefined"
5161

5262
instance SQL.Table ErrorBottomTotalFunction
5363

5464
errorBottomTotalFunction
55-
:: MonadLog logger
65+
:: MonadThrow logger
5666
=> InternalVariable variable
5767
=> TermLike variable
5868
-> logger ()
5969
errorBottomTotalFunction (mapVariables (pure toVariableName) -> term) =
60-
logEntry ErrorBottomTotalFunction { term }
70+
throwM ErrorBottomTotalFunction { term }

kore/src/Kore/Step/Function/Evaluator.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ import Control.Error
2121
, maybeT
2222
, throwE
2323
)
24+
import Control.Monad.Catch
25+
( MonadThrow
26+
)
2427
import qualified Data.Foldable as Foldable
2528

2629
import qualified Kore.Attribute.Pattern.Simplified as Attribute.Simplified
@@ -71,6 +74,7 @@ evaluateApplication
7174
:: forall variable simplifier
7275
. ( InternalVariable variable
7376
, MonadSimplify simplifier
77+
, MonadThrow simplifier
7478
)
7579
=> SideCondition variable
7680
-- ^ The predicate from the configuration

kore/src/Kore/Step/Simplification/Application.hs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ module Kore.Step.Simplification.Application
1414

1515
import Prelude.Kore
1616

17+
import Control.Monad.Catch
18+
( MonadThrow
19+
)
20+
1721
import qualified Kore.Internal.Conditional as Conditional
1822
import qualified Kore.Internal.MultiOr as MultiOr
1923
( fullCrossProduct
@@ -58,7 +62,10 @@ predicates ans substitutions, applying functions on the Application(terms),
5862
then merging everything into an Pattern.
5963
-}
6064
simplify
61-
:: (InternalVariable variable, MonadSimplify simplifier)
65+
:: ( InternalVariable variable
66+
, MonadSimplify simplifier
67+
, MonadThrow simplifier
68+
)
6269
=> SideCondition variable
6370
-> Application Symbol (OrPattern variable)
6471
-> simplifier (OrPattern variable)
@@ -80,7 +87,10 @@ simplify sideCondition application = do
8087
childrenCrossProduct = MultiOr.fullCrossProduct children
8188

8289
makeAndEvaluateApplications
83-
:: (InternalVariable variable, MonadSimplify simplifier)
90+
:: ( InternalVariable variable
91+
, MonadSimplify simplifier
92+
, MonadThrow simplifier
93+
)
8494
=> SideCondition variable
8595
-> Symbol
8696
-> [Pattern variable]
@@ -89,7 +99,10 @@ makeAndEvaluateApplications =
8999
makeAndEvaluateSymbolApplications
90100

91101
makeAndEvaluateSymbolApplications
92-
:: (InternalVariable variable, MonadSimplify simplifier)
102+
:: ( InternalVariable variable
103+
, MonadSimplify simplifier
104+
, MonadThrow simplifier
105+
)
93106
=> SideCondition variable
94107
-> Symbol
95108
-> [Pattern variable]
@@ -105,7 +118,10 @@ makeAndEvaluateSymbolApplications sideCondition symbol children = do
105118
return (MultiOr.mergeAll orResults)
106119

107120
evaluateApplicationFunction
108-
:: (InternalVariable variable, MonadSimplify simplifier)
121+
:: ( InternalVariable variable
122+
, MonadSimplify simplifier
123+
, MonadThrow simplifier
124+
)
109125
=> SideCondition variable
110126
-- ^ The predicate from the configuration
111127
-> ExpandedApplication variable

kore/src/Kore/Step/Simplification/TermLike.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ module Kore.Step.Simplification.TermLike
1010
import Prelude.Kore
1111

1212
import qualified Control.Lens.Combinators as Lens
13+
import Control.Monad.Catch
14+
( MonadThrow
15+
)
1316
import Data.Functor.Const
1417
import qualified Data.Functor.Foldable as Recursive
1518

@@ -167,6 +170,7 @@ simplify
167170
. HasCallStack
168171
=> InternalVariable variable
169172
=> MonadSimplify simplifier
173+
=> MonadThrow simplifier
170174
=> SideCondition variable
171175
-> TermLike variable
172176
-> simplifier (OrPattern variable)

kore/test/Test/Kore/Builtin/Definition.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ elementMapSymbol =
437437

438438
concatMapSymbol :: Internal.Symbol
439439
concatMapSymbol =
440-
binarySymbol "concatMap" mapSort & hook "MAP.concat" & functional
440+
binarySymbol "concatMap" mapSort & hook "MAP.concat" & function
441441

442442
inKeysMapSymbol :: Internal.Symbol
443443
inKeysMapSymbol =
@@ -596,7 +596,7 @@ elementSet x = mkApplySymbol elementSetSymbol [x]
596596

597597
concatSetSymbol :: Internal.Symbol
598598
concatSetSymbol =
599-
binarySymbol "concatSet" setSort & hook "SET.concat" & functional
599+
binarySymbol "concatSet" setSort & hook "SET.concat" & function
600600

601601
concatSet
602602
:: TermLike VariableName

kore/test/Test/Kore/Step/Simplification/TermLike.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import Test.Tasty.HUnit
1010
import Control.Monad
1111
( void
1212
)
13+
import Control.Monad.Catch
14+
( MonadThrow
15+
)
1316

1417
import Kore.Internal.OrPattern
1518
( OrPattern
@@ -45,7 +48,7 @@ simplifyEvaluated original =
4548

4649
newtype TestSimplifier a = TestSimplifier { getTestSimplifier :: Simplifier a }
4750
deriving (Functor, Applicative, Monad)
48-
deriving (MonadLog, MonadSMT)
51+
deriving (MonadLog, MonadSMT, MonadThrow)
4952

5053
instance MonadSimplify TestSimplifier where
5154
askMetadataTools = TestSimplifier askMetadataTools

0 commit comments

Comments
 (0)