[commit: ghc] master: Fix `fromInteger` constructing invalid `Natural` (b836139)

git at git.haskell.org git at git.haskell.org
Sat Nov 22 14:20:54 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/b836139099fc203a8b94849655d7dfb95dd80f4a/ghc

>---------------------------------------------------------------

commit b836139099fc203a8b94849655d7dfb95dd80f4a
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Sat Nov 22 14:56:53 2014 +0100

    Fix `fromInteger` constructing invalid `Natural`
    
    This fixes a case where `isValidNatural . fromInteger` would be `False`.
    
    Re #9818


>---------------------------------------------------------------

b836139099fc203a8b94849655d7dfb95dd80f4a
 libraries/base/GHC/Natural.hs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libraries/base/GHC/Natural.hs b/libraries/base/GHC/Natural.hs
index 0dead29..38a705e 100644
--- a/libraries/base/GHC/Natural.hs
+++ b/libraries/base/GHC/Natural.hs
@@ -158,7 +158,7 @@ instance Read Natural where
 
 instance Num Natural where
     fromInteger (S# i#) | I# i# >= 0  = NatS# (int2Word# i#)
-    fromInteger (Jp# bn#)             = NatJ# bn#
+    fromInteger (Jp# bn)              = bigNatToNatural bn
     fromInteger _                     = throw Underflow
 
     (+) = plusNatural



More information about the ghc-commits mailing list