Rule "fromIntegral/Int->Natural" is inconsistent
As noticed by @trac-vdukhovni in #20062 (comment 362750):
import GHC.Natural
i :: Int
i = -10
main :: IO ()
main = let n :: Natural
n = fromIntegral i
in print n
- with -O2: prints 18446744073709551606
- with -O0: throw "arithmetic underflow"
While it should always throw an exception (I guess? "fromIntegral" isn't precisely defined in the report).
GHC versions: 9.0, 9.2, HEAD