summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc
diff options
context:
space:
mode:
authorsheaf <sam.derbyshire@gmail.com>2022-01-26 14:24:48 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-02-08 05:27:25 -0500
commita9355e84480e421a22fee57d6ee24d9ec059e128 (patch)
tree7994b81532b131db79c56a25c17d6ee34e1f63dd /compiler/GHC/Tc
parentff867c460db9cfc43f5697c8e582f8c1ea4bd572 (diff)
downloadhaskell-a9355e84480e421a22fee57d6ee24d9ec059e128.tar.gz
Allow HasField in quantified constraints
We perform validity checking on user-written HasField instances, for example to disallow: data Foo a = Foo { fld :: Int } instance HasField "fld" (Foo a) Bool However, these checks were also being made on quantified constraints, e.g. data Bar where Bar :: (forall a. HasField s (Foo a) Int) => Proxy s -> Bar This patch simply skips validity checking for quantified constraints, in line with what we already do for equality constraints such as Coercible. Fixes #20989
Diffstat (limited to 'compiler/GHC/Tc')
-rw-r--r--compiler/GHC/Tc/Validity.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/GHC/Tc/Validity.hs b/compiler/GHC/Tc/Validity.hs
index 9d6a05c7aa..cad2ea1796 100644
--- a/compiler/GHC/Tc/Validity.hs
+++ b/compiler/GHC/Tc/Validity.hs
@@ -1417,6 +1417,10 @@ check_special_inst_head dflags is_boot is_sig ctxt clas cls_args
; when (safeInferOn dflags) (recordUnsafeInfer emptyMessages) }
| clas_nm == hasFieldClassName
+ , not quantified_constraint
+ -- Don't do any validity checking for HasField contexts
+ -- inside quantified constraints (#20989): the validity checks
+ -- only apply to user-written instances.
= checkHasFieldInst clas cls_args
| isCTupleClass clas