diff options
author | Andrei Borzenkov <andreyborzenkov2002@gmail.com> | 2023-01-17 17:22:54 +0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2023-01-18 22:26:43 -0500 |
commit | 14b5982a3aea351e4b01c5804ebd4d4629ba6bab (patch) | |
tree | ef1fd598914a6625b90c28cc71cb7041c03cc823 /testsuite | |
parent | 154889dbfbef62ad58a28df4171bf767cc690c2a (diff) | |
download | haskell-14b5982a3aea351e4b01c5804ebd4d4629ba6bab.tar.gz |
Fix printing of promoted MkSolo datacon (#22785)
Problem: In 2463df2f, the Solo data constructor was renamed to MkSolo,
and Solo was turned into a pattern synonym for backwards compatibility.
Since pattern synonyms can not be promoted, the old code that pretty-printed
promoted single-element tuples started producing ill-typed code:
t :: Proxy ('Solo Int)
This fails with "Pattern synonym ‘Solo’ used as a type"
The solution is to track the distinction between type constructors and data
constructors more carefully when printing single-element tuples.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/printer/T22785.hs | 8 | ||||
-rw-r--r-- | testsuite/tests/printer/T22785.stderr | 7 | ||||
-rw-r--r-- | testsuite/tests/printer/all.T | 3 | ||||
-rw-r--r-- | testsuite/tests/th/T17380.stderr | 12 | ||||
-rw-r--r-- | testsuite/tests/th/T18612.stderr | 2 | ||||
-rw-r--r-- | testsuite/tests/th/TH_Promoted1Tuple.stderr | 2 |
6 files changed, 25 insertions, 9 deletions
diff --git a/testsuite/tests/printer/T22785.hs b/testsuite/tests/printer/T22785.hs new file mode 100644 index 0000000000..1db6b7d88d --- /dev/null +++ b/testsuite/tests/printer/T22785.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE DataKinds #-} +module T22785 where +import Data.Proxy +import Data.Tuple + + +p :: Proxy ('MkSolo Int) +p = Proxy :: Proxy Int diff --git a/testsuite/tests/printer/T22785.stderr b/testsuite/tests/printer/T22785.stderr new file mode 100644 index 0000000000..05bf7bfb3d --- /dev/null +++ b/testsuite/tests/printer/T22785.stderr @@ -0,0 +1,7 @@ + +T22785.hs:8:5: [GHC-83865] + Couldn't match type ‘Int’ with ‘MkSolo Int’ + Expected: Proxy (MkSolo Int) + Actual: Proxy Int + In the expression: Proxy :: Proxy Int + In an equation for ‘p’: p = Proxy :: Proxy Int diff --git a/testsuite/tests/printer/all.T b/testsuite/tests/printer/all.T index 409c9f2b13..cc4e4b3324 100644 --- a/testsuite/tests/printer/all.T +++ b/testsuite/tests/printer/all.T @@ -187,4 +187,5 @@ test('T22488_docHead', normal, compile_and_run, ['-package ghc']) test('T20531', extra_files(['T20531_defs.hs']), ghci_script, ['T20531.script']) test('T20531_red_ticks', extra_files(['T20531_defs.hs']), ghci_script, ['T20531_red_ticks.script']) test('HsDocTy', [ignore_stderr, req_ppr_deps], makefile_test, ['HsDocTy']) -test('Test22765', [ignore_stderr, req_ppr_deps], makefile_test, ['Test22765'])
\ No newline at end of file +test('Test22765', [ignore_stderr, req_ppr_deps], makefile_test, ['Test22765']) +test('T22785', normal, compile_fail, ['']) diff --git a/testsuite/tests/th/T17380.stderr b/testsuite/tests/th/T17380.stderr index d1f4684062..b5e79ffb63 100644 --- a/testsuite/tests/th/T17380.stderr +++ b/testsuite/tests/th/T17380.stderr @@ -25,17 +25,17 @@ T17380.hs:18:7: error: [GHC-83865] T17380.hs:21:8: error: [GHC-83865] • Couldn't match type: Maybe String - with: 'Solo (Maybe String) - Expected: Proxy ('Solo (Maybe String)) + with: MkSolo (Maybe String) + Expected: Proxy (MkSolo (Maybe String)) Actual: Proxy (Maybe String) • In the expression: Proxy :: Proxy (Maybe String) In an equation for ‘quuz’: quuz = Proxy :: Proxy (Maybe String) T17380.hs:24:8: error: [GHC-83865] - • Couldn't match type: 'Solo (Maybe String) + • Couldn't match type: MkSolo (Maybe String) with: Maybe String Expected: Proxy (Maybe String) - Actual: Proxy ('Solo (Maybe String)) - • In the expression: Proxy :: Proxy ('Solo Maybe String) + Actual: Proxy (MkSolo (Maybe String)) + • In the expression: Proxy :: Proxy ('MkSolo Maybe String) In an equation for ‘fred’: - fred = Proxy :: Proxy ('Solo Maybe String) + fred = Proxy :: Proxy ('MkSolo Maybe String) diff --git a/testsuite/tests/th/T18612.stderr b/testsuite/tests/th/T18612.stderr index 0865ddc17b..b710dc3b39 100644 --- a/testsuite/tests/th/T18612.stderr +++ b/testsuite/tests/th/T18612.stderr @@ -1,7 +1,7 @@ T18612.hs:14:11-68: Splicing type conT ''Proxy `appT` (promotedTupleT 1 `appT` (tupleT 0)) ======> - Proxy ('Solo ()) + Proxy ('MkSolo ()) T18612.hs:(10,7)-(11,75): Splicing type arrowT `appT` (conT ''Identity `appT` (tupleT 1 `appT` (tupleT 0))) `appT` (conT ''Identity `appT` (tupleT 1 `appT` (tupleT 0))) diff --git a/testsuite/tests/th/TH_Promoted1Tuple.stderr b/testsuite/tests/th/TH_Promoted1Tuple.stderr index bd71507e2e..2453cb26d5 100644 --- a/testsuite/tests/th/TH_Promoted1Tuple.stderr +++ b/testsuite/tests/th/TH_Promoted1Tuple.stderr @@ -1,3 +1,3 @@ TH_Promoted1Tuple.hs:7:2: error: - Illegal type: ‘'Solo Int’ Perhaps you intended to use DataKinds + Illegal type: ‘'MkSolo Int’ Perhaps you intended to use DataKinds |