Skip to content

Commit aee03d2

Browse files
committed
Ignore prelude check result when running with noSolver
1 parent 1b82c66 commit aee03d2

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

booster/library/Booster/SMT/Interface.hs

+14-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module Booster.SMT.Interface (
1212
SMTError (..),
1313
initSolver,
1414
noSolver,
15+
isNoSolver,
1516
finaliseSolver,
1617
getModelFor,
1718
checkPredicates,
@@ -34,7 +35,7 @@ import Data.Either.Extra (fromLeft', fromRight')
3435
import Data.IORef
3536
import Data.Map (Map)
3637
import Data.Map qualified as Map
37-
import Data.Maybe (fromMaybe)
38+
import Data.Maybe (fromMaybe, isNothing)
3839
import Data.Set (Set)
3940
import Data.Set qualified as Set
4041
import Data.Text as Text (Text, pack, unlines, unwords)
@@ -121,6 +122,10 @@ noSolver = do
121122
, options = defaultSMTOptions{retryLimit = Just 0}
122123
}
123124

125+
-- | Detect of the @SMTContext@ does not have a solver
126+
isNoSolver :: SMT.SMTContext -> Bool
127+
isNoSolver SMTContext{mbSolver} = isNothing mbSolver
128+
124129
-- | Hot-swap @SMTOptions@ in the active @SMTContext@, update the query timeout
125130
swapSmtOptions :: forall io. Log.LoggerMIO io => SMTOptions -> SMT io ()
126131
swapSmtOptions smtOptions = do
@@ -163,10 +168,14 @@ checkPrelude = do
163168
case check of
164169
Sat -> pure ()
165170
other -> do
166-
Log.logMessage $ "Initial SMT definition check returned " <> pack (show other)
167-
SMT get >>= closeContext
168-
throwSMT' $
169-
"Aborting due to potentially-inconsistent SMT setup: Initial check returned " <> show other
171+
ctxt <- SMT get
172+
if isNoSolver ctxt
173+
then -- when running with a dummy solver, ignore the Unknown prelude check
174+
pure ()
175+
else do
176+
Log.logMessage $ "Initial SMT definition check returned " <> pack (show other)
177+
throwSMT' $
178+
"Aborting due to potentially-inconsistent SMT setup: Initial check returned " <> show other
170179

171180
-- | Send the commands from the definition's SMT prelude
172181
runPrelude :: Log.LoggerMIO io => SMT io ()

0 commit comments

Comments
 (0)