[GHC] #12959: GHC doesn't warn about missing implementations for class methods beginning with an underscore

GHC ghc-devs at haskell.org
Sun Dec 11 01:17:20 UTC 2016


#12959: GHC doesn't warn about missing implementations for class methods beginning
with an underscore
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  Other             |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 I believe I've found
 [http://git.haskell.org/ghc.git/blob/490b9429a8ed3c55d17bf0964fb14582eb206a3d:/compiler/typecheck/TcClassDcl.hs#l283
 the function] that's responsible for this behavior:

 {{{#!hs
 tcClassMinimalDef :: Name -> [LSig Name] -> [TcMethInfo] -> TcM
 ClassMinimalDef
 tcClassMinimalDef _clas sigs op_info
   = case findMinimalDef sigs of
       Nothing -> return defMindef
       Just mindef -> do
         -- Warn if the given mindef does not imply the default one
         -- That is, the given mindef should at least ensure that the
         -- class ops without default methods are required, since we
         -- have no way to fill them in otherwise
         whenIsJust (isUnsatisfied (mindef `impliesAtom`) defMindef) $
                    (\bf -> addWarnTc NoReason (warningMinimalDefIncomplete
 bf))
         return mindef
   where
     -- By default require all methods without a default
     -- implementation whose names don't start with '_'
     defMindef :: ClassMinimalDef
     defMindef = mkAnd [ noLoc (mkVar name)
                       | (name, _, Nothing) <- op_info
                       , not (startsWithUnderscore (getOccName name)) ]
 }}}

 Notice that `defMindef` deliberately discards method names that begin with
 an underscore. So fixing this ticket would be a simple matter of removing
 that line.

 That being said, I'm worried that there's a comment in this code
 explicitly calling out the case in which a method's name begins with `_`.
 Is there a story behind this comment? (e.g., did someone ask for this to
 be the case?)

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


More information about the ghc-tickets mailing list