Serious bug with Natural in GHC 9.0.1

Hi Café, I've made a mistake while implementing constant folding for Natural numbers in GHC 9.0.1 that hasn't been caught before the release. It's a rather serious bug as any number converted into `Natural` with `fromIntegral` can be truncated to Word range if a bogus rule is triggered (see #19345 and #19411 for more details). It is already fixed in HEAD and the fix will be present in GHC 9.0.2 which should be released soon. In the meantime you can check if the rule is triggered with `-ddump-rule-firings`. If it shows that the following rule has fired, then your code may be badly modified: |Rule fired: fromIntegral/Int->Natural (GHC.Real)| (the issue is that despite its name the rule isn't correctly constrained to convert Ints into Natural, but any numeric type...). Sorry about that! Sylvain #19345: https://gitlab.haskell.org/ghc/ghc/-/issues/19345 #19411: https://gitlab.haskell.org/ghc/ghc/-/issues/19411

No worries Sylvain, Mistakes will be made while improving things, and we caught it, so that's great. Thanks for the head's up and good luck with your ongoing improvements! Cheers, Emily On Thu, Mar 04, 2021 at 4:24 PM, Sylvain Henry < sylvain@haskus.fr > wrote:
Hi Café,
I've made a mistake while implementing constant folding for Natural numbers in GHC 9.0.1 that hasn't been caught before the release. It's a rather serious bug as any number converted into `Natural` with `fromIntegral` can be truncated to Word range if a bogus rule is triggered (see #19345 and #19411 for more details).
It is already fixed in HEAD and the fix will be present in GHC 9.0.2 which should be released soon.
In the meantime you can check if the rule is triggered with `-ddump-rule-firings`. If it shows that the following rule has fired, then your code may be badly modified:
Rule fired: fromIntegral/Int->Natural (GHC.Real)
(the issue is that despite its name the rule isn't correctly constrained to convert Ints into Natural, but any numeric type...).
Sorry about that! Sylvain
#19345: https:/ / gitlab. haskell. org/ ghc/ ghc/ -/ issues/ 19345 ( https://gitlab.haskell.org/ghc/ghc/-/issues/19345 ) #19411: https:/ / gitlab. haskell. org/ ghc/ ghc/ -/ issues/ 19411 ( https://gitlab.haskell.org/ghc/ghc/-/issues/19411 )
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http:/ / mail. haskell. org/ cgi-bin/ mailman/ listinfo/ haskell-cafe ( http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe ) Only members subscribed via the mailman list are allowed to post.
participants (2)
-
Emily Pillmore
-
Sylvain Henry