[commit: ghc] master: typecheck: Don't warn about "redundant" TypeError constraints (d66ca01)

git at git.haskell.org git at git.haskell.org
Fri Jun 8 00:12:20 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/d66ca0111cefcda6620a4c82a932456b3e48874c/ghc

>---------------------------------------------------------------

commit d66ca0111cefcda6620a4c82a932456b3e48874c
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Thu Jun 7 13:40:57 2018 -0400

    typecheck: Don't warn about "redundant" TypeError constraints
    
    Summary: This fixes #15232, where we would warn about `TypeError` constraints being redundant.
    
    Test Plan: Validate
    
    Subscribers: rwbarton, thomie, carter
    
    GHC Trac Issues: #15232
    
    Differential Revision: https://phabricator.haskell.org/D4808


>---------------------------------------------------------------

d66ca0111cefcda6620a4c82a932456b3e48874c
 compiler/typecheck/TcErrors.hs                 | 11 ++++++++---
 testsuite/tests/typecheck/should_compile/all.T |  3 +--
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/compiler/typecheck/TcErrors.hs b/compiler/typecheck/TcErrors.hs
index 897ed96..95dc152 100644
--- a/compiler/typecheck/TcErrors.hs
+++ b/compiler/typecheck/TcErrors.hs
@@ -459,9 +459,14 @@ warnRedundantConstraints ctxt env info ev_vars
    doc = text "Redundant constraint" <> plural redundant_evs <> colon
          <+> pprEvVarTheta redundant_evs
 
-   redundant_evs = case info of -- See Note [Redundant constraints in instance decls]
-                     InstSkol -> filterOut improving ev_vars
-                     _        -> ev_vars
+   redundant_evs =
+       filterOut is_type_error $
+       case info of -- See Note [Redundant constraints in instance decls]
+         InstSkol -> filterOut improving ev_vars
+         _        -> ev_vars
+
+   -- See #15232
+   is_type_error = isJust . userTypeError_maybe . idType
 
    improving ev_var = any isImprovementPred $
                       transSuperClasses (idType ev_var)
diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T
index 2b7b9ef..0d2b089 100644
--- a/testsuite/tests/typecheck/should_compile/all.T
+++ b/testsuite/tests/typecheck/should_compile/all.T
@@ -621,5 +621,4 @@ test('SplitWD', normal, compile, [''])
 test('T14441', omit_ways(['profasm']), compile, [''])
 test('T15050', [expect_broken(15050)], compile, [''])
 test('T14735', normal, compile, [''])
-test('T15232', expect_broken(15232), compile, [''])
-
+test('T15232', normal, compile, [''])



More information about the ghc-commits mailing list