diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2021-03-25 16:27:53 +0000 |
---|---|---|
committer | Fendor <power.walross@gmail.com> | 2021-04-10 10:35:38 +0200 |
commit | b014f902c75b9c071b25815b2876adebb2cb5a44 (patch) | |
tree | bd7291660e69662d64226b944ec69ff542e47e30 /compiler/GHC/Tc/Errors.hs | |
parent | a951e06921f05df1601d9c3a39efcede27f3330c (diff) | |
download | haskell-wip/T19296.tar.gz |
More accurate SrcSpan when reporting redundant constraintswip/T19296
We want an accurate SrcSpan for redundant constraints:
• Redundant constraint: Eq a
• In the type signature for:
f :: forall a. Eq a => a -> ()
|
5 | f :: Eq a => a -> ()
| ^^^^
This patch adds some plumbing to achieve this
* New data type GHC.Tc.Types.Origin.ReportRedundantConstraints (RRC)
* This RRC value is kept inside
- FunSigCtxt
- ExprSigCtxt
* Then, when reporting the error in GHC.Tc.Errors, use this SrcSpan
to control the error message: GHC.Tc.Errors.warnRedundantConstraints
Quite a lot of files are touched in a boring way.
Diffstat (limited to 'compiler/GHC/Tc/Errors.hs')
-rw-r--r-- | compiler/GHC/Tc/Errors.hs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/GHC/Tc/Errors.hs b/compiler/GHC/Tc/Errors.hs index fb52a01c4b..1f972c6425 100644 --- a/compiler/GHC/Tc/Errors.hs +++ b/compiler/GHC/Tc/Errors.hs @@ -463,9 +463,10 @@ warnRedundantConstraints ctxt env info ev_vars | null redundant_evs = return () - | SigSkol {} <- info + | SigSkol user_ctxt _ _ <- info = setLclEnv env $ -- We want to add "In the type signature for f" -- to the error context, which is a bit tiresome + setSrcSpan (redundantConstraintsSpan user_ctxt) $ addErrCtxt (text "In" <+> ppr info) $ do { env <- getLclEnv ; msg <- mkErrorReport (WarningWithFlag Opt_WarnRedundantConstraints) ctxt env (important doc) |