[GHC] #7766: equality constraints exposed by patterns mess up constraint inference

#7766: equality constraints exposed by patterns mess up constraint inference --------------------------------------+------------------------------------- Reporter: heisenbug | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.7 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: GHC rejects valid program | Blockedby: Blocking: | Related: --------------------------------------+------------------------------------- When patterns bring (equality) constraints into scope, the inference mechanism for other (unrelated) constraints breaks down. This is a new problem that appeared between * ghc-7.7.20121025 and * ghc-7.7.20121114 I can try to track down the commit if that helps. Testcase against HEAD attached. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7766 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7766: equality constraints exposed by patterns mess up constraint inference ----------------------------------------+----------------------------------- Reporter: heisenbug | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.7 Resolution: invalid | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: GHC rejects valid program | Difficulty: Unknown Testcase: | Blockedby: Blocking: | Related: ----------------------------------------+----------------------------------- Changes (by simonpj): * status: new => closed * difficulty: => Unknown * resolution: => invalid Comment: This is by design. Type inference in the presence of GADTs is tricky! If you give the signature `main :: IO ()` it works fine. But here you are asking GHC to ''infer'' the type of `main`. (Remember, Haskell doesn't insist on `IO ()`; the `main` function can have type `IO Char`.) Becuase you are pattern matching against GADTs there are equalities in scope, so GHC declines to contrain the type of `main`. In this particular case there is only one answer, but that's very hard to figure out, so we fail conservatively. Bottom line: use type signatures when pattern matching on GADTs. Simon -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7766#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC