
#12387: Template Haskell ignores class instance definitions with methods that don't belong to the class -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC accepts | Unknown/Multiple invalid program | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj): I made a little progress with this, which I'll record. The bug is here in `RnEnv.lookupSubBndrOcc`. Usually this function looks up an unqualified `RdrName` and uses the parent info in the `GlobalRdrEnv` to disambiguate; and to check that the specified name is indeed a method of the parent class. But here are in the `Exact` `RdrName` case: {{{ lookupSubBndrOcc warn_if_deprec the_parent doc rdr_name | Just n <- isExact_maybe rdr_name -- This happens in derived code = do { n <- lookupExactOcc n ; return (Right n) } }}} In the example `'compare` refers precisely to `GHC.Classes.compare`, so we get an `Exact` `RdrName`. But that `compare` may not even be in scope, and may not be in the `GlobalRdrEnv`. We are omitting a check for the correct parent; hence the lack of error message. What to do? Either * If it's not in scope it must presumably be imported and hence in the `TypeEnv`. So we could look for parent-hood that way. A bit of a pain. * Or we could postpone the check altogether to the typechecker. I like this plan better because it works uniformly for local and imported things. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12387#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler