diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2021-10-31 19:29:11 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-11-02 01:38:53 -0400 |
commit | a7e1be3d84d2b7d0515f909175cdfa5dcf0dc55c (patch) | |
tree | 5bc4f66b615c1eaf26bfbad6f08b8f7cc1adcfc1 /testsuite | |
parent | da1a8e2986731b767f5c977cb873034e771d9371 (diff) | |
download | haskell-a7e1be3d84d2b7d0515f909175cdfa5dcf0dc55c.tar.gz |
Fix #20590 with another application of mkHsContextMaybe
We were always converting empty GADT contexts to `Just []` in `GHC.ThToHs`,
which caused the pretty-printer to always print them as `() => ...`. This is
easily fixed by using the `mkHsContextMaybe` function when converting GADT
contexts so that empty contexts are turned to `Nothing`. This is in the same
tradition established in commit 4c87a3d1d14f9e28c8aa0f6062e9c4201f469ad7.
In the process of fixing this, I discovered that the `Cxt` argument to
`mkHsContextMaybe` is completely unnecessary, as we can just as well check if
the `LHsContext GhcPs` argument is empty.
Fixes #20590.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/th/T20590.hs | 8 | ||||
-rw-r--r-- | testsuite/tests/th/T20590.stderr | 4 | ||||
-rw-r--r-- | testsuite/tests/th/all.T | 1 |
3 files changed, 13 insertions, 0 deletions
diff --git a/testsuite/tests/th/T20590.hs b/testsuite/tests/th/T20590.hs new file mode 100644 index 0000000000..68ee97267a --- /dev/null +++ b/testsuite/tests/th/T20590.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE GADTs #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TemplateHaskell #-} +module T20590 where + +$([d| data T where + MkT :: forall a. a -> T + |]) diff --git a/testsuite/tests/th/T20590.stderr b/testsuite/tests/th/T20590.stderr new file mode 100644 index 0000000000..9d06f592a5 --- /dev/null +++ b/testsuite/tests/th/T20590.stderr @@ -0,0 +1,4 @@ +T20590.hs:(6,2)-(8,7): Splicing declarations + [d| data T where MkT :: forall a. a -> T |] + ======> + data T where MkT :: forall a. a -> T diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T index a5c4610598..439e88cd9a 100644 --- a/testsuite/tests/th/all.T +++ b/testsuite/tests/th/all.T @@ -537,3 +537,4 @@ test('T17820b', normal, compile_fail, ['']) test('T17820c', normal, compile_fail, ['']) test('T17820d', normal, compile_fail, ['']) test('T17820e', normal, compile_fail, ['']) +test('T20590', normal, compile, ['-v0 -ddump-splices -dsuppress-uniques']) |