[GHC] #11016: PartialTypeSignatures trigger bogus "unbound implicit parameter" error

#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

#11016: PartialTypeSignatures trigger bogus "unbound implicit parameter" error -------------------------------------+------------------------------------- Reporter: gridaphobe | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Resolution: | 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: | -------------------------------------+------------------------------------- Comment (by gridaphobe): I see that commit 1e041b7 addresses this issue and fixes the 'unbound implicit parameter' error (thanks!!), but ghc still refuses to compile `f2`. {{{ % ./inplace/bin/ghc-stage2 Bad.hs [1 of 1] Compiling Bad ( Bad.hs, Bad.o ) Bad.hs:9:1: error: • Could not deduce: ?loc::t from the context: ?loc::Int bound by the inferred type for ‘f2’: (?loc::Int) => t at Bad.hs:9:1-9 • When checking that the inferred type f2 :: forall t. (?loc::t) => t is as general as its (partial) signature f2 :: forall t. (?loc::Int) => t }}} I think this error is still bogus, because ghc should not have inferred {{{ f2 :: forall t. (?loc::t) => t }}} in the first place. It should have inferred {{{ f2 :: (?loc::Int) => Int }}} which is a valid instantiation of the partial signature, and so should be OK. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11016#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11016: PartialTypeSignatures trigger bogus "unbound implicit parameter" error
-------------------------------------+-------------------------------------
Reporter: gridaphobe | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.10.2
Resolution: | 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: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#11016: PartialTypeSignatures trigger bogus "unbound implicit parameter" error -------------------------------------+------------------------------------- Reporter: gridaphobe | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: GHC rejects | Test Case: partial- valid program | sigs/should_compile/T11016 Blocked By: | Blocking: Related Tickets: #10846 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * testcase: => partial-sigs/should_compile/T11016 * status: new => closed * resolution: => fixed Comment: Excellent point, thank you! Fixed. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11016#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC