
#12466: Typechecker regression: Inaccessible code in a type expected by the context -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: new Priority: highest | Milestone: 8.2.1 Component: Compiler (Type | Version: 8.1 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * cc: ekmett (added) Comment: Sorry, my previous estimate was off the mark. It's not that the definition of `$dmfoo` is being inlined. Rather, after reading d2958bd08a049b61941f078e51809c7e63bc3354 more closely, the real culprit is that prior to that commit, default methods weren't being typechecked for each instance! As a result, the code was sneaking past the typechecker. But I'm still confused as to why defining: {{{#!hs instance Foo Char where foo _ x = x }}} typechecks without issue (on all versions of GHC), but defining the instance in terms of a helper method: {{{#!hs fooDefault :: (a ~ Int => Int) -> a -> a fooDefault _ a2 = a2 instance Foo Char where foo = fooDefault @Char }}} is rejected with an error. cc'ing Edward Kmett on this one, since if `lens` really is using code that shouldn't typecheck, `lens` is going to need to come up with a workaround. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12466#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler