diff options
author | Richard Eisenberg <rae@richarde.dev> | 2020-12-24 15:04:06 -0500 |
---|---|---|
committer | Richard Eisenberg <rae@richarde.dev> | 2020-12-24 15:09:44 -0500 |
commit | e9cc41df3f53db0e1fe39d970278cb630872a762 (patch) | |
tree | 086c73dfbde90f4b07f3c4c15972761dc2e2788c /compiler/GHC/Data | |
parent | b4508bd6f8b6492d2e74053d7338980109174861 (diff) | |
download | haskell-wip/T17812.tar.gz |
Use mutable update to defer out-of-scope errorswip/T17812
Previously, we let-bound an identifier to use to carry
the erroring evidence for an out-of-scope variable. But
this failed for levity-polymorphic out-of-scope variables,
leading to a panic (#17812). The new plan is to use
a mutable update to just write the erroring expression directly
where it needs to go.
Close #17812.
Test case: typecheck/should_compile/T17812
Diffstat (limited to 'compiler/GHC/Data')
-rw-r--r-- | compiler/GHC/Data/IOEnv.hs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/GHC/Data/IOEnv.hs b/compiler/GHC/Data/IOEnv.hs index 439f101ecc..850d111818 100644 --- a/compiler/GHC/Data/IOEnv.hs +++ b/compiler/GHC/Data/IOEnv.hs @@ -29,7 +29,7 @@ module GHC.Data.IOEnv ( tryM, tryAllM, tryMostM, fixM, -- I/O operations - IORef, newMutVar, readMutVar, writeMutVar, updMutVar, + IORef, newMutVar, readMutVar, writeMutVar, updMutVar, updMutVarM, atomicUpdMutVar, atomicUpdMutVar' ) where @@ -193,6 +193,12 @@ readMutVar var = liftIO (readIORef var) updMutVar :: IORef a -> (a -> a) -> IOEnv env () updMutVar var upd = liftIO (modifyIORef var upd) +updMutVarM :: IORef a -> (a -> IOEnv env a) -> IOEnv env () +updMutVarM ref upd + = do { contents <- liftIO $ readIORef ref + ; new_contents <- upd contents + ; liftIO $ writeIORef ref new_contents } + -- | Atomically update the reference. Does not force the evaluation of the -- new variable contents. For strict update, use 'atomicUpdMutVar''. atomicUpdMutVar :: IORef a -> (a -> (a, b)) -> IOEnv env b |