Typechecker allows a skolem to escapt
This program make GHC 7.4 and GHC 7.6 rc1 give a Lint error, because a skolem is allowed to escape
```
{-# LANGUAGE MultiParamTypeClasses, TypeFamilies, FlexibleContexts #-}
module Foo where
type family F a
class C b where {}
foo :: a -> F a
foo x = error "urk"
h :: (b -> ()) -> Int
h = error "urk"
f = h (\x -> let g :: C (F a) => a -> Int
g y = length [x, foo y]
in ())
```
This is the result with 7.6 rc1
```
*** Core Lint errors : in result of Desugar (after optimization) ***
<no location info>: Warning:
In the expression: Foo.h @ (Foo.F a_o) (\ _ -> GHC.Tuple.())
@ a_o is out of scope
*** Offending Program ***
Foo.h :: forall b_aeJ. (b_aeJ -> ()) -> GHC.Types.Int
[LclIdX]
Foo.h =
\ (@ b_d) ->
GHC.Err.error
@ ((b_d -> ()) -> GHC.Types.Int) (GHC.CString.unpackCString# "urk")
Foo.f :: GHC.Types.Int
[LclIdX]
Foo.f = Foo.h @ (Foo.F a_o) (\ _ -> GHC.Tuple.())
Foo.foo :: forall a_aeL. a_aeL -> Foo.F a_aeL
[LclIdX]
Foo.foo =
\ (@ a_g) _ ->
GHC.Err.error @ (Foo.F a_g) (GHC.CString.unpackCString# "urk")
*** End of Offense ***
```
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 7.4.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Typechecker allows a skolem to escapt","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"7.4.2","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This program make GHC 7.4 and GHC 7.6 rc1 give a Lint error, because a skolem is allowed to escape\r\n{{{\r\n{-# LANGUAGE MultiParamTypeClasses, TypeFamilies, FlexibleContexts #-} \r\n\r\nmodule Foo where\r\n\r\ntype family F a\r\n\r\nclass C b where {}\r\n\r\nfoo :: a -> F a\r\nfoo x = error \"urk\"\r\n\r\nh :: (b -> ()) -> Int\r\nh = error \"urk\"\r\n\r\nf = h (\\x -> let g :: C (F a) => a -> Int\r\n g y = length [x, foo y]\r\n in ())\r\n}}}\r\nThis is the result with 7.6 rc1\r\n{{{\r\n*** Core Lint errors : in result of Desugar (after optimization) ***\r\n<no location info>: Warning:\r\n In the expression: Foo.h @ (Foo.F a_o) (\\ _ -> GHC.Tuple.())\r\n @ a_o is out of scope\r\n*** Offending Program ***\r\nFoo.h :: forall b_aeJ. (b_aeJ -> ()) -> GHC.Types.Int\r\n[LclIdX]\r\nFoo.h =\r\n \\ (@ b_d) ->\r\n GHC.Err.error\r\n @ ((b_d -> ()) -> GHC.Types.Int) (GHC.CString.unpackCString# \"urk\")\r\n\r\nFoo.f :: GHC.Types.Int\r\n[LclIdX]\r\nFoo.f = Foo.h @ (Foo.F a_o) (\\ _ -> GHC.Tuple.())\r\n\r\nFoo.foo :: forall a_aeL. a_aeL -> Foo.F a_aeL\r\n[LclIdX]\r\nFoo.foo =\r\n \\ (@ a_g) _ ->\r\n GHC.Err.error @ (Foo.F a_g) (GHC.CString.unpackCString# \"urk\")\r\n\r\n*** End of Offense ***\r\n}}}\r\n","type_of_failure":"OtherFailure","blocking":[]} -->
issue