[GHC] #16002: Type family equation with wrong name is silently accepted (GHC 8.6+ only)

GHC ghc-devs at haskell.org
Thu Dec 6 00:23:53 UTC 2018


#16002: Type family equation with wrong name is silently accepted (GHC 8.6+ only)
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.8.1
       Component:  Compiler          |              Version:  8.6.2
      Resolution:                    |             Keywords:  TypeFamilies
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 RyanGlScott):

 Ah, it's due to this change:

 {{{#!diff
  kcLTyClDecl :: LTyClDecl GhcRn -> TcM ()
    -- See Note [Kind checking for type and class decls]
  kcLTyClDecl (L loc decl)
 +  | hsDeclHasCusk decl
 +  = traceTc "kcTyClDecl skipped due to cusk" (ppr tc_name)
 +  | otherwise
    = setSrcSpan loc $
      tcAddDeclCtxt decl $
 -    do { traceTc "kcTyClDecl {" (ppr (tyClDeclLName decl))
 +    do { traceTc "kcTyClDecl {" (ppr tc_name)
         ; kcTyClDecl decl
 -       ; traceTc "kcTyClDecl done }" (ppr (tyClDeclLName decl)) }
 +       ; traceTc "kcTyClDecl done }" (ppr tc_name) }
 +  where
 +    tc_name = tyClDeclLName decl
 }}}

 Note that `kcTyClDecl` (which performs the validity check needed to reject
 `A x = x` above) is only invoked when a type family declaration lacks a
 CUSK!

 NB: This code no longer exists in GHC HEAD, as it has since been
 refactored into
 [http://git.haskell.org/ghc.git/blob/5f1d949ab9e09b8d95319633854b7959df06eb58:/compiler/typecheck/TcTyClsDecls.hs#l484
 kcTyClGroup]:

 {{{#!hs
 kcTyClGroup decls
   = do  { ...

         ; let (cusk_decls, no_cusk_decls)
                  = partition (hsDeclHasCusk . unLoc) decls

         ; ...

         ; mapM_ kcLTyClDecl no_cusk_decls

         ; ... }
 }}}

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


More information about the ghc-tickets mailing list