diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2019-01-14 21:45:17 -0500 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-01-28 12:23:16 -0500 |
commit | b1e569a54085bf1093b4f858f8c7c739e3be769b (patch) | |
tree | 499199793dc7aa1f6b3b6212b5ffca9c39df31d4 /testsuite | |
parent | 77974922eb4390899cb151de840308c5fe87949b (diff) | |
download | haskell-b1e569a54085bf1093b4f858f8c7c739e3be769b.tar.gz |
Use sigPrec in more places in Convert and HsUtils
Trac #16183 was caused by TH conversion (in `Convert`) not properly
inserting parentheses around occurrences of explicit signatures where
appropriate, such as in applications, function types, and type family
equations. Solution: use `parenthesizeHsType sigPrec` in these
places. While I was in town, I also updated `nlHsFunTy` to do the
same thing.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/th/T12045TH1.stderr | 4 | ||||
-rw-r--r-- | testsuite/tests/th/T16183.hs | 11 | ||||
-rw-r--r-- | testsuite/tests/th/T16183.stderr | 12 | ||||
-rw-r--r-- | testsuite/tests/th/all.T | 1 |
4 files changed, 26 insertions, 2 deletions
diff --git a/testsuite/tests/th/T12045TH1.stderr b/testsuite/tests/th/T12045TH1.stderr index fb4bf1a302..aede24c7a0 100644 --- a/testsuite/tests/th/T12045TH1.stderr +++ b/testsuite/tests/th/T12045TH1.stderr @@ -5,7 +5,7 @@ T12045TH1.hs:(8,3)-(10,52): Splicing declarations ======> type family F (a :: k) :: Type where F @Type Int = Bool - F @Type -> Type Maybe = Char + F @(Type -> Type) Maybe = Char T12045TH1.hs:13:3-31: Splicing declarations [d| data family D (a :: k) |] ======> data family D (a :: k) T12045TH1.hs:15:3-40: Splicing declarations @@ -15,4 +15,4 @@ T12045TH1.hs:15:3-40: Splicing declarations T12045TH1.hs:17:3-50: Splicing declarations [d| data instance D @(Type -> Type) b = DChar |] ======> - data instance D @Type -> Type b = DChar + data instance D @(Type -> Type) b = DChar diff --git a/testsuite/tests/th/T16183.hs b/testsuite/tests/th/T16183.hs new file mode 100644 index 0000000000..6b1280f344 --- /dev/null +++ b/testsuite/tests/th/T16183.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TypeFamilies #-} +module T16183 where + +import Data.Kind + +$([d| type F1 = (Maybe :: Type -> Type) Int + type F2 = (Int :: Type) -> (Int :: Type) + type family F3 a where + F3 (a :: Type) = Int + newtype F4 = MkF4 (Int :: Type) |]) diff --git a/testsuite/tests/th/T16183.stderr b/testsuite/tests/th/T16183.stderr new file mode 100644 index 0000000000..812fd58ac9 --- /dev/null +++ b/testsuite/tests/th/T16183.stderr @@ -0,0 +1,12 @@ +T16183.hs:(7,3)-(11,40): Splicing declarations + [d| type F1 = (Maybe :: Type -> Type) Int + type F2 = (Int :: Type) -> (Int :: Type) + type family F3 a where + F3 (a :: Type) = Int + newtype F4 = MkF4 (Int :: Type) |] + ======> + type F1 = (Maybe :: Type -> Type) Int + type F2 = (Int :: Type) -> (Int :: Type) + type family F3 a where + F3 (a :: Type) = Int + newtype F4 = MkF4 (Int :: Type) diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T index 4062cf2af0..b93673c138 100644 --- a/testsuite/tests/th/all.T +++ b/testsuite/tests/th/all.T @@ -468,3 +468,4 @@ test('T15985', normal, compile, ['']) test('T16133', normal, compile_fail, ['']) test('T15471', normal, multimod_compile, ['T15471.hs', '-v0']) test('T16180', when(opsys('darwin'), expect_broken(16218)), compile_and_run, ['']) +test('T16183', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques']) |