Unused tyvars in FamInst: only report user tyvars
This commit changes how we perform some validity checking for coercion axioms to mirror how we handle default declarations for associated type families. This allows us to keep track of whether type variables in type and data family instances were user-written or not, in order to only report the user-written ones in "unused type variable" error messages. Consider for example: {-# LANGUAGE PolyKinds #-} type family F type instance forall a. F = () In this case, we get two quantified type variables, (k :: Type) and (a :: k); the second being user-written, but the first is introduced by the typechecker. We should only report 'a' as being unused, as the user has no idea what 'k' is. Fixes #23734
Showing
- compiler/GHC/Core/Class.hs 43 additions, 24 deletionscompiler/GHC/Core/Class.hs
- compiler/GHC/Core/Coercion/Axiom.hs 27 additions, 17 deletionscompiler/GHC/Core/Coercion/Axiom.hs
- compiler/GHC/IfaceToCore.hs 1 addition, 1 deletioncompiler/GHC/IfaceToCore.hs
- compiler/GHC/Tc/Deriv/Generate.hs 3 additions, 1 deletioncompiler/GHC/Tc/Deriv/Generate.hs
- compiler/GHC/Tc/TyCl.hs 86 additions, 49 deletionscompiler/GHC/Tc/TyCl.hs
- compiler/GHC/Tc/TyCl/Build.hs 0 additions, 1 deletioncompiler/GHC/Tc/TyCl/Build.hs
- compiler/GHC/Tc/TyCl/Instance.hs 22 additions, 17 deletionscompiler/GHC/Tc/TyCl/Instance.hs
- compiler/GHC/Tc/Validity.hs 40 additions, 18 deletionscompiler/GHC/Tc/Validity.hs
- compiler/GHC/Tc/Zonk/Type.hs 1 addition, 1 deletioncompiler/GHC/Tc/Zonk/Type.hs
- testsuite/tests/indexed-types/should_fail/ExplicitForAllFams4b.stderr 12 additions, 12 deletions...sts/indexed-types/should_fail/ExplicitForAllFams4b.stderr
- testsuite/tests/indexed-types/should_fail/T17008a.stderr 2 additions, 2 deletionstestsuite/tests/indexed-types/should_fail/T17008a.stderr
- testsuite/tests/typecheck/should_fail/T23734.hs 1 addition, 1 deletiontestsuite/tests/typecheck/should_fail/T23734.hs
- testsuite/tests/typecheck/should_fail/T23734.stderr 22 additions, 0 deletionstestsuite/tests/typecheck/should_fail/T23734.stderr
- testsuite/tests/typecheck/should_fail/all.T 1 addition, 0 deletionstestsuite/tests/typecheck/should_fail/all.T
Loading
Please register or sign in to comment