naturalAndNot truncates result when the second argument is word-sized and the first is not
Summary
When the first argument to naturalAndNot is larger than a Word and the second is Word-sized, naturalAndNot will truncate the result:
Steps to reproduce
module Main where
import Data.Bits
import GHC.Num.Natural
main :: IO ()
main =
-- Ok, prints 16
print $ naturalAndNot ((2 ^ 4) .|. (2 ^ 3)) (2 ^ 3)
-- Ok, prints 680564733841876926926749214863536422912
print $ naturalAndNot ((2 ^ 129) .|. (2 ^ 65)) (2 ^ 65)
-- Ok, prints 16
print $ naturalAndNot ((2 ^ 4) .|. (2 ^ 3)) ((2 ^ 65) .|. (2 ^ 3))
-- Bug, prints 0
print $ naturalAndNot ((2 ^ 65) .|. (2 ^ 3)) (2 ^ 3)
Please provide a set of concrete steps to reproduce the issue.
Expected behavior
The result for the final print should be 2 ^ 65
Environment
- GHC version used: 9.12.2
Optional:
- Operating System: MacOS 13.7.6
- System Architecture: x86_64