File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
hls-graph/src/Development/IDE/Graph/Internal Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ module Development.IDE.Graph.Internal.Key
3434 ) where
3535
3636-- import Control.Monad.IO.Class ()
37+ import Control.Exception (evaluate )
3738import Data.Coerce
3839import Data.Dynamic
3940import qualified Data.HashMap.Strict as Map
@@ -85,8 +86,15 @@ newKey k = unsafePerformIO $ do
8586
8687lookupKeyValue :: Key -> KeyValue
8788lookupKeyValue (UnsafeMkKey x) = unsafePerformIO $ do
89+ -- NOTE:
90+ -- The reason for this evaluate is that the x, if not forced yet, is a thunk
91+ -- that forces the atomicModifyIORef' in the creation of the new key. If it
92+ -- isn't forced *before* reading the keyMap, the keyMap will only obtain the new
93+ -- key (x) *after* the IntMap is already copied out of the keyMap reference,
94+ -- i.e. when it is forced for the lookup in the IntMap.
95+ k <- evaluate x
8896 GlobalKeyValueMap _ im _ <- readIORef keyMap
89- pure $! im IM. ! x
97+ pure $! im IM. ! k
9098
9199{-# NOINLINE lookupKeyValue #-}
92100
You can’t perform that action at this time.
0 commit comments