[project @ 2005-02-04 17:24:01 by simonpj]
authorsimonpj <unknown>
Fri, 4 Feb 2005 17:24:09 +0000 (17:24 +0000)
committersimonpj <unknown>
Fri, 4 Feb 2005 17:24:09 +0000 (17:24 +0000)
commitc36a2f9b4fd728e359da3c700938cc56eef90738
tree937bcd37122e6206af60ae08edd7c5f199a8e164
parent6ac3317e3c882d2010ceb5cdd3c059633860cd42
[project @ 2005-02-04 17:24:01 by simonpj]
------------------------------------------------------
Report top-level implicit parameter errors more nicely
------------------------------------------------------

Consider
    module Main where

main = let ?x = 5 in print foo

foo = woggle 3

woggle :: (?x :: Int) => Int -> Int
woggle y = ?x + y

GHC's current rules say that 'foo' is monomorphic, so we get
foo :: Int
but we also get an unbound top-level constraint (?x::Int).  GHC 6.2 emits a
message like:
     Unbound implicit parameter (?x::Int)
     arising from use of `woggle' at ...

The point is that THERE IS NO WAY FOR THIS CONSTRAINT TO GET BOUND,
because we don't have a top-level binding form for implicit parameters.
So it's stupid for 'foo' to be monomorphic.

This commit improves matters by giving a much nicer error message:

     Implicit parameters escape from the monomorphic top-level binding(s) of `foo':
       ?x::Int arising from use of `woggle' at tcfail130.hs:10:6-11
     Probably fix: add type signatures for the top-level binding(s)
     When generalising the type(s) for `foo'
ghc/compiler/typecheck/TcBinds.lhs
ghc/compiler/typecheck/TcEnv.lhs
ghc/compiler/typecheck/TcRnTypes.lhs
ghc/compiler/typecheck/TcSimplify.lhs