diff options
author | Richard Eisenberg <rae@richarde.dev> | 2021-01-05 22:40:53 -0500 |
---|---|---|
committer | Richard Eisenberg <rae@richarde.dev> | 2021-01-15 23:14:13 -0500 |
commit | 7d550ff71ee06c681756f60fbd3731559484afa3 (patch) | |
tree | eab8a083e327c06272f1c95833174ecf347bea45 /compiler/GHC/Core/InstEnv.hs | |
parent | 0dba78410887ffc3d219639081e284ef7b67560a (diff) | |
download | haskell-wip/T19106.tar.gz |
Make matchableGivens more reliably correct.wip/T19106
This has two fixes:
1. Take TyVarTvs into account in matchableGivens. This
fixes #19106.
2. Don't allow unifying alpha ~ Maybe alpha. This fixes
#19107.
This patch also removes a redundant Note and redirects
references to a better replacement.
Also some refactoring/improvements around the BindFun
in the pure unifier, which now can take the RHS type
into account.
Close #19106.
Close #19107.
Test case: partial-sigs/should_compile/T19106,
typecheck/should_compile/T19107
Diffstat (limited to 'compiler/GHC/Core/InstEnv.hs')
-rw-r--r-- | compiler/GHC/Core/InstEnv.hs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/GHC/Core/InstEnv.hs b/compiler/GHC/Core/InstEnv.hs index 1d1d550aca..24e1d84107 100644 --- a/compiler/GHC/Core/InstEnv.hs +++ b/compiler/GHC/Core/InstEnv.hs @@ -1060,9 +1060,9 @@ incoherent instances as long as there are others. ************************************************************************ -} -instanceBindFun :: TyCoVar -> BindFlag -instanceBindFun tv | isOverlappableTyVar tv = Skolem - | otherwise = BindMe +instanceBindFun :: BindFun +instanceBindFun tv _rhs_ty | isOverlappableTyVar tv = Apart + | otherwise = BindMe -- Note [Binding when looking up instances] {- @@ -1085,7 +1085,7 @@ them in the unification test. These are called "super skolems". Example: The op [x,x] means we need (Foo [a]). This `a` will never be instantiated, and so it is a super skolem. (See the use of tcInstSuperSkolTyVarsX in GHC.Tc.Gen.Pat.tcDataConPat.) Super skolems respond True to -isOverlappableTyVar, and the use of Skolem in instanceBindFun, above, means +isOverlappableTyVar, and the use of Apart in instanceBindFun, above, means that these will be treated as fresh constants in the unification algorithm during instance lookup. Without this treatment, GHC would complain, saying that the choice of instance depended on the instantiation of 'a'; but of |