diff options
-rw-r--r-- | compiler/rename/RnSource.hs | 5 | ||||
-rw-r--r-- | testsuite/tests/gadt/T14808.hs | 12 | ||||
-rw-r--r-- | testsuite/tests/gadt/all.T | 1 | ||||
-rw-r--r-- | testsuite/tests/th/T13123.hs | 2 |
4 files changed, 17 insertions, 3 deletions
diff --git a/compiler/rename/RnSource.hs b/compiler/rename/RnSource.hs index e51d9efc43..5c7f53860e 100644 --- a/compiler/rename/RnSource.hs +++ b/compiler/rename/RnSource.hs @@ -1917,7 +1917,10 @@ rnConDecl decl@(ConDeclGADT { con_names = names ; let explicit_tkvs = hsQTvExplicit qtvs theta = hsConDeclTheta mcxt arg_tys = hsConDeclArgTys args - ; free_tkvs <- extractHsTysRdrTyVarsDups (res_ty : theta ++ arg_tys) + -- We must ensure that we extract the free tkvs in the + -- order of theta, then arg_tys, then res_ty. Failing to + -- do so resulted in #14808. + ; free_tkvs <- extractHsTysRdrTyVarsDups (theta ++ arg_tys ++ [res_ty]) ; free_tkvs <- extractHsTvBndrs explicit_tkvs free_tkvs ; let ctxt = ConDeclCtx new_names diff --git a/testsuite/tests/gadt/T14808.hs b/testsuite/tests/gadt/T14808.hs new file mode 100644 index 0000000000..726f502789 --- /dev/null +++ b/testsuite/tests/gadt/T14808.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE TypeApplications #-} +module T14808 where + +import Data.Kind + +data ECC ctx f a where + ECC :: ctx => f a -> ECC ctx f a + +f :: [()] -> ECC () [] () +f = ECC @() @[] @() diff --git a/testsuite/tests/gadt/all.T b/testsuite/tests/gadt/all.T index 59ec307d58..4c8eb806a7 100644 --- a/testsuite/tests/gadt/all.T +++ b/testsuite/tests/gadt/all.T @@ -116,3 +116,4 @@ test('T12087', normal, compile_fail, ['']) test('T12468', normal, compile_fail, ['']) test('T14320', normal, compile, ['']) test('T14719', normal, compile_fail, ['-fdiagnostics-show-caret']) +test('T14808', normal, compile, ['']) diff --git a/testsuite/tests/th/T13123.hs b/testsuite/tests/th/T13123.hs index dbc071c184..d7e1006b9e 100644 --- a/testsuite/tests/th/T13123.hs +++ b/testsuite/tests/th/T13123.hs @@ -8,7 +8,6 @@ module T13123 where import GHC.Exts (Constraint) -{- $([d| idProxy :: forall proxy (a :: k). proxy a -> proxy a idProxy x = x |]) @@ -32,7 +31,6 @@ $([d| class Foo b where $([d| data GADT where MkGADT :: forall proxy (a :: k). proxy a -> GADT |]) --} $([d| data Dec13 :: (* -> Constraint) -> * where MkDec13 :: c a => a -> Dec13 c |