[GHC] #12201: Wrong instance selection with overlapping instances and local bindings

GHC ghc-devs at haskell.org
Fri Jun 17 03:10:06 UTC 2016


#12201: Wrong instance selection with overlapping instances and local bindings
-------------------------------------+-------------------------------------
        Reporter:  kanetw            |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.0.1
  checker)                           |
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Description changed by kanetw:

@@ -1,1 +1,1 @@
- test and test2 should have the same type, but it seems like the {-#
+ test and test2 should have the same type, but it seems like the non-{#-

New description:

 test and test2 should have the same type, but it seems like the non-{#-
 OVERLAPPING #-} instance is chosen prematurely.
 {{{#!hs
 {-# LANGUAGE NoMonomorphismRestriction, FlexibleContexts,
 FlexibleInstances #-}
 module Bug where

 class A a where
 class A a => B a where

 data Foo s a
 instance {-# OVERLAPPING #-} A (Foo Int Bool)
 instance A (Foo s a)
 instance B (Foo s a)

 bar :: (A a, B a) => a
 bar = undefined

 helper :: Foo s Bool -> s -> Int
 helper = undefined

 {-
   *Bug> :t test
   test :: A (Foo s Bool) => s -> Int
 -}
 test = helper bar

 {-
   *Bug> :t test2
   test2 :: s -> Int
 -}
 test2 = let foo = bar in helper foo
 }}}

 Compare with 7.10.3:
 {{{
 *Bug> :t test
 test :: A (Foo s Bool) => s -> Int
 *Bug> :t test2
 test2 :: A (Foo s Bool) => s -> Int
 }}}

--

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12201#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list