summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/GHC/Rename/HsType.hs2
-rw-r--r--testsuite/tests/th/T19759.hs25
-rw-r--r--testsuite/tests/th/all.T1
3 files changed, 27 insertions, 1 deletions
diff --git a/compiler/GHC/Rename/HsType.hs b/compiler/GHC/Rename/HsType.hs
index a7f28b69cc..3a570e2e14 100644
--- a/compiler/GHC/Rename/HsType.hs
+++ b/compiler/GHC/Rename/HsType.hs
@@ -1911,7 +1911,7 @@ extractDataDefnKindVars (HsDataDefn { dd_kindSig = ksig })
= maybe [] extractHsTyRdrTyVars ksig
extract_lctxt :: Maybe (LHsContext GhcPs) -> FreeKiTyVars -> FreeKiTyVars
-extract_lctxt Nothing = const []
+extract_lctxt Nothing = id
extract_lctxt (Just ctxt) = extract_ltys (unLoc ctxt)
extract_scaled_ltys :: [HsScaled GhcPs (LHsType GhcPs)]
diff --git a/testsuite/tests/th/T19759.hs b/testsuite/tests/th/T19759.hs
new file mode 100644
index 0000000000..96c1684a0b
--- /dev/null
+++ b/testsuite/tests/th/T19759.hs
@@ -0,0 +1,25 @@
+{-# LANGUAGE PatternSynonyms #-}
+{-# LANGUAGE TemplateHaskell #-}
+module T19759 where
+
+import Language.Haskell.TH
+
+data T a where
+ MkT :: a -> b -> T a
+
+{-
+pattern MkT' :: () => forall b. a -> b -> T a
+pattern MkT' x y = MkT x y
+-}
+
+$(do let mkT' = mkName "MkT'"
+ a <- newName "a"
+ b <- newName "b"
+ x <- newName "x"
+ y <- newName "y"
+ pure [ PatSynSigD mkT' $ ForallT [] [] $ ForallT [PlainTV b SpecifiedSpec] []
+ $ ArrowT `AppT` VarT a `AppT` (ArrowT `AppT` VarT b `AppT` (ConT ''T `AppT` VarT a))
+ , PatSynD mkT' (PrefixPatSyn [x, y]) ImplBidir $
+ ConP 'MkT [] [VarP x, VarP y]
+ ])
+
diff --git a/testsuite/tests/th/all.T b/testsuite/tests/th/all.T
index 36567db6e7..70342cc45a 100644
--- a/testsuite/tests/th/all.T
+++ b/testsuite/tests/th/all.T
@@ -522,3 +522,4 @@ test('T18740d', normal, compile_fail, [''])
test('T19363', normal, compile_and_run, [''])
test('T19377', normal, compile, [''])
test('T17804', normal, compile, [''])
+test('T19759', normal, compile, [''])