diff options
author | Richard Eisenberg <rae@richarde.dev> | 2019-08-06 10:45:01 -0400 |
---|---|---|
committer | Vladislav Zavialov <vlad.z.4096@gmail.com> | 2019-08-16 13:04:41 +0300 |
commit | cfbb3873ee44d96c91714b8d9572b409738cc80b (patch) | |
tree | 8bdf432ef56e98ca3f3120776dc6901c284f310e | |
parent | ebbee458c8a7339e50efa1210383c07fc2e33e6a (diff) | |
download | haskell-cfbb3873ee44d96c91714b8d9572b409738cc80b.tar.gz |
Fix Note [Kind-checking tyvar binders for associated types]
-rw-r--r-- | compiler/typecheck/TcHsType.hs | 11 | ||||
-rw-r--r-- | compiler/typecheck/TcTyClsDecls.hs | 1 |
2 files changed, 7 insertions, 5 deletions
diff --git a/compiler/typecheck/TcHsType.hs b/compiler/typecheck/TcHsType.hs index dd6357ef68..4504f8c276 100644 --- a/compiler/typecheck/TcHsType.hs +++ b/compiler/typecheck/TcHsType.hs @@ -1797,6 +1797,7 @@ kcLHsQTyVars_Cusk name flav do { (scoped_kvs, (tc_tvs, res_kind)) <- pushTcLevelM_ $ solveEqualities $ + -- See Note [Kind-checking tyvar binders for associated types] bindImplicitTKBndrs_Q_Skol kv_ns $ bindExplicitTKBndrs_Q_Skol ctxt_kind hs_tvs $ thing_inside @@ -1961,16 +1962,15 @@ When kind-checking the type-variable binders for associated family decls we behave specially for type variables that are already in scope; that is, bound by the enclosing class decl. This is done in -kcLHsQTyVarBndrs: - * The use of tcImplicitQTKBndrs - * The tcLookupLocal_maybe code in kc_hs_tv +kcLHsQTyVars_Cusk and kcLHsQTyVars_NoCusk with +the use of bindImplicitTKBndrs_Q and bindExplicitTKBndrs_Q. See Note [Associated type tyvar names] in Class and Note [TyVar binders for associated decls] in HsDecls We must do the same for family instance decls, where the in-scope variables may be bound by the enclosing class instance decl. -Hence the use of tcImplicitQTKBndrs in tcFamTyPatsAndGen. +Hence the use of bindImplicitTKBndrs_Q_Skol in tcTyFamInstEqnGuts. Note [Kind variable ordering for associated types] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -2075,6 +2075,7 @@ bindImplicitTKBndrsX new_tv tv_names thing_inside newImplicitTyVarQ :: (Name -> TcM TcTyVar) -> Name -> TcM TcTyVar -- Behave like new_tv, except that if the tyvar is in scope, use it +-- See Note [Kind-checking tyvar binders for associated types] newImplicitTyVarQ new_tv name = do { mb_tv <- tcLookupLcl_maybe name ; case mb_tv of @@ -3000,7 +3001,7 @@ promotionErr name err -- | If the inner action emits constraints, report them as errors and fail; -- otherwise, propagates the return value. Useful as a wrapper around --- 'tcImplicitTKBndrs', which uses solveLocalEqualities, when there won't be +-- 'bindImplicitTKBndrs', which uses solveLocalEqualities, when there won't be -- another chance to solve constraints failIfEmitsConstraints :: TcM a -> TcM a failIfEmitsConstraints thing_inside diff --git a/compiler/typecheck/TcTyClsDecls.hs b/compiler/typecheck/TcTyClsDecls.hs index b9e51fa1f5..caf496482b 100644 --- a/compiler/typecheck/TcTyClsDecls.hs +++ b/compiler/typecheck/TcTyClsDecls.hs @@ -2300,6 +2300,7 @@ tcTyFamInstEqnGuts fam_tc mb_clsinfo imp_vars exp_bndrs hs_pats hs_rhs_ty ; (imp_tvs, (exp_tvs, (lhs_ty, rhs_ty))) <- pushTcLevelM_ $ solveEqualities $ + -- See Note [Kind-checking tyvar binders for associated types] bindImplicitTKBndrs_Q_Skol imp_vars $ bindExplicitTKBndrs_Q_Skol AnyKind exp_bndrs $ do { (lhs_ty, rhs_kind) <- tcFamTyPats fam_tc hs_pats |