diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2021-01-05 11:26:26 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-01-09 21:24:06 -0500 |
commit | 2754419673eabea772f27e9ad9275ef6acaddae3 (patch) | |
tree | b7dd6e2f0f3319255536c2d1f2f1eec7cc47a8a7 /libraries | |
parent | 9163b3f104cfe9b9da235f3bf4427d0579f8642e (diff) | |
download | haskell-2754419673eabea772f27e9ad9275ef6acaddae3.tar.gz |
Natural: fix left shift of 0 (fix #19170)
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/ghc-bignum/src/GHC/Num/Natural.hs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libraries/ghc-bignum/src/GHC/Num/Natural.hs b/libraries/ghc-bignum/src/GHC/Num/Natural.hs index d5e91c9574..d10a76165d 100644 --- a/libraries/ghc-bignum/src/GHC/Num/Natural.hs +++ b/libraries/ghc-bignum/src/GHC/Num/Natural.hs @@ -239,7 +239,8 @@ naturalShiftR x (W# n) = naturalShiftR# x n -- | Left shift naturalShiftL# :: Natural -> Word# -> Natural -naturalShiftL# (NS x) n +naturalShiftL# v@(NS x) n + | 0## <- x = v | isTrue# (clz# x `geWord#` n) = NS (x `uncheckedShiftL#` word2Int# n) | True = NB (bigNatFromWord# x `bigNatShiftL#` n) naturalShiftL# (NB x) n = NB (x `bigNatShiftL#` n) |