[Git][ghc/ghc][wip/fast-binary] compiler: make getPrim eagerly evaluate its result
Cheng Shao pushed to branch wip/fast-binary at Glasgow Haskell Compiler / GHC Commits: 31136101 by Cheng Shao at 2026-01-07T23:41:02+01:00 compiler: make getPrim eagerly evaluate its result This commit makes `GHC.Utils.Binary.getPrim` eagerly evaluate its result, to avoid accidental laziness when future patches build other binary parsers using `getPrim`. - - - - - 1 changed file: - compiler/GHC/Utils/Binary.hs Changes: ===================================== compiler/GHC/Utils/Binary.hs ===================================== @@ -642,7 +642,7 @@ getPrim (ReadBinMem _ ix_r sz_r arr_r) size f = do ix <- readFastMutInt ix_r when (ix + size > sz_r) $ ioError (mkIOError eofErrorType "Data.Binary.getPrim" Nothing Nothing) - w <- unsafeWithForeignPtr arr_r $ \p -> f (p `plusPtr` ix) + !w <- unsafeWithForeignPtr arr_r $ \p -> f (p `plusPtr` ix) -- This is safe WRT #17760 as we we guarantee that the above line doesn't -- diverge writeFastMutInt ix_r (ix + size) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/311361012c8cb15223b5075cf89167d1... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/311361012c8cb15223b5075cf89167d1... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Cheng Shao (@TerrorJack)