diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2021-05-27 12:02:45 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-06-05 19:23:46 -0400 |
commit | 52a524f7c8c5701708a007a5946c27914703d045 (patch) | |
tree | 63e5417205788aa800e06ef679f96ca29a3586aa /testsuite/tests/stranal | |
parent | ea9a4ef69a382cf3cee28b78eca390a6a06c6965 (diff) | |
download | haskell-52a524f7c8c5701708a007a5946c27914703d045.tar.gz |
Re-do rubbish literals
As #19882 pointed out, we were simply doing rubbish literals wrong.
(I'll refrain from explaining the wrong-ness here -- see the ticket.)
This patch fixes it by adding a Type (of kind RuntimeRep) as field of
LitRubbish, rather than [PrimRep].
The Note [Rubbish literals] in GHC.Types.Literal explains the details.
Diffstat (limited to 'testsuite/tests/stranal')
-rw-r--r-- | testsuite/tests/stranal/should_compile/T18982.stderr | 26 | ||||
-rw-r--r-- | testsuite/tests/stranal/should_compile/T19882a.hs | 10 | ||||
-rw-r--r-- | testsuite/tests/stranal/should_compile/T19882b.hs | 9 | ||||
-rw-r--r-- | testsuite/tests/stranal/should_compile/all.T | 2 |
4 files changed, 34 insertions, 13 deletions
diff --git a/testsuite/tests/stranal/should_compile/T18982.stderr b/testsuite/tests/stranal/should_compile/T18982.stderr index 310eed5cc3..19f25be15c 100644 --- a/testsuite/tests/stranal/should_compile/T18982.stderr +++ b/testsuite/tests/stranal/should_compile/T18982.stderr @@ -1,6 +1,6 @@ ==================== Tidy Core ==================== -Result size of Tidy Core = {terms: 315, types: 214, coercions: 2, joins: 0/0} +Result size of Tidy Core = {terms: 311, types: 214, coercions: 4, joins: 0/0} -- RHS size: {terms: 8, types: 9, coercions: 1, joins: 0/0} T18982.$WExGADT :: forall e. (e ~ Int) => e %1 -> Int %1 -> ExGADT Int @@ -210,21 +210,21 @@ T18982.$tc'ExGADT2 = GHC.Types.TrNameS T18982.$tc'ExGADT3 T18982.$tc'ExGADT :: GHC.Types.TyCon T18982.$tc'ExGADT = GHC.Types.TyCon 8468257409157161049## 5503123603717080600## T18982.$trModule T18982.$tc'ExGADT2 1# T18982.$tc'ExGADT1 --- RHS size: {terms: 13, types: 15, coercions: 0, joins: 0/0} -T18982.$wi :: forall {a} {e}. e -> GHC.Prim.Int# -> GHC.Prim.Int# -T18982.$wi = \ (@a) (@e) (ww :: e) (ww1 :: GHC.Prim.Int#) -> case RUBBISH[] @(a GHC.Prim.~# Int) of ww2 { __DEFAULT -> case ww of { __DEFAULT -> GHC.Prim.+# ww1 1# } } +-- RHS size: {terms: 11, types: 10, coercions: 0, joins: 0/0} +T18982.$wi :: forall {a} {e}. (a GHC.Prim.~# Int) -> e -> GHC.Prim.Int# -> GHC.Prim.Int# +T18982.$wi = \ (@a) (@e) (ww :: a GHC.Prim.~# Int) (ww1 :: e) (ww2 :: GHC.Prim.Int#) -> case ww1 of { __DEFAULT -> GHC.Prim.+# ww2 1# } --- RHS size: {terms: 15, types: 22, coercions: 0, joins: 0/0} +-- RHS size: {terms: 15, types: 22, coercions: 1, joins: 0/0} i :: forall a. ExGADT a -> Int -i = \ (@a) (w :: ExGADT a) -> case w of { ExGADT @e ww1 ww2 ww3 ww4 -> case ww4 of { GHC.Types.I# ww6 -> case T18982.$wi @a @e ww3 ww6 of ww7 { __DEFAULT -> GHC.Types.I# ww7 } } } +i = \ (@a) (w :: ExGADT a) -> case w of { ExGADT @e ww ww1 ww2 ww3 -> case ww3 of { GHC.Types.I# ww4 -> case T18982.$wi @a @e @~(ww :: a GHC.Prim.~# Int) ww2 ww4 of ww5 { __DEFAULT -> GHC.Types.I# ww5 } } } --- RHS size: {terms: 8, types: 12, coercions: 0, joins: 0/0} -T18982.$wh :: forall {a}. GHC.Prim.Int# -> GHC.Prim.Int# -T18982.$wh = \ (@a) (ww :: GHC.Prim.Int#) -> case RUBBISH[] @(a GHC.Prim.~# Int) of ww1 { __DEFAULT -> GHC.Prim.+# ww 1# } +-- RHS size: {terms: 6, types: 7, coercions: 0, joins: 0/0} +T18982.$wh :: forall {a}. (a GHC.Prim.~# Int) -> GHC.Prim.Int# -> GHC.Prim.Int# +T18982.$wh = \ (@a) (ww :: a GHC.Prim.~# Int) (ww1 :: GHC.Prim.Int#) -> GHC.Prim.+# ww1 1# --- RHS size: {terms: 14, types: 15, coercions: 0, joins: 0/0} +-- RHS size: {terms: 14, types: 15, coercions: 1, joins: 0/0} h :: forall a. GADT a -> Int -h = \ (@a) (w :: GADT a) -> case w of { GADT ww1 ww2 -> case ww2 of { GHC.Types.I# ww4 -> case T18982.$wh @a ww4 of ww5 { __DEFAULT -> GHC.Types.I# ww5 } } } +h = \ (@a) (w :: GADT a) -> case w of { GADT ww ww1 -> case ww1 of { GHC.Types.I# ww2 -> case T18982.$wh @a @~(ww :: a GHC.Prim.~# Int) ww2 of ww3 { __DEFAULT -> GHC.Types.I# ww3 } } } -- RHS size: {terms: 9, types: 4, coercions: 0, joins: 0/0} T18982.$wg :: forall {e}. e -> GHC.Prim.Int# -> GHC.Prim.Int# @@ -232,7 +232,7 @@ T18982.$wg = \ (@e) (ww :: e) (ww1 :: GHC.Prim.Int#) -> case ww of { __DEFAULT - -- RHS size: {terms: 14, types: 11, coercions: 0, joins: 0/0} g :: Ex Int -> Int -g = \ (w :: Ex Int) -> case w of { Ex @e ww1 ww2 -> case ww2 of { GHC.Types.I# ww4 -> case T18982.$wg @e ww1 ww4 of ww5 { __DEFAULT -> GHC.Types.I# ww5 } } } +g = \ (w :: Ex Int) -> case w of { Ex @e ww ww1 -> case ww1 of { GHC.Types.I# ww2 -> case T18982.$wg @e ww ww2 of ww3 { __DEFAULT -> GHC.Types.I# ww3 } } } -- RHS size: {terms: 4, types: 1, coercions: 0, joins: 0/0} T18982.$wf :: GHC.Prim.Int# -> GHC.Prim.Int# @@ -240,7 +240,7 @@ T18982.$wf = \ (ww :: GHC.Prim.Int#) -> GHC.Prim.+# ww 1# -- RHS size: {terms: 13, types: 8, coercions: 0, joins: 0/0} f :: Box Int -> Int -f = \ (w :: Box Int) -> case w of { Box ww1 -> case ww1 of { GHC.Types.I# ww3 -> case T18982.$wf ww3 of ww4 { __DEFAULT -> GHC.Types.I# ww4 } } } +f = \ (w :: Box Int) -> case w of { Box ww -> case ww of { GHC.Types.I# ww1 -> case T18982.$wf ww1 of ww2 { __DEFAULT -> GHC.Types.I# ww2 } } } diff --git a/testsuite/tests/stranal/should_compile/T19882a.hs b/testsuite/tests/stranal/should_compile/T19882a.hs new file mode 100644 index 0000000000..65d920dfc9 --- /dev/null +++ b/testsuite/tests/stranal/should_compile/T19882a.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE UnboxedTuples, MagicHash #-} + +module T19882a where + +import GHC.Exts + +f1 :: (# State# RealWorld, Int, Int #) -> Bool -> Int +f1 x True = 1 +f1 x False = f1 x True + diff --git a/testsuite/tests/stranal/should_compile/T19882b.hs b/testsuite/tests/stranal/should_compile/T19882b.hs new file mode 100644 index 0000000000..455bd016c1 --- /dev/null +++ b/testsuite/tests/stranal/should_compile/T19882b.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE UnboxedTuples, MagicHash #-} + +module T19882b where + +import GHC.Exts + +f2 :: (# State# RealWorld, Int #) -> Bool -> Int +f2 x True = 1 +f2 x False = f2 x True diff --git a/testsuite/tests/stranal/should_compile/all.T b/testsuite/tests/stranal/should_compile/all.T index 61e9c58dee..f5ebbf289a 100644 --- a/testsuite/tests/stranal/should_compile/all.T +++ b/testsuite/tests/stranal/should_compile/all.T @@ -67,3 +67,5 @@ test('T18982', [ grep_errmsg(r'\$w. .*Int#$') ], compile, ['-dppr-cols=1000 -dd test('T19180', normal, compile, ['']) test('T19849', normal, compile, ['']) +test('T19882a', normal, compile, ['']) +test('T19882b', normal, compile, ['']) |