Commit 1bfff60f authored by Simon Peyton Jones's avatar Simon Peyton Jones

Fix inference of partial signatures

When we had
  f :: ( _ ) => blah
we were failing to call growThetaTyVars, as we do in the
no-type-signature case, and that meant that we weren't generalising
over the right type variables.  I'm quite surprised this didn't cause
problems earlier.

Anyway Trac #12844 showed it up and this patch fixes it
parent eb55ec29
......@@ -822,8 +822,11 @@ chooseInferredQuantifiers inferred_theta tau_tvs qtvs
| Just wc_var <- wcx
= do { annotated_theta <- zonkTcTypes annotated_theta
; let free_tvs = closeOverKinds (tyCoVarsOfTypes annotated_theta
`unionVarSet` tau_tvs)
; let free_tvs = closeOverKinds (growThetaTyVars inferred_theta seed_tvs)
-- growThetaVars just like the no-type-sig case
-- Omitting this caused #12844
seed_tvs = tyCoVarsOfTypes annotated_theta -- These are put there
`unionVarSet` tau_tvs -- by the user
my_theta = pickCapturedPreds free_tvs inferred_theta
-- Report the inferred constraints for an extra-constraints wildcard/hole as
......
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
module T12844 where
barWraper :: ('(r,r') ~ Head rngs, Foo rngs) => FooData rngs
barWraper = bar
bar :: (_) => FooData rngs
bar = foo
data FooData rngs
class Foo xs where foo :: (Head xs ~ '(r,r')) => FooData xs
type family Head (xs :: [k]) where Head (x ': xs) = x
T12844.hs:12:9: warning: [-Wpartial-type-signatures (in -Wdefault)]
• Found type wildcard ‘_’
standing for ‘(Head rngs ~ '(r, r'), Foo rngs)’
Where: ‘r’ is a rigid type variable bound by
the inferred type of
bar :: (Head rngs ~ '(r, r'), Foo rngs) => FooData rngs
at T12844.hs:13:1-9
‘r'’ is a rigid type variable bound by
the inferred type of
bar :: (Head rngs ~ '(r, r'), Foo rngs) => FooData rngs
at T12844.hs:13:1-9
‘rngs’ is a rigid type variable bound by
the inferred type of
bar :: (Head rngs ~ '(r, r'), Foo rngs) => FooData rngs
at T12844.hs:13:1-9
‘k’ is a rigid type variable bound by
the inferred type of
bar :: (Head rngs ~ '(r, r'), Foo rngs) => FooData rngs
at T12844.hs:13:1-9
‘k1’ is a rigid type variable bound by
the inferred type of
bar :: (Head rngs ~ '(r, r'), Foo rngs) => FooData rngs
at T12844.hs:13:1-9
• In the type signature: bar :: _ => FooData rngs
......@@ -68,3 +68,4 @@ test('T11670', normal, compile, [''])
test('T12156', normal, compile_fail, ['-fdefer-typed-holes'])
test('T12531', normal, compile, ['-fdefer-typed-holes'])
test('T12845', normal, compile, [''])
test('T12844', normal, compile, [''])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment