summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc
diff options
context:
space:
mode:
authorsheaf <sam.derbyshire@gmail.com>2022-04-01 17:17:58 +0200
committerJakob Bruenker <jakob.bruenker@gmail.com>2022-04-01 20:36:01 +0200
commitaefb1e6d15749dd318e98a326d9df34b26c38cbd (patch)
tree8ccd34cc9c9fb1bff5697c3a945be44aecde3ee0 /compiler/GHC/Tc
parent9a325b59aeba2b52af1ab9e4ca0b1a8aafc82a54 (diff)
downloadhaskell-aefb1e6d15749dd318e98a326d9df34b26c38cbd.tar.gz
Ensure implicit parameters are lifted
`tcExpr` typechecked implicit parameters by introducing a metavariable of kind `TYPE kappa`, without enforcing that `kappa ~ LiftedRep`. This patch instead creates a metavariable of kind `Type`. Fixes #21327
Diffstat (limited to 'compiler/GHC/Tc')
-rw-r--r--compiler/GHC/Tc/Gen/Expr.hs8
1 files changed, 3 insertions, 5 deletions
diff --git a/compiler/GHC/Tc/Gen/Expr.hs b/compiler/GHC/Tc/Gen/Expr.hs
index b5e9982f48..c9e4421a7d 100644
--- a/compiler/GHC/Tc/Gen/Expr.hs
+++ b/compiler/GHC/Tc/Gen/Expr.hs
@@ -240,11 +240,9 @@ tcExpr (NegApp x expr neg_expr) res_ty
; return (NegApp x expr' neg_expr') }
tcExpr e@(HsIPVar _ x) res_ty
- = do { {- Implicit parameters must have a *tau-type* not a
- type scheme. We enforce this by creating a fresh
- type variable as its type. (Because res_ty may not
- be a tau-type.) -}
- ip_ty <- newOpenFlexiTyVarTy
+ = do { ip_ty <- newFlexiTyVarTy liftedTypeKind
+ -- Create a unification type variable of kind 'Type'.
+ -- (The type of an implicit parameter must have kind 'Type'.)
; let ip_name = mkStrLitTy (hsIPNameFS x)
; ipClass <- tcLookupClass ipClassName
; ip_var <- emitWantedEvVar origin (mkClassPred ipClass [ip_name, ip_ty])