Commit 31f7d21b authored by Sylvain Henry's avatar Sylvain Henry Committed by Ben Gamari
Browse files

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

(cherry picked from commit 987b5e7f)
parent 5059edb0
......@@ -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'.
......
import Numeric
import GHC.Natural
main = do
-- test that GHC correctly compiles big Natural literals
let x = 0xffffffffffffffffffffffff :: Natural
print (showHex x "" == "ffffffffffffffffffffffff")
......@@ -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'])
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