Simon Peyton Jones pushed to branch wip/T25992 at Glasgow Haskell Compiler / GHC

Commits:

4 changed files:

Changes:

  • compiler/GHC/Tc/Solver/Default.hs
    ... ... @@ -247,11 +247,11 @@ tryUnsatisfiableGivens wc =
    247 247
          ; solveAgainIf did_work final_wc }
    
    248 248
       where
    
    249 249
         go_wc (WC { wc_simple = wtds, wc_impl = impls, wc_errors = errs })
    
    250
    -      = do impls' <- mapMaybeBagM go_impl impls
    
    250
    +      = do impls' <- mapBagM go_impl impls
    
    251 251
                return $ WC { wc_simple = wtds, wc_impl = impls', wc_errors = errs }
    
    252 252
         go_impl impl
    
    253 253
           | isSolvedStatus (ic_status impl)
    
    254
    -      = return $ Just impl
    
    254
    +      = return impl
    
    255 255
           -- Is there a Given with type "Unsatisfiable msg"?
    
    256 256
           -- If so, use it to solve all other Wanteds.
    
    257 257
           | unsat_given:_ <- mapMaybe unsatisfiableEv_maybe (ic_given impl)
    
    ... ... @@ -271,7 +271,7 @@ unsatisfiableEv_maybe v = (v,) <$> isUnsatisfiableCt_maybe (idType v)
    271 271
     -- | We have an implication with an 'Unsatisfiable' Given; use that Given to
    
    272 272
     -- solve all the other Wanted constraints, including those nested within
    
    273 273
     -- deeper implications.
    
    274
    -solveImplicationUsingUnsatGiven :: (EvVar, Type) -> Implication -> TcS (Maybe Implication)
    
    274
    +solveImplicationUsingUnsatGiven :: (EvVar, Type) -> Implication -> TcS Implication
    
    275 275
     solveImplicationUsingUnsatGiven
    
    276 276
       unsat_given@(given_ev,_)
    
    277 277
       impl@(Implic { ic_wanted = wtd, ic_tclvl = tclvl, ic_binds = ev_binds_var
    
    ... ... @@ -279,7 +279,7 @@ solveImplicationUsingUnsatGiven
    279 279
       | isCoEvBindsVar ev_binds_var
    
    280 280
       -- We can't use Unsatisfiable evidence in kinds.
    
    281 281
       -- See Note [Coercion evidence only] in GHC.Tc.Types.Evidence.
    
    282
    -  = return $ Just impl
    
    282
    +  = return impl
    
    283 283
       | otherwise
    
    284 284
       = do { wcs <- nestImplicTcS ev_binds_var tclvl $ go_wc wtd
    
    285 285
            ; setImplicationStatus $
    
    ... ... @@ -290,7 +290,7 @@ solveImplicationUsingUnsatGiven
    290 290
         go_wc :: WantedConstraints -> TcS WantedConstraints
    
    291 291
         go_wc wc@(WC { wc_simple = wtds, wc_impl = impls })
    
    292 292
           = do { mapBagM_ go_simple wtds
    
    293
    -           ; impls <- mapMaybeBagM (solveImplicationUsingUnsatGiven unsat_given) impls
    
    293
    +           ; impls <- mapBagM (solveImplicationUsingUnsatGiven unsat_given) impls
    
    294 294
                ; return $ wc { wc_simple = emptyBag, wc_impl = impls } }
    
    295 295
         go_simple :: Ct -> TcS ()
    
    296 296
         go_simple ct = case ctEvidence ct of
    

  • testsuite/tests/typecheck/should_compile/T25992.hs
    1
    +{-# OPTIONS_GHC -Wredundant-constraints #-}
    
    2
    +
    
    3
    +module T25992 where
    
    4
    +
    
    5
    +data P a = P
    
    6
    +
    
    7
    +instance Eq a => Semigroup (P a) where
    
    8
    +  P <> P = P

  • testsuite/tests/typecheck/should_compile/T25992.stderr
    1
    + T25992.hs:7:10: error: [GHC-30606] [-Wredundant-constraints, Werror=redundant-constraints]
    
    2
    +    • Redundant constraint: Eq a
    
    3
    +    • In the instance declaration for ‘Semigroup (P a)’

  • testsuite/tests/typecheck/should_compile/all.T
    ... ... @@ -941,3 +941,4 @@ test('T25597', normal, compile, [''])
    941 941
     test('T25960', normal, compile, [''])
    
    942 942
     test('T26020', normal, compile, [''])
    
    943 943
     test('T26020a', [extra_files(['T26020a_help.hs'])], multimod_compile, ['T26020a', '-v0'])
    
    944
    +test('T25992', normal, compile, [''])