
#10619: Order matters when type-checking -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- When I say {{{ {-# LANGUAGE RankNTypes #-} module Bug where foo True = (\x -> x) :: (forall a. a -> a) -> forall b. b -> b foo False = \y -> y }}} the module compiles. But when I say {{{ {-# LANGUAGE RankNTypes #-} module Bug where foo False = \y -> y foo True = (\x -> x) :: (forall a. a -> a) -> forall b. b -> b }}} it doesn't, failing with {{{ Bug.hs:6:13: Couldn't match type ‘b0 -> b0’ with ‘forall a. a -> a’ Expected type: (forall a. a -> a) -> forall a. a -> a Actual type: (forall a. a -> a) -> b0 -> b0 In the expression: (\ x -> x) :: (forall a. a -> a) -> forall b. b -> b In an equation for ‘foo’: foo True = (\ x -> x) :: (forall a. a -> a) -> forall b. b -> b }}} I believe this behavior stems from the special case in `tcMonoBinds`, for non-recursive functions without a type signature. I believe the bug would be fixed if that function also checks to make sure that there is precisely one clause to the function. Do you agree? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10619 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler