[commit: ghc] master: Fix for built-in Natural literals desugaring (987b5e7)
git at git.haskell.org
git at git.haskell.org
Fri Jul 6 18:10:12 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/987b5e7fbacd8afd2c8463c16eac28cd68f43155/ghc
>---------------------------------------------------------------
commit 987b5e7fbacd8afd2c8463c16eac28cd68f43155
Author: Sylvain Henry <hsyl20 at gmail.com>
Date: Fri Jul 6 11:01:14 2018 -0400
Fix for built-in Natural literals desugaring
The recent patch "Built-in Natural literals in Core"
(https://phabricator.haskell.org/rGHCfe770c211631e7b4c9b0b1e88ef9b6046c6
585ef) introduced a regression when desugaring large numbers.
This patch fixes it and adds a regression test.
Reviewers: hvr, bgamari
Reviewed By: bgamari
Subscribers: rwbarton, thomie, carter
GHC Trac Issues: #15301
Differential Revision: https://phabricator.haskell.org/D4885
>---------------------------------------------------------------
987b5e7fbacd8afd2c8463c16eac28cd68f43155
libraries/base/GHC/Natural.hs | 2 +-
testsuite/tests/numeric/should_run/T15301.hs | 7 +++++++
.../tests/numeric/should_run/T15301.stdout | 0
testsuite/tests/numeric/should_run/all.T | 1 +
4 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/libraries/base/GHC/Natural.hs b/libraries/base/GHC/Natural.hs
index db8d8b8..a35688d 100644
--- a/libraries/base/GHC/Natural.hs
+++ b/libraries/base/GHC/Natural.hs
@@ -594,7 +594,7 @@ mkNatural :: [Word] -- ^ value expressed in 32 bit chunks, least
-> Natural
mkNatural [] = wordToNaturalBase 0##
mkNatural (W# i : is') = wordToNaturalBase (i `and#` 0xffffffff##) `orNatural`
- shiftLNatural (mkNatural is') 31
+ shiftLNatural (mkNatural is') 32
{-# CONSTANT_FOLDED mkNatural #-}
-- | Convert 'Int' to 'Natural'.
diff --git a/testsuite/tests/numeric/should_run/T15301.hs b/testsuite/tests/numeric/should_run/T15301.hs
new file mode 100644
index 0000000..6efbce4
--- /dev/null
+++ b/testsuite/tests/numeric/should_run/T15301.hs
@@ -0,0 +1,7 @@
+import Numeric
+import GHC.Natural
+
+main = do
+ -- test that GHC correctly compiles big Natural literals
+ let x = 0xffffffffffffffffffffffff :: Natural
+ print (showHex x "" == "ffffffffffffffffffffffff")
diff --git a/libraries/base/tests/IO/IOError002.stdout b/testsuite/tests/numeric/should_run/T15301.stdout
similarity index 100%
copy from libraries/base/tests/IO/IOError002.stdout
copy to testsuite/tests/numeric/should_run/T15301.stdout
diff --git a/testsuite/tests/numeric/should_run/all.T b/testsuite/tests/numeric/should_run/all.T
index 691fc26..140fa6c 100644
--- a/testsuite/tests/numeric/should_run/all.T
+++ b/testsuite/tests/numeric/should_run/all.T
@@ -65,3 +65,4 @@ test('T10011', normal, compile_and_run, [''])
test('T10962', omit_ways(['ghci']), compile_and_run, ['-O2'])
test('T11702', extra_ways(['optasm']), compile_and_run, [''])
test('T12136', normal, compile_and_run, [''])
+test('T15301', normal, compile_and_run, ['-O2'])
More information about the ghc-commits
mailing list