[commit: ghc] master: Warn about simplifiable class constraints (9421b0c)
git at git.haskell.org
git at git.haskell.org
Fri Apr 22 10:30:00 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/9421b0c77122d40bf72665ea9f90dca64a0a0ae2/ghc
>---------------------------------------------------------------
commit 9421b0c77122d40bf72665ea9f90dca64a0a0ae2
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date: Thu Apr 21 13:06:54 2016 +0100
Warn about simplifiable class constraints
Provoked by Trac #11948, this patch adds a new warning to GHC
-Wsimplifiable-class-constraints
It warns if you write a class constraint in a type signature that
can be simplified by an existing instance declaration. Almost always
this means you should simplify it right now; type inference is very
fragile without it, as #11948 shows.
I've put the warning as on-by-default, but I suppose that if there are
howls of protest we can move it out (as happened for -Wredundant-constraints.
It actually found an example of an over-complicated context in CmmNode.
Quite a few tests use these weird contexts to trigger something else,
so I had to suppress the warning in those.
The 'haskeline' library has a few occurrences of the warning (which
I think should be fixed), so I switched it off for that library in
warnings.mk.
The warning itself is done in TcValidity.check_class_pred.
HOWEVER, when type inference fails we get a type error; and the error
suppresses the (informative) warning. So as things stand, the warning
only happens when it doesn't cause a problem. Not sure what to do
about this, but this patch takes us forward, I think.
>---------------------------------------------------------------
9421b0c77122d40bf72665ea9f90dca64a0a0ae2
compiler/basicTypes/BasicTypes.hs | 8 ++-
compiler/cmm/CmmNode.hs | 2 +-
compiler/main/DynFlags.hs | 5 +-
compiler/typecheck/TcInteract.hs | 15 +++++-
compiler/typecheck/TcType.hs | 2 +-
compiler/typecheck/TcValidity.hs | 63 +++++++++++++++++-----
compiler/types/InstEnv.hs | 45 ++++++++--------
docs/users_guide/using-warnings.rst | 22 ++++++++
mk/warnings.mk | 1 +
.../dependent/should_compile/dynamic-paper.hs | 5 +-
testsuite/tests/ghci/scripts/ghci047.script | 4 +-
testsuite/tests/ghci/scripts/ghci047.stderr | 4 +-
.../tests/indexed-types/should_compile/Gentle.hs | 3 +-
.../indexed-types/should_compile/NonLinearLHS.hs | 4 +-
.../tests/indexed-types/should_compile/T11067.hs | 5 ++
.../tests/indexed-types/should_compile/T5002.hs | 6 ++-
.../should_compile/SomethingShowable.stderr | 6 ++-
testsuite/tests/polykinds/T6020a.hs | 4 +-
.../tests/simplCore/should_compile/simpl014.hs | 5 +-
testsuite/tests/th/T3100.hs | 3 +-
.../typecheck/should_compile/GivenOverlapping.hs | 3 +-
testsuite/tests/typecheck/should_compile/T10195.hs | 4 +-
testsuite/tests/typecheck/should_compile/T3108.hs | 3 +-
testsuite/tests/typecheck/should_compile/T4361.hs | 2 +-
testsuite/tests/typecheck/should_compile/T6055.hs | 4 +-
testsuite/tests/typecheck/should_compile/T7541.hs | 3 +-
testsuite/tests/typecheck/should_compile/T7875.hs | 3 +-
testsuite/tests/typecheck/should_compile/tc229.hs | 4 +-
testsuite/tests/typecheck/should_fail/T11948.hs | 22 ++++++++
.../tests/typecheck/should_fail/T11948.stderr | 10 ++++
testsuite/tests/typecheck/should_fail/all.T | 1 +
31 files changed, 209 insertions(+), 62 deletions(-)
Diff suppressed because of size. To see it, use:
git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 9421b0c77122d40bf72665ea9f90dca64a0a0ae2
More information about the ghc-commits
mailing list