diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2015-01-05 13:20:48 +0000 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2015-01-06 14:21:13 +0000 |
commit | 32973bf3c2f6fe00e01b44a63ac1904080466938 (patch) | |
tree | dcefa6b0b92f2cefda9c0ce8944169da0036d598 /testsuite/tests/deriving/should_compile | |
parent | da9b2ec3e19edb1de0e73e8f32aa0443743f072c (diff) | |
download | haskell-32973bf3c2f6fe00e01b44a63ac1904080466938.tar.gz |
Major patch to add -fwarn-redundant-constraints
The idea was promted by Trac #9939, but it was Christmas, so I did
some recreational programming that went much further.
The idea is to warn when a constraint in a user-supplied context is
redundant. Everything is described in detail in
Note [Tracking redundant constraints]
in TcSimplify.
Main changes:
* The new ic_status field in an implication, of type ImplicStatus.
It replaces ic_insol, and includes information about redundant
constraints.
* New function TcSimplify.setImplicationStatus sets the ic_status.
* TcSigInfo has sig_report_redundant field to say whenther a
redundant constraint should be reported; and similarly
the FunSigCtxt constructor of UserTypeCtxt
* EvBinds has a field eb_is_given, to record whether it is a given
or wanted binding. Some consequential chagnes to creating an evidence
binding (so that we record whether it is given or wanted).
* AbsBinds field abs_ev_binds is now a *list* of TcEvBiinds;
see Note [Typechecking plan for instance declarations] in
TcInstDcls
* Some significant changes to the type checking of instance
declarations; Note [Typechecking plan for instance declarations]
in TcInstDcls.
* I found that TcErrors.relevantBindings was failing to zonk the
origin of the constraint it was looking at, and hence failing to
find some relevant bindings. Easy to fix, and orthogonal to
everything else, but hard to disentangle.
Some minor refactorig:
* TcMType.newSimpleWanteds moves to Inst, renamed as newWanteds
* TcClassDcl and TcInstDcls now have their own code for typechecking
a method body, rather than sharing a single function. The shared
function (ws TcClassDcl.tcInstanceMethodBody) didn't have much code
and the differences were growing confusing.
* Add new function TcRnMonad.pushLevelAndCaptureConstraints, and
use it
* Add new function Bag.catBagMaybes, and use it in TcSimplify
Diffstat (limited to 'testsuite/tests/deriving/should_compile')
9 files changed, 18 insertions, 7 deletions
diff --git a/testsuite/tests/deriving/should_compile/T2856.hs b/testsuite/tests/deriving/should_compile/T2856.hs index c8f81a00bc..fc309585fe 100644 --- a/testsuite/tests/deriving/should_compile/T2856.hs +++ b/testsuite/tests/deriving/should_compile/T2856.hs @@ -1,3 +1,4 @@ +{-# OPTIONS -fno-warn-redundant-constraints #-} {-# LANGUAGE TypeFamilies, GeneralizedNewtypeDeriving, StandaloneDeriving, FlexibleInstances #-} -- Test Trac #2856 diff --git a/testsuite/tests/deriving/should_compile/T4966.hs b/testsuite/tests/deriving/should_compile/T4966.hs index 363627a415..85245b73ff 100644 --- a/testsuite/tests/deriving/should_compile/T4966.hs +++ b/testsuite/tests/deriving/should_compile/T4966.hs @@ -1,3 +1,5 @@ +{-# OPTIONS -fno-warn-redundant-constraints #-} + {-# LANGUAGE DatatypeContexts #-} {-# LANGUAGE EmptyDataDecls #-} {-# LANGUAGE FlexibleInstances #-} diff --git a/testsuite/tests/deriving/should_compile/T4966.stderr b/testsuite/tests/deriving/should_compile/T4966.stderr index dceeaa698f..765c69756d 100644 --- a/testsuite/tests/deriving/should_compile/T4966.stderr +++ b/testsuite/tests/deriving/should_compile/T4966.stderr @@ -1,8 +1,8 @@ -T4966.hs:1:14: Warning: +T4966.hs:3:14: Warning: -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language. -T4966.hs:33:30: Warning: +T4966.hs:35:30: Warning: No explicit implementation for either ‘==’ or ‘/=’ In the instance declaration for ‘Eq (TreeListObject a)’ diff --git a/testsuite/tests/deriving/should_compile/deriving-1935.hs b/testsuite/tests/deriving/should_compile/deriving-1935.hs index 5b3bca0c77..8bccd58182 100644 --- a/testsuite/tests/deriving/should_compile/deriving-1935.hs +++ b/testsuite/tests/deriving/should_compile/deriving-1935.hs @@ -3,6 +3,8 @@ -- Trac #1935 -- See Note [Superclasses of derived instance] in TcDeriv +{-# OPTIONS -fno-warn-redundant-constraints #-} + module Foo where import Data.Data diff --git a/testsuite/tests/deriving/should_compile/deriving-1935.stderr b/testsuite/tests/deriving/should_compile/deriving-1935.stderr index bf2c79cb7a..9901a367d7 100644 --- a/testsuite/tests/deriving/should_compile/deriving-1935.stderr +++ b/testsuite/tests/deriving/should_compile/deriving-1935.stderr @@ -1,15 +1,15 @@ -deriving-1935.hs:15:11: Warning: +deriving-1935.hs:17:11: Warning: No explicit implementation for either ‘==’ or ‘/=’ In the instance declaration for ‘Eq (T a)’ -deriving-1935.hs:18:11: Warning: +deriving-1935.hs:20:11: Warning: No explicit implementation for either ‘==’ or ‘/=’ In the instance declaration for ‘Eq (S a)’ -deriving-1935.hs:19:11: Warning: +deriving-1935.hs:21:11: Warning: No explicit implementation for either ‘compare’ or ‘<=’ In the instance declaration for ‘Ord (S a)’ diff --git a/testsuite/tests/deriving/should_compile/drv001.hs b/testsuite/tests/deriving/should_compile/drv001.hs index 694af6a50f..3afd394cc0 100644 --- a/testsuite/tests/deriving/should_compile/drv001.hs +++ b/testsuite/tests/deriving/should_compile/drv001.hs @@ -1,3 +1,5 @@ +{-# OPTIONS -fno-warn-redundant-constraints #-} + -- !!! canonical weird example for "deriving" module ShouldSucceed where diff --git a/testsuite/tests/deriving/should_compile/drv002.hs b/testsuite/tests/deriving/should_compile/drv002.hs index 15eb2d9ecc..9ccb7b7bb7 100644 --- a/testsuite/tests/deriving/should_compile/drv002.hs +++ b/testsuite/tests/deriving/should_compile/drv002.hs @@ -1,3 +1,5 @@ +{-# OPTIONS -fno-warn-redundant-constraints #-} + module ShouldSucceed where data Z a b diff --git a/testsuite/tests/deriving/should_compile/drv003.hs b/testsuite/tests/deriving/should_compile/drv003.hs index 0b8149ce8a..6fdd763f84 100644 --- a/testsuite/tests/deriving/should_compile/drv003.hs +++ b/testsuite/tests/deriving/should_compile/drv003.hs @@ -1,3 +1,5 @@ +{-# OPTIONS -fno-warn-redundant-constraints #-} + -- !!! This is the example given in TcDeriv -- module ShouldSucceed where diff --git a/testsuite/tests/deriving/should_compile/drv003.stderr b/testsuite/tests/deriving/should_compile/drv003.stderr index 6d9819fee8..ead606d28a 100644 --- a/testsuite/tests/deriving/should_compile/drv003.stderr +++ b/testsuite/tests/deriving/should_compile/drv003.stderr @@ -1,10 +1,10 @@ -drv003.hs:12:10: Warning: +drv003.hs:14:10: Warning: No explicit implementation for either ‘==’ or ‘/=’ In the instance declaration for ‘Eq (Foo a)’ -drv003.hs:15:10: Warning: +drv003.hs:17:10: Warning: No explicit implementation for either ‘==’ or ‘/=’ In the instance declaration for ‘Eq (Bar b)’ |