Commit 27544196 authored by Sylvain Henry's avatar Sylvain Henry Committed by Marge Bot

Natural: fix left shift of 0 (fix #19170)

parent 9163b3f1
Pipeline #29711 canceled with stages
......@@ -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)
......
module Main where
import Data.Bits
import GHC.Natural
import GHC.Num.Natural
main :: IO ()
main = do
print $ (shiftL 0 65 :: Natural)
print $ naturalCheck (shiftL 0 65 :: Natural)
print $ shiftL 0 65 == (0 :: Natural)
......@@ -12,6 +12,7 @@ test('integerGcdExt', [], compile_and_run, [''])
test('integerRecipMod', [], compile_and_run, [''])
test('bignumMatch', [], compile, [''])
test('T18813', [], compile_and_run, [''])
test('T19170', [], compile_and_run, [''])
# skip ghci as it doesn't support unboxed tuples
test('integerImportExport', [omit_ways(['ghci'])], compile_and_run, [''])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment