diff options
author | sheaf <sam.derbyshire@gmail.com> | 2022-03-01 17:36:48 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-03-02 14:09:51 -0500 |
commit | f596c91aaede75f7293ac2214ad48018a6b7a753 (patch) | |
tree | 92c51240f4d7237d03868d27ddada78a0819cc14 /testsuite/tests/numeric | |
parent | 81b7c4361c0e3da403e0fcf42cc7faae2ca3db9a (diff) | |
download | haskell-f596c91aaede75f7293ac2214ad48018a6b7a753.tar.gz |
Improve out-of-order inferred type variables
Don't instantiate type variables for :type in
`GHC.Tc.Gen.App.tcInstFun`, to avoid inconsistently instantianting
`r1` but not `r2` in the type
forall {r1} (a :: TYPE r1) {r2} (b :: TYPE r2). ...
This fixes #21088.
This patch also changes the primop pretty-printer to ensure
that we put all the inferred type variables first. For example,
the type of reallyUnsafePtrEquality# is now
forall {l :: Levity} {k :: Levity}
(a :: TYPE (BoxedRep l))
(b :: TYPE (BoxedRep k)).
a -> b -> Int#
This means we avoid running into issue #21088 entirely with
the types of primops. Users can still write a type signature where
the inferred type variables don't come first, however.
This change to primops had a knock-on consequence, revealing that
we were sometimes performing eta reduction on keepAlive#.
This patch updates tryEtaReduce to avoid eta reducing functions
with no binding, bringing it in line with tryEtaReducePrep,
and thus fixing #21090.
Diffstat (limited to 'testsuite/tests/numeric')
3 files changed, 22 insertions, 22 deletions
diff --git a/testsuite/tests/numeric/should_compile/T19769.stderr-ws-32 b/testsuite/tests/numeric/should_compile/T19769.stderr-ws-32 index 21e9fa465c..33a23630ff 100644 --- a/testsuite/tests/numeric/should_compile/T19769.stderr-ws-32 +++ b/testsuite/tests/numeric/should_compile/T19769.stderr-ws-32 @@ -1,21 +1,21 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 68, types: 58, coercions: 0, joins: 0/0} + = {terms: 84, types: 66, coercions: 0, joins: 0/0} -wi8 = word8ToInt8# +wi8 = \ x -> word8ToInt8# x -wi16 = word16ToInt16# +wi16 = \ x -> word16ToInt16# x -wi32 = word32ToInt32# +wi32 = \ x -> word32ToInt32# x wi64 = \ x -> intToInt64# (word2Int# (word64ToWord# x)) -iw8 = int8ToWord8# +iw8 = \ x -> int8ToWord8# x -iw16 = int16ToWord16# +iw16 = \ x -> int16ToWord16# x -iw32 = int32ToWord32# +iw32 = \ x -> int32ToWord32# x iw64 = \ x -> wordToWord64# (int2Word# (int64ToInt# x)) @@ -43,9 +43,9 @@ wiw64 = \ x -> x iwi64 = \ x -> x -ww64i = word2Int# +ww64i = \ x -> word2Int# x -ii64w = int2Word# +ii64w = \ x -> int2Word# x diff --git a/testsuite/tests/numeric/should_compile/T19769.stderr-ws-64 b/testsuite/tests/numeric/should_compile/T19769.stderr-ws-64 index c5620bbf4b..99793137a2 100644 --- a/testsuite/tests/numeric/should_compile/T19769.stderr-ws-64 +++ b/testsuite/tests/numeric/should_compile/T19769.stderr-ws-64 @@ -1,23 +1,23 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 54, types: 54, coercions: 0, joins: 0/0} + = {terms: 74, types: 64, coercions: 0, joins: 0/0} -wi8 = word8ToInt8# +wi8 = \ x -> word8ToInt8# x -wi16 = word16ToInt16# +wi16 = \ x -> word16ToInt16# x -wi32 = word32ToInt32# +wi32 = \ x -> word32ToInt32# x -wi64 = word64ToInt64# +wi64 = \ x -> word64ToInt64# x -iw8 = int8ToWord8# +iw8 = \ x -> int8ToWord8# x -iw16 = int16ToWord16# +iw16 = \ x -> int16ToWord16# x -iw32 = int32ToWord32# +iw32 = \ x -> int32ToWord32# x -iw64 = int64ToWord64# +iw64 = \ x -> int64ToWord64# x i8 = \ x -> x @@ -43,9 +43,9 @@ wiw64 = w64 iwi64 = i64 -ww64i = word2Int# +ww64i = \ x -> word2Int# x -ii64w = int2Word# +ii64w = \ x -> int2Word# x diff --git a/testsuite/tests/numeric/should_compile/T20347.stderr b/testsuite/tests/numeric/should_compile/T20347.stderr index e4e80ada00..6fcb0b0722 100644 --- a/testsuite/tests/numeric/should_compile/T20347.stderr +++ b/testsuite/tests/numeric/should_compile/T20347.stderr @@ -1,7 +1,7 @@ ==================== Tidy Core ==================== Result size of Tidy Core - = {terms: 20, types: 15, coercions: 0, joins: 0/0} + = {terms: 24, types: 17, coercions: 0, joins: 0/0} foo0 = \ x -> -# 10# x @@ -9,7 +9,7 @@ foo1 = \ _ -> 10# foo2 = \ x -> +# 10# x -foo3 = *# +foo3 = \ x y -> *# x y foo4 = \ x -> *# -10# x |