[GHC] #12881: GHC 8.0.2 regression involving OVERLAP annotations
GHC
ghc-devs at haskell.org
Mon Nov 28 15:30:11 UTC 2016
#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: |
-------------------------------------+-------------------------------------
Comment (by RyanGlScott):
So it looks like what is going on here is that in GHC 8.0.1 and before,
there was different code generated under the hood for default class method
implementations. This code happened to work irrespective of whether any
overlapping instances were marked with `OVERLAPPING` or not. That's not to
say that leaving off `OVERLAPPING` pragmas couldn't have caused problems
down the road in GHC 8.0.1, but in the particular case of default method
implementations, it luckily didn't matter.
In GHC 8.0.2, however (after
https://ghc.haskell.org/trac/ghc/changeset/d2958bd08a049b61941f078e51809c7e63bc3354/ghc),
GHC switched to using visible type application to implement default class
method implementations. This now poses an issue for any overlapping
instances with default method implementations, because in the code that
gets generated now, e.g.,
{{{#!hs
instance Arbitrary Int where
shrink = dmshrink @Int
}}}
`dmshrink @Int` is forced to choose a particular `Arbitrary` instance, and
without the `OVERLAPPING` annotation, GHC can't decide between the
`Arbitrary a` instance and the `Arbitrary Int` instance.
So on one hand, there is a somewhat good reason why this code now fails to
typecheck. On the other hand, it's quite annoying—a nontrivial number of
packages in the wild now fail to build with GHC 8.0.2, and there are
probably more examples outside of Stackage that I haven't found. I'm not
sure how to address this.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12881#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list