
#12881: GHC 8.0.2 regression involving OVERLAP annotations -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.2 Component: Compiler | Version: 8.0.2-rc1 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: | -------------------------------------+------------------------------------- @@ -16,15 +16,0 @@ - {{{ - $ /opt/ghc/8.0.2/bin/ghc Bug.hs - [1 of 1] Compiling Bug ( Bug.hs, Bug.o ) - - Bug.hs:9:10: error: - • Overlapping instances for Arbitrary Int - arising from a use of ‘Bug.$dmshrink’ - Matching instances: - instance Arbitrary a -- Defined at Bug.hs:8:10 - instance Arbitrary Int -- Defined at Bug.hs:9:10 - • In the expression: Bug.$dmshrink @Int - In an equation for ‘shrink’: shrink = Bug.$dmshrink @Int - In the instance declaration for ‘Arbitrary Int’ - }}} - New description: `quickcheck-combinators-0.0.1` fails to build with GHC 8.0.2-rc1 (but does build with GHC 8.0.1) due to this issue. Here is a simplified example: {{{#!hs {-# LANGUAGE FlexibleInstances #-} module Bug where class Arbitrary a where shrink :: a -> [a] shrink _ = [] instance Arbitrary a instance Arbitrary Int }}} Is this expected? If so, we should make a note of this in the 8.0.2 release notes. -- Comment (by simonpj): Well there really is an issue here. Suppose you added to the program in the Description {{{ foo :: [Int] -> Int foo x = shrink x }}} then you'd ''expect'' to get the warning {{{ T12881.hs:15:9: error: • Overlapping instances for Arbitrary Int arising from a use of ‘shrink’ Matching instances: instance Arbitrary a -- Defined at T12881.hs:8:10 instance Arbitrary Int -- Defined at T12881.hs:10:10 • In the expression: shrink x In an equation for ‘foo’: foo x = shrink x }}} So, without the pragmas, or the global `-XOverlappingInstances`, the instance declarations for `Arbitrary` are effectively useless. Now, it's true that 8.0.2 is reporting that problem a bit more eagerly than before. I suppose we could switch on `-XOverlappingInstances` when typechecking the default methods in each instance declaration. But that feels like sweeping the real problem under the carpet: those instances really are useless unless you allow overlapping. So the right solution is to add those pragmas. We could mitigate for 8.0.3 (as suggested in the previous para) but I worry that the same thing would happen in 8.2. Advice? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12881#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler