
#11016: PartialTypeSignatures trigger bogus "unbound implicit parameter" error -------------------------------------+------------------------------------- Reporter: gridaphobe | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: GHC rejects Unknown/Multiple | valid program Test Case: | Blocked By: Blocking: | Related Tickets: #10846 Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- GHC seems to forget about in-scope implicit parameters when there's a hole in the type signature. Given {{{#!haskell {-# LANGUAGE ImplicitParams, PartialTypeSignatures #-} module Bad where f1 :: (?loc :: Int, _) => Int f1 = ?loc f2 :: (?loc :: Int) => _ f2 = ?loc }}} GHC incorrectly reports the following errors. {{{ % ghc -fforce-recomp Bad.hs [1 of 1] Compiling Bad ( Bad.hs, Bad.o ) Bad.hs:8:6: Unbound implicit parameter (?loc::Int) arising from a use of implicit parameter ‘?loc’ In the expression: ?loc In an equation for ‘f1’: f1 = ?loc Bad.hs:11:1: Occurs check: cannot construct the infinite type: _ ~ (?loc::Int) => _ When checking that ‘f2’ has the specified type f2 :: (?loc::Int) => _ Probable cause: the inferred type is ambiguous Bad.hs:11:6: Unbound implicit parameter (?loc::_) arising from a use of implicit parameter ‘?loc’ Relevant bindings include f2 :: _ (bound at Bad.hs:11:1) In the expression: ?loc In an equation for ‘f2’: f2 = ?loc }}} `?loc` is very clearly bound by both `f1` and `f2`'s signature. `f2` additionally reports what looks to me to be a bogus occurs-check error; we know from the theta that `?loc :: Int` so the hole should be solved for `Int`. I suspect this is all related to the fact that PartialTypeSignatures triggers `tcPolyInfer` instead of `tcPolyCheck`. I think this is the same underlying bug as #10846. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11016 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler