Skip to content

Commit

Permalink
Empty the cache in a pop for SFunArray
Browse files Browse the repository at this point in the history
Addresses #541
  • Loading branch information
LeventErkok committed Jul 9, 2020
1 parent 5d144b4 commit af2a6e8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Data/SBV/Control/Query.hs
Expand Up @@ -33,7 +33,7 @@ module Data.SBV.Control.Query (
import Control.Monad (unless, when, zipWithM)
import Control.Monad.IO.Class (MonadIO)

import Data.IORef (readIORef)
import Data.IORef (readIORef, writeIORef)

import qualified Data.Map.Strict as M
import qualified Data.IntMap.Strict as IM
Expand Down Expand Up @@ -496,6 +496,11 @@ restoreTablesAndArrays = do st <- queryState
[x] -> send True $ "(assert " ++ x ++ ")"
xs -> send True $ "(assert (and " ++ unwords xs ++ "))"

-- We have to also clean-out the caches for all functional arrays, as a pop would
-- invalidate the cache. See: https://github.com/LeventErkok/sbv/issues/541
io $ do faMap <- readIORef (rFArrayMap st)
mapM_ (\(_, c) -> writeIORef c IM.empty) (IM.elems faMap)

-- | Generalization of 'Data.SBV.Control.inNewAssertionStack'
inNewAssertionStack :: (MonadIO m, MonadQuery m) => m a -> m a
inNewAssertionStack q = do push 1
Expand Down

0 comments on commit af2a6e8

Please sign in to comment.