[Git][ghc/ghc][master] JS: fix putEnum/fromEnum (#24593)
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: a3ac7074 by Sylvain Henry at 2026-03-06T06:35:17-05:00 JS: fix putEnum/fromEnum (#24593) Don't go through Word16 when serializing Enums. - - - - - 1 changed file: - compiler/GHC/StgToJS/Object.hs Changes: ===================================== compiler/GHC/StgToJS/Object.hs ===================================== @@ -406,12 +406,10 @@ readObjectBlocks file bids = do -------------------------------------------------------------------------------- putEnum :: Enum a => WriteBinHandle -> a -> IO () -putEnum bh x | n > 65535 = error ("putEnum: out of range: " ++ show n) - | otherwise = put_ bh n - where n = fromIntegral $ fromEnum x :: Word16 +putEnum bh x = put_ bh (fromEnum x) getEnum :: Enum a => ReadBinHandle -> IO a -getEnum bh = toEnum . fromIntegral <$> (get bh :: IO Word16) +getEnum bh = toEnum <$> (get bh) -- | Helper to convert Int to Int32 toI32 :: Int -> Int32 View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a3ac7074987fb8d72119b1d2ba4df918... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a3ac7074987fb8d72119b1d2ba4df918... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)