Commit ea4df12f authored by Ben Gamari's avatar Ben Gamari 🐢

Ensure shiftL/shiftR arguments aren't negative

Fixes #10571.
parent 36811bfd
......@@ -515,8 +515,12 @@ instance Bits Integer where
complement = complementInteger
shift x i@(I# i#) | i >= 0 = shiftLInteger x i#
| otherwise = shiftRInteger x (negateInt# i#)
shiftL x (I# i#) = shiftLInteger x i#
shiftR x (I# i#) = shiftRInteger x i#
shiftL x i@(I# i#)
| i < 0 = error "Bits.shiftL(Integer): negative shift"
| otherwise = shiftLInteger x i#
shiftR x i@(I# i#)
| i < 0 = error "Bits.shiftR(Integer): negative shift"
| otherwise = shiftRInteger x i#
testBit x (I# i) = testBitInteger x i
......
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