diff options
34 files changed, 60 insertions, 166 deletions
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index a9b4a03962..1c6be035ff 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -3984,7 +3984,8 @@ wWarningFlagsDeps = [ flagSpec "hi-shadowing" Opt_WarnHiShadows, flagSpec "inaccessible-code" Opt_WarnInaccessibleCode, flagSpec "implicit-prelude" Opt_WarnImplicitPrelude, - flagSpec "implicit-kind-vars" Opt_WarnImplicitKindVars, + depFlagSpec "implicit-kind-vars" Opt_WarnImplicitKindVars + "it is now an error", flagSpec "incomplete-patterns" Opt_WarnIncompletePatterns, flagSpec "incomplete-record-updates" Opt_WarnIncompletePatternsRecUpd, flagSpec "incomplete-uni-patterns" Opt_WarnIncompleteUniPatterns, @@ -4810,7 +4811,6 @@ minusWcompatOpts = [ Opt_WarnMissingMonadFailInstances , Opt_WarnSemigroup , Opt_WarnNonCanonicalMonoidInstances - , Opt_WarnImplicitKindVars , Opt_WarnStarIsType ] diff --git a/compiler/rename/RnSource.hs b/compiler/rename/RnSource.hs index 0699f80858..e22e75318a 100644 --- a/compiler/rename/RnSource.hs +++ b/compiler/rename/RnSource.hs @@ -729,13 +729,10 @@ rnFamInstEqn doc mb_cls rhs_kvars -- below to report unsed binder on the LHS ; let pat_kity_vars = rmDupsInRdrTyVars pat_kity_vars_with_dups - -- all pat vars not explicitly bound (see extractHsTvBndrs) - ; let mb_imp_kity_vars = extractHsTvBndrs <$> mb_bndrs <*> pure pat_kity_vars - imp_vars = case mb_imp_kity_vars of - -- kind vars are the only ones free if we have an explicit forall - Just nbnd_kity_vars -> freeKiTyVarsKindVars nbnd_kity_vars - -- all pattern vars are free otherwise - Nothing -> freeKiTyVarsAllVars pat_kity_vars + -- Implicitly bound variables, empty if we have an explicit 'forall' according + -- to the "forall-or-nothing" rule. + ; let imp_vars | isNothing mb_bndrs = freeKiTyVarsAllVars pat_kity_vars + | otherwise = [] ; imp_var_names <- mapM (newTyVarNameRn mb_cls) imp_vars ; let bndrs = fromMaybe [] mb_bndrs @@ -2148,7 +2145,8 @@ rnConDecl decl@(ConDeclGADT { con_names = names -- That order governs the order the implicitly-quantified type -- variable, and hence the order needed for visible type application -- See Trac #14808. - free_tkvs = extractHsTvBndrs explicit_tkvs $ + free_tkvs = freeKiTyVarsAllVars $ + extractHsTvBndrs explicit_tkvs $ extractHsTysRdrTyVarsDups (theta ++ arg_tys ++ [res_ty]) ctxt = ConDeclCtx new_names diff --git a/compiler/rename/RnTypes.hs b/compiler/rename/RnTypes.hs index 1eaf89a7b9..be851e759a 100644 --- a/compiler/rename/RnTypes.hs +++ b/compiler/rename/RnTypes.hs @@ -134,7 +134,7 @@ rn_hs_sig_wc_type scoping ctxt AlwaysBind -> True BindUnlessForall -> not (isLHsForAllTy hs_ty) NeverBind -> False - ; rnImplicitBndrs bind_free_tvs tv_rdrs $ \ vars -> + ; rnImplicitBndrs bind_free_tvs (freeKiTyVarsAllVars tv_rdrs) $ \ vars -> do { (wcs, hs_ty', fvs1) <- rnWcBody ctxt nwc_rdrs hs_ty ; let sig_ty' = HsWC { hswc_ext = wcs, hswc_body = ib_ty' } ib_ty' = HsIB { hsib_ext = vars @@ -308,7 +308,7 @@ rnHsSigType :: HsDocContext -> LHsSigType GhcPs rnHsSigType ctx (HsIB { hsib_body = hs_ty }) = do { traceRn "rnHsSigType" (ppr hs_ty) ; vars <- extractFilteredRdrTyVarsDups hs_ty - ; rnImplicitBndrs (not (isLHsForAllTy hs_ty)) vars $ \ vars -> + ; rnImplicitBndrs (not (isLHsForAllTy hs_ty)) (freeKiTyVarsAllVars vars) $ \ vars -> do { (body', fvs) <- rnLHsType ctx hs_ty ; return ( HsIB { hsib_ext = vars , hsib_body = body' } @@ -320,58 +320,27 @@ rnImplicitBndrs :: Bool -- True <=> bring into scope any free type variables -- we do not want to bring 'b' into scope, hence False -- But f :: a -> b -- we want to bring both 'a' and 'b' into scope - -> FreeKiTyVarsWithDups + -> [Located RdrName] -- Free vars of hs_ty (excluding wildcards) -- May have duplicates, which is -- checked here -> ([Name] -> RnM (a, FreeVars)) -> RnM (a, FreeVars) rnImplicitBndrs bind_free_tvs - fvs_with_dups@(FKTV { fktv_kis = kvs_with_dups - , fktv_tys = tvs_with_dups }) + fvs_with_dups thing_inside - = do { let FKTV kvs tvs = rmDupsInRdrTyVars fvs_with_dups - real_tvs | bind_free_tvs = tvs + = do { let fvs = nubL fvs_with_dups + real_fvs | bind_free_tvs = fvs | otherwise = [] - -- We always bind over free /kind/ variables. - -- Bind free /type/ variables only if there is no - -- explicit forall. E.g. - -- f :: Proxy (a :: k) -> b - -- Quantify over {k} and {a,b} - -- g :: forall a. Proxy (a :: k) -> b - -- Quantify over {k} and {} - -- Note that we always do the implicit kind-quantification - -- but, rather arbitrarily, we switch off the type-quantification - -- if there is an explicit forall - - ; traceRn "rnImplicitBndrs" (vcat [ ppr kvs, ppr tvs, ppr real_tvs ]) - - ; whenWOptM Opt_WarnImplicitKindVars $ - unless (bind_free_tvs || null kvs) $ - addWarnAt (Reason Opt_WarnImplicitKindVars) (getLoc (head kvs)) $ - implicit_kind_vars_msg kvs - ; loc <- getSrcSpanM - -- NB: kinds before tvs, as mandated by - -- Note [Ordering of implicit variables] - ; vars <- mapM (newLocalBndrRn . cL loc . unLoc) (kvs ++ real_tvs) + ; traceRn "rnImplicitBndrs" $ + vcat [ ppr fvs_with_dups, ppr fvs, ppr real_fvs ] - ; traceRn "checkMixedVars2" $ - vcat [ text "kvs_with_dups" <+> ppr kvs_with_dups - , text "tvs_with_dups" <+> ppr tvs_with_dups ] + ; loc <- getSrcSpanM + ; vars <- mapM (newLocalBndrRn . cL loc . unLoc) real_fvs ; bindLocalNamesFV vars $ thing_inside vars } - where - implicit_kind_vars_msg kvs = - vcat [ text "An explicit" <+> quotes (text "forall") <+> - text "was used, but the following kind variables" <+> - text "are not quantified:" <+> - hsep (punctuate comma (map (quotes . ppr) kvs)) - , text "Despite this fact, GHC will introduce them into scope," <+> - text "but it will stop doing so in the future." - , text "Suggested fix: add" <+> - quotes (text "forall" <+> hsep (map ppr kvs) <> char '.') ] {- ****************************************************** * * diff --git a/docs/users_guide/using-warnings.rst b/docs/users_guide/using-warnings.rst index 03ca184531..27efd9f899 100644 --- a/docs/users_guide/using-warnings.rst +++ b/docs/users_guide/using-warnings.rst @@ -123,7 +123,6 @@ The following flags are simple ways to select standard "packages" of warnings: * :ghc-flag:`-Wmissing-monadfail-instances` * :ghc-flag:`-Wsemigroup` * :ghc-flag:`-Wnoncanonical-monoid-instances` - * :ghc-flag:`-Wimplicit-kind-vars` * :ghc-flag:`-Wstar-is-type` .. ghc-flag:: -Wno-compat @@ -776,58 +775,6 @@ of ``-W(no-)*``. This warning is off by default. -.. ghc-flag:: -Wimplicit-kind-vars - :shortdesc: warn when kind variables are brought into scope implicitly despite - the "forall-or-nothing" rule - :type: dynamic - :reverse: -Wno-implicit-kind-vars - :category: - - :since: 8.6 - - `GHC proposal #24 - <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0024-no-kind-vars.rst>`__ - prescribes to treat kind variables and type variables identically in - ``forall``, removing the legacy distinction between them. - - Consider the following examples: :: - - f :: Proxy a -> Proxy b -> () - g :: forall a b. Proxy a -> Proxy b -> () - - ``f`` does not use an explicit ``forall``, so type variables ``a`` and ``b`` - are brought into scope implicitly. ``g`` quantifies both ``a`` and ``b`` - explicitly. Both ``f`` and ``g`` work today and will continue to work in the - future because they adhere to the "forall-or-nothing" rule: either all type - variables in a function definition are introduced explicitly or implicitly, - there is no middle ground. - - A violation of the "forall-or-nothing" rule looks like this: :: - - m :: forall a. Proxy a -> Proxy b -> () - - ``m`` does not introduce one of the variables, ``b``, and thus is rejected. - - However, consider the following example: :: - - n :: forall a. Proxy (a :: k) -> () - - While ``n`` uses ``k`` without introducing it and thus violates the rule, it - is currently accepted. This is because ``k`` in ``n`` is considered a kind - variable, as it occurs in a kind signature. In reality, the line between - type variables and kind variables is blurry, as the following example - demonstrates: :: - - kindOf :: forall a. Proxy (a :: k) -> Proxy k - - In ``kindOf``, the ``k`` variable is used both in a kind position and a type - position. Currently, ``kindOf`` happens to be accepted as well. - - In a future release of GHC, both ``n`` and ``kindOf`` will be rejected per - the "forall-or-nothing" rule. This warning, being part of the - :ghc-flag:`-Wcompat` option group, allows to detect this before the actual - breaking change takes place. - .. ghc-flag:: -Wincomplete-patterns :shortdesc: warn when a pattern match could fail :type: dynamic diff --git a/testsuite/tests/codeGen/should_fail/T13233.hs b/testsuite/tests/codeGen/should_fail/T13233.hs index 1facb77914..f24fc03bfb 100644 --- a/testsuite/tests/codeGen/should_fail/T13233.hs +++ b/testsuite/tests/codeGen/should_fail/T13233.hs @@ -8,9 +8,9 @@ module Bug where import GHC.Exts (TYPE, RuntimeRep, Weak#, State#, RealWorld, mkWeak# ) class Foo (a :: TYPE rep) where - bar :: forall (b :: TYPE rep2). (a -> a -> b) -> a -> a -> b + bar :: forall rep2 (b :: TYPE rep2). (a -> a -> b) -> a -> a -> b -baz :: forall (a :: TYPE rep). Foo a => a -> a -> (# a, a #) +baz :: forall rep (a :: TYPE rep). Foo a => a -> a -> (# a, a #) baz = bar (#,#) obscure :: (forall (rep1 :: RuntimeRep) (rep2 :: RuntimeRep) diff --git a/testsuite/tests/dependent/should_compile/T15264.stderr b/testsuite/tests/dependent/should_compile/T15264.stderr deleted file mode 100644 index 222d686513..0000000000 --- a/testsuite/tests/dependent/should_compile/T15264.stderr +++ /dev/null @@ -1,10 +0,0 @@ - -T15264.hs:8:22: warning: [-Wimplicit-kind-vars (in -Wcompat)] - An explicit ‘forall’ was used, but the following kind variables are not quantified: ‘k’ - Despite this fact, GHC will introduce them into scope, but it will stop doing so in the future. - Suggested fix: add ‘forall k.’ - -T15264.hs:11:22: warning: [-Wimplicit-kind-vars (in -Wcompat)] - An explicit ‘forall’ was used, but the following kind variables are not quantified: ‘k1’, ‘k2’ - Despite this fact, GHC will introduce them into scope, but it will stop doing so in the future. - Suggested fix: add ‘forall k1 k2.’ diff --git a/testsuite/tests/dependent/should_compile/all.T b/testsuite/tests/dependent/should_compile/all.T index fa39c9a69a..ca5f436174 100644 --- a/testsuite/tests/dependent/should_compile/all.T +++ b/testsuite/tests/dependent/should_compile/all.T @@ -48,7 +48,6 @@ test('T14066a', normal, compile, ['']) test('T14749', normal, compile, ['']) test('T14845_compile', normal, compile, ['']) test('T14991', normal, compile, ['']) -test('T15264', normal, compile, ['']) test('DkNameRes', normal, compile, ['']) test('T15346', normal, compile, ['']) test('T15419', normal, compile, ['']) diff --git a/testsuite/tests/dependent/should_fail/BadTelescope2.hs b/testsuite/tests/dependent/should_fail/BadTelescope2.hs index b12adbd8e3..e33fdf110e 100644 --- a/testsuite/tests/dependent/should_fail/BadTelescope2.hs +++ b/testsuite/tests/dependent/should_fail/BadTelescope2.hs @@ -10,5 +10,5 @@ data SameKind :: k -> k -> * foo :: forall a k (b :: k). SameKind a b foo = undefined -bar :: forall a (c :: Proxy b) (d :: Proxy a). Proxy c -> SameKind b d +bar :: forall a k (b :: k) (c :: Proxy b) (d :: Proxy a). Proxy c -> SameKind b d bar = undefined diff --git a/testsuite/tests/dependent/should_fail/BadTelescope2.stderr b/testsuite/tests/dependent/should_fail/BadTelescope2.stderr index 55a484910c..a8c4b689ae 100644 --- a/testsuite/tests/dependent/should_fail/BadTelescope2.stderr +++ b/testsuite/tests/dependent/should_fail/BadTelescope2.stderr @@ -5,9 +5,9 @@ BadTelescope2.hs:10:8: error: k (a :: k) (b :: k) • In the type signature: foo :: forall a k (b :: k). SameKind a b -BadTelescope2.hs:13:70: error: - • Expected kind ‘k0’, but ‘d’ has kind ‘Proxy a’ +BadTelescope2.hs:13:81: error: + • Expected kind ‘k’, but ‘d’ has kind ‘Proxy a’ • In the second argument of ‘SameKind’, namely ‘d’ In the type signature: - bar :: forall a (c :: Proxy b) (d :: Proxy a). + bar :: forall a k (b :: k) (c :: Proxy b) (d :: Proxy a). Proxy c -> SameKind b d diff --git a/testsuite/tests/dependent/should_compile/T15264.hs b/testsuite/tests/dependent/should_fail/T15264.hs index f3dec42564..394c53a013 100644 --- a/testsuite/tests/dependent/should_compile/T15264.hs +++ b/testsuite/tests/dependent/should_fail/T15264.hs @@ -1,5 +1,4 @@ {-# LANGUAGE ExplicitForAll, PolyKinds #-} -{-# OPTIONS -Wcompat -Wno-error=implicit-kind-vars #-} module T15264 where diff --git a/testsuite/tests/dependent/should_fail/T15264.stderr b/testsuite/tests/dependent/should_fail/T15264.stderr new file mode 100644 index 0000000000..6d5f597823 --- /dev/null +++ b/testsuite/tests/dependent/should_fail/T15264.stderr @@ -0,0 +1,6 @@ + +T15264.hs:7:22: error: Not in scope: type variable ‘k’ + +T15264.hs:10:22: error: Not in scope: type variable ‘k1’ + +T15264.hs:10:32: error: Not in scope: type variable ‘k2’ diff --git a/testsuite/tests/dependent/should_fail/T15825.hs b/testsuite/tests/dependent/should_fail/T15825.hs index 01227a8696..651525b21d 100644 --- a/testsuite/tests/dependent/should_fail/T15825.hs +++ b/testsuite/tests/dependent/should_fail/T15825.hs @@ -10,5 +10,5 @@ module T15825 where type C k = (forall (x::k). *) -class X (a :: *) -instance forall (a :: C k). X (a :: *) +class X (a :: *) +instance forall k (a :: C k). X (a :: *) diff --git a/testsuite/tests/dependent/should_fail/T15825.stderr b/testsuite/tests/dependent/should_fail/T15825.stderr index d64cab0494..97582ba952 100644 --- a/testsuite/tests/dependent/should_fail/T15825.stderr +++ b/testsuite/tests/dependent/should_fail/T15825.stderr @@ -1,5 +1,5 @@ -T15825.hs:14:29: error: +T15825.hs:14:31: error: • Illegal type synonym family application ‘GHC.Types.Any @k’ in instance: X (a @(GHC.Types.Any @k)) diff --git a/testsuite/tests/dependent/should_fail/all.T b/testsuite/tests/dependent/should_fail/all.T index a75886e8f6..57f718ebaa 100644 --- a/testsuite/tests/dependent/should_fail/all.T +++ b/testsuite/tests/dependent/should_fail/all.T @@ -39,3 +39,4 @@ test('T15743c', normal, compile_fail, ['']) test('T15743d', normal, compile_fail, ['']) test('T15825', normal, compile_fail, ['']) test('T15859', normal, compile_fail, ['']) +test('T15264', normal, compile_fail, ['']) diff --git a/testsuite/tests/ghci/scripts/T9293.stdout b/testsuite/tests/ghci/scripts/T9293.stdout index 6d140bc9f7..87b950654d 100644 --- a/testsuite/tests/ghci/scripts/T9293.stdout +++ b/testsuite/tests/ghci/scripts/T9293.stdout @@ -13,7 +13,6 @@ other dynamic, non-language, flag settings: -fimplicit-import-qualified -fshow-warning-groups warning settings: - -Wimplicit-kind-vars -Wmissing-monadfail-instances -Wsemigroup -Wnoncanonical-monoid-instances @@ -37,7 +36,6 @@ other dynamic, non-language, flag settings: -fimplicit-import-qualified -fshow-warning-groups warning settings: - -Wimplicit-kind-vars -Wmissing-monadfail-instances -Wsemigroup -Wnoncanonical-monoid-instances @@ -60,7 +58,6 @@ other dynamic, non-language, flag settings: -fimplicit-import-qualified -fshow-warning-groups warning settings: - -Wimplicit-kind-vars -Wmissing-monadfail-instances -Wsemigroup -Wnoncanonical-monoid-instances @@ -85,7 +82,6 @@ other dynamic, non-language, flag settings: -fimplicit-import-qualified -fshow-warning-groups warning settings: - -Wimplicit-kind-vars -Wmissing-monadfail-instances -Wsemigroup -Wnoncanonical-monoid-instances diff --git a/testsuite/tests/ghci/scripts/ghci024.stdout b/testsuite/tests/ghci/scripts/ghci024.stdout index 863184ad49..138da30075 100644 --- a/testsuite/tests/ghci/scripts/ghci024.stdout +++ b/testsuite/tests/ghci/scripts/ghci024.stdout @@ -14,7 +14,6 @@ other dynamic, non-language, flag settings: -fimplicit-import-qualified -fshow-warning-groups warning settings: - -Wimplicit-kind-vars -Wmissing-monadfail-instances -Wsemigroup -Wnoncanonical-monoid-instances diff --git a/testsuite/tests/ghci/scripts/ghci057.stdout b/testsuite/tests/ghci/scripts/ghci057.stdout index 6d140bc9f7..87b950654d 100644 --- a/testsuite/tests/ghci/scripts/ghci057.stdout +++ b/testsuite/tests/ghci/scripts/ghci057.stdout @@ -13,7 +13,6 @@ other dynamic, non-language, flag settings: -fimplicit-import-qualified -fshow-warning-groups warning settings: - -Wimplicit-kind-vars -Wmissing-monadfail-instances -Wsemigroup -Wnoncanonical-monoid-instances @@ -37,7 +36,6 @@ other dynamic, non-language, flag settings: -fimplicit-import-qualified -fshow-warning-groups warning settings: - -Wimplicit-kind-vars -Wmissing-monadfail-instances -Wsemigroup -Wnoncanonical-monoid-instances @@ -60,7 +58,6 @@ other dynamic, non-language, flag settings: -fimplicit-import-qualified -fshow-warning-groups warning settings: - -Wimplicit-kind-vars -Wmissing-monadfail-instances -Wsemigroup -Wnoncanonical-monoid-instances @@ -85,7 +82,6 @@ other dynamic, non-language, flag settings: -fimplicit-import-qualified -fshow-warning-groups warning settings: - -Wimplicit-kind-vars -Wmissing-monadfail-instances -Wsemigroup -Wnoncanonical-monoid-instances diff --git a/testsuite/tests/indexed-types/should_compile/ExplicitForAllFams1.hs b/testsuite/tests/indexed-types/should_compile/ExplicitForAllFams1.hs index 067127cf8a..c16e4e0156 100644 --- a/testsuite/tests/indexed-types/should_compile/ExplicitForAllFams1.hs +++ b/testsuite/tests/indexed-types/should_compile/ExplicitForAllFams1.hs @@ -26,6 +26,6 @@ type family H a b where -- More tests type family D a b where - forall (a :: Type -> Type) (b :: a Int) (c :: k). D (Proxy b) (Proxy c) = () + forall (a :: Type -> Type) (b :: a Int) k (c :: k). D (Proxy b) (Proxy c) = () forall (a :: Bool) (b :: Proxy a). D (Proxy b) () = Int forall (a :: Type). D a a = Maybe a diff --git a/testsuite/tests/patsyn/should_fail/T14498.hs b/testsuite/tests/patsyn/should_fail/T14498.hs index 0744310aee..b7f7db4d8a 100644 --- a/testsuite/tests/patsyn/should_fail/T14498.hs +++ b/testsuite/tests/patsyn/should_fail/T14498.hs @@ -23,9 +23,9 @@ type SN = (TypeRep :: N -> Type) pattern SO = (Typeable :: TypeRep (O::N)) pattern SS :: - forall (t :: k'). + forall k' (t :: k'). () - => forall (a :: kk -> k') (n :: kk). + => forall kk (a :: kk -> k') (n :: kk). (t ~ a n) => TypeRep n -> TypeRep t diff --git a/testsuite/tests/patsyn/should_fail/T14507.hs b/testsuite/tests/patsyn/should_fail/T14507.hs index b36425ced6..9599b73c77 100644 --- a/testsuite/tests/patsyn/should_fail/T14507.hs +++ b/testsuite/tests/patsyn/should_fail/T14507.hs @@ -13,7 +13,7 @@ foo rep = error "urk" type family SING :: k -> Type where SING = (TypeRep :: Bool -> Type) -pattern RepN :: forall (a::kk). () => Bool~kk => SING a -> TypeRep (a::kk) +pattern RepN :: forall kk (a::kk). () => Bool~kk => SING a -> TypeRep (a::kk) pattern RepN tr <- (foo -> ( HRefl :: Bool:~~:kk , tr :: TypeRep (a::Bool))) diff --git a/testsuite/tests/patsyn/should_fail/all.T b/testsuite/tests/patsyn/should_fail/all.T index 7cdef908a6..ef23572c0a 100644 --- a/testsuite/tests/patsyn/should_fail/all.T +++ b/testsuite/tests/patsyn/should_fail/all.T @@ -40,7 +40,7 @@ test('T13470', normal, compile_fail, ['']) test('T14112', normal, compile_fail, ['']) test('T14114', normal, compile_fail, ['']) test('T14380', normal, compile_fail, ['']) -test('T14498', normal, compile_fail, ['']) +test('T14498', expect_broken(16315), compile_fail, ['']) test('T14507', normal, compile_fail, ['-dsuppress-uniques']) test('T15289', normal, compile_fail, ['']) test('T15685', normal, compile_fail, ['']) diff --git a/testsuite/tests/polykinds/BadKindVar.hs b/testsuite/tests/polykinds/BadKindVar.hs index c24657f3d2..9275d453c5 100644 --- a/testsuite/tests/polykinds/BadKindVar.hs +++ b/testsuite/tests/polykinds/BadKindVar.hs @@ -5,5 +5,5 @@ module Foo where import Data.Proxy -- Should be illegal without PolyKinds -f :: forall (a :: k). Proxy a +f :: forall k (a :: k). Proxy a f = f diff --git a/testsuite/tests/polykinds/BadKindVar.stderr b/testsuite/tests/polykinds/BadKindVar.stderr index beeed2b3c8..3312350602 100644 --- a/testsuite/tests/polykinds/BadKindVar.stderr +++ b/testsuite/tests/polykinds/BadKindVar.stderr @@ -1,5 +1,5 @@ -BadKindVar.hs:8:19: error: +BadKindVar.hs:8:21: error: Unexpected kind variable ‘k’ Perhaps you intended to use PolyKinds In the type signature for ‘f’ diff --git a/testsuite/tests/polykinds/T10503.hs b/testsuite/tests/polykinds/T10503.hs index 2cc1ee717e..2b9900652f 100644 --- a/testsuite/tests/polykinds/T10503.hs +++ b/testsuite/tests/polykinds/T10503.hs @@ -5,5 +5,5 @@ data Proxy p = Proxy data KProxy (a :: *) = KProxy -h :: forall r . (Proxy ('KProxy :: KProxy k) ~ Proxy ('KProxy :: KProxy *) => r) -> r +h :: forall k r . (Proxy ('KProxy :: KProxy k) ~ Proxy ('KProxy :: KProxy *) => r) -> r h = undefined diff --git a/testsuite/tests/polykinds/T10503.stderr b/testsuite/tests/polykinds/T10503.stderr index 9fb87e9be7..a47a872253 100644 --- a/testsuite/tests/polykinds/T10503.stderr +++ b/testsuite/tests/polykinds/T10503.stderr @@ -4,14 +4,14 @@ T10503.hs:8:6: error: from the context: Proxy 'KProxy ~ Proxy 'KProxy bound by a type expected by the context: (Proxy 'KProxy ~ Proxy 'KProxy) => r - at T10503.hs:8:6-85 + at T10503.hs:8:6-87 ‘k’ is a rigid type variable bound by the type signature for: h :: forall k r. ((Proxy 'KProxy ~ Proxy 'KProxy) => r) -> r - at T10503.hs:8:6-85 + at T10503.hs:8:6-87 • In the ambiguity check for ‘h’ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes In the type signature: - h :: forall r. + h :: forall k r. (Proxy ('KProxy :: KProxy k) ~ Proxy ('KProxy :: KProxy *) => r) -> r diff --git a/testsuite/tests/polykinds/T14561.hs b/testsuite/tests/polykinds/T14561.hs index 7b1f17e08e..8c74ab4740 100644 --- a/testsuite/tests/polykinds/T14561.hs +++ b/testsuite/tests/polykinds/T14561.hs @@ -8,7 +8,7 @@ module T14561 where import GHC.Types import GHC.Prim -badId :: forall (a :: TYPE r). a -> a +badId :: forall r (a :: TYPE r). a -> a badId = unsafeCoerce# -- Un-saturated application of a levity-polymorphic -- function that must be eta-expanded diff --git a/testsuite/tests/polykinds/T14563.hs b/testsuite/tests/polykinds/T14563.hs index bdc05dd6df..aefa12b59e 100644 --- a/testsuite/tests/polykinds/T14563.hs +++ b/testsuite/tests/polykinds/T14563.hs @@ -5,5 +5,5 @@ import GHC.Types (TYPE) import Data.Kind data Lan (g::TYPE rep -> TYPE rep') (h::TYPE rep -> TYPE rep'') a where - Lan :: forall xx (g::TYPE rep -> TYPE rep') (h::TYPE rep -> Type) a. + Lan :: forall rep rep' xx (g::TYPE rep -> TYPE rep') (h::TYPE rep -> Type) a. (g xx -> a) -> h xx -> Lan g h a diff --git a/testsuite/tests/polykinds/T14887a.hs b/testsuite/tests/polykinds/T14887a.hs index 2e5cf02212..4179862cad 100644 --- a/testsuite/tests/polykinds/T14887a.hs +++ b/testsuite/tests/polykinds/T14887a.hs @@ -1,16 +1,10 @@ {-# LANGUAGE PartialTypeSignatures #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeInType #-} -{-# OPTIONS_GHC -Wno-partial-type-signatures -Wno-implicit-kind-vars #-} +{-# OPTIONS_GHC -Wno-partial-type-signatures #-} module Bug where import Data.Proxy -f1 :: forall (x :: a). Proxy (x :: _) --- This one has an implicitly-quantified kind var 'a', which --- we will stop accepting in the future, under the forall-or-nothing --- rule. Hence -Wno-implicit-kind-vars -f1 = Proxy - f2 :: forall a (x :: a). Proxy (x :: _) f2 = Proxy diff --git a/testsuite/tests/polykinds/T8616.hs b/testsuite/tests/polykinds/T8616.hs index 47e31bcc94..e8f4c682bf 100644 --- a/testsuite/tests/polykinds/T8616.hs +++ b/testsuite/tests/polykinds/T8616.hs @@ -4,11 +4,11 @@ module T8616 where import Data.Proxy import GHC.Exts -withSomeSing :: forall (kproxy :: k). Proxy kproxy +withSomeSing :: forall k (kproxy :: k). Proxy kproxy withSomeSing = undefined :: (Any :: k) -- The 'k' is bought into scope by the type signature -- This is a type error, but should not crash GHC -foo = (undefined :: Proxy (a :: k)) :: forall (a :: k). Proxy a +foo = (undefined :: Proxy (a :: k)) :: forall k (a :: k). Proxy a -- Again, the 'k' is bought into scope by the type signature - -- No type error though
\ No newline at end of file + -- No type error though diff --git a/testsuite/tests/polykinds/T8616.stderr b/testsuite/tests/polykinds/T8616.stderr index f9e5132a34..4341b3051a 100644 --- a/testsuite/tests/polykinds/T8616.stderr +++ b/testsuite/tests/polykinds/T8616.stderr @@ -4,7 +4,7 @@ T8616.hs:8:16: error: ‘k’ is a rigid type variable bound by the type signature for: withSomeSing :: forall k (kproxy :: k). Proxy kproxy - at T8616.hs:7:1-50 + at T8616.hs:7:1-52 When matching types a0 :: * Any :: k diff --git a/testsuite/tests/polykinds/T9144.hs b/testsuite/tests/polykinds/T9144.hs index 0a9ef08afa..85e1b24dbe 100644 --- a/testsuite/tests/polykinds/T9144.hs +++ b/testsuite/tests/polykinds/T9144.hs @@ -8,7 +8,7 @@ import GHC.TypeLits data family Sing (a :: k) data SomeSing :: KProxy k -> * where - SomeSing :: forall (a :: k). Sing a -> SomeSing ('KProxy :: KProxy k) + SomeSing :: forall k (a :: k). Sing a -> SomeSing ('KProxy :: KProxy k) class kproxy ~ 'KProxy => SingKind (kproxy :: KProxy k) where fromSing :: forall (a :: k). Sing a -> DemoteRep ('KProxy :: KProxy k) diff --git a/testsuite/tests/typecheck/should_fail/T12973.hs b/testsuite/tests/typecheck/should_fail/T12973.hs index b0a33a8213..765e02f34b 100644 --- a/testsuite/tests/typecheck/should_fail/T12973.hs +++ b/testsuite/tests/typecheck/should_fail/T12973.hs @@ -9,7 +9,7 @@ class Num (a :: TYPE r) where (+) :: a -> a -> a fromInteger :: P.Integer -> a -foo :: forall (a :: TYPE r). Num a => a +foo :: forall r (a :: TYPE r). Num a => a foo = 3 + 4 diff --git a/testsuite/tests/typecheck/should_fail/T15629.hs b/testsuite/tests/typecheck/should_fail/T15629.hs index fdbba60ccc..6d1d0b8897 100644 --- a/testsuite/tests/typecheck/should_fail/T15629.hs +++ b/testsuite/tests/typecheck/should_fail/T15629.hs @@ -23,5 +23,5 @@ sg _ _ = Proxy f :: forall (x :: Type). Proxy x -> () f _ = () where - g :: forall ab. Proxy ((Comp (F1Sym :: x ~> F x z) F2Sym) :: F x ab ~> F x ab) + g :: forall z ab. Proxy ((Comp (F1Sym :: x ~> F x z) F2Sym) :: F x ab ~> F x ab) g = sg Proxy Proxy diff --git a/testsuite/tests/typecheck/should_fail/T15629.stderr b/testsuite/tests/typecheck/should_fail/T15629.stderr index ce77bb04a3..a0e0f42286 100644 --- a/testsuite/tests/typecheck/should_fail/T15629.stderr +++ b/testsuite/tests/typecheck/should_fail/T15629.stderr @@ -1,12 +1,12 @@ -T15629.hs:26:35: error: +T15629.hs:26:37: error: • Expected kind ‘x1 ~> F x1 ab1’, but ‘F1Sym :: x ~> F x z’ has kind ‘x1 ~> F x1 z’ • In the first argument of ‘Comp’, namely ‘(F1Sym :: x ~> F x z)’ In the first argument of ‘Proxy’, namely ‘((Comp (F1Sym :: x ~> F x z) F2Sym) :: F x ab ~> F x ab)’ In the type signature: - g :: forall ab. + g :: forall z ab. Proxy ((Comp (F1Sym :: x ~> F x z) F2Sym) :: F x ab ~> F x ab) T15629.hs:27:9: error: @@ -14,11 +14,11 @@ T15629.hs:27:9: error: ‘ab1’ is a rigid type variable bound by the type signature for: g :: forall z1 ab1. Proxy (Comp F1Sym F2Sym) - at T15629.hs:26:5-82 + at T15629.hs:26:5-84 ‘z’ is a rigid type variable bound by the type signature for: g :: forall z1 ab1. Proxy (Comp F1Sym F2Sym) - at T15629.hs:26:5-82 + at T15629.hs:26:5-84 When matching types f0 :: x ~> F x ab F1Sym :: TyFun x1 (F x1 z) -> * @@ -31,7 +31,7 @@ T15629.hs:27:9: error: = () where g :: - forall ab. + forall z ab. Proxy ((Comp (F1Sym :: x ~> F x z) F2Sym) :: F x ab ~> F x ab) g = sg Proxy Proxy • Relevant bindings include |