Skip to content
  • Ryan Scott's avatar
    Check that a default type signature aligns with the non-default signature · 7363d538
    Ryan Scott authored
    Before, GHC was extremely permissive about the form a default type
    signature could take on in a class declaration. Notably, it would accept
    garbage like this:
    
      class Monad m => MonadSupply m where
        fresh :: m Integer
        default fresh :: MonadTrans t => t m Integer
        fresh = lift fresh
    
    And then give an extremely confusing error message when you actually
    tried to declare an empty instance of MonadSupply. We now do extra
    validity checking of default type signatures to ensure that they align
    with their non-default type signature counterparts. That is, a default
    type signature is allowed to differ from the non-default one only in its
    context - they must otherwise be alpha-equivalent.
    
    Fixes #12918.
    
    Test Plan: ./validate
    
    Reviewers: goldfire, simonpj, austin, bgamari
    
    Reviewed By: bgamari
    
    Subscribers: mpickering, dfeuer, thomie
    
    Differential Revision: https://phabricator.haskell.org/D2983
    
    GHC Trac Issues: #12918
    7363d538