Commit 5a6a223f authored by Simon Peyton Jones's avatar Simon Peyton Jones

Add flag -fwarn-duplicate-constraints

This fixes Trac #7541, and is on by default.
Use -fno-warn-duplicate-constraints to switch it off.
parent 302172f4
......@@ -384,6 +384,7 @@ data GeneralFlag
data WarningFlag =
Opt_WarnDuplicateExports
| Opt_WarnDuplicateConstraints
| Opt_WarnHiShadows
| Opt_WarnImplicitPrelude
| Opt_WarnIncompletePatterns
......@@ -2324,6 +2325,7 @@ fWarningFlags = [
( "warn-dodgy-exports", Opt_WarnDodgyExports, nop ),
( "warn-dodgy-imports", Opt_WarnDodgyImports, nop ),
( "warn-duplicate-exports", Opt_WarnDuplicateExports, nop ),
( "warn-duplicate-constraints", Opt_WarnDuplicateConstraints, nop ),
( "warn-hi-shadowing", Opt_WarnHiShadows, nop ),
( "warn-implicit-prelude", Opt_WarnImplicitPrelude, nop ),
( "warn-incomplete-patterns", Opt_WarnIncompletePatterns, nop ),
......@@ -2740,7 +2742,8 @@ standardWarnings
Opt_WarnAlternativeLayoutRuleTransitional,
Opt_WarnPointlessPragmas,
Opt_WarnUnsupportedCallingConventions,
Opt_WarnInlineRuleShadowing
Opt_WarnInlineRuleShadowing,
Opt_WarnDuplicateConstraints
]
minusWOpts :: [WarningFlag]
......
......@@ -1266,10 +1266,11 @@ checkValidTheta ctxt theta
check_valid_theta :: UserTypeCtxt -> [PredType] -> TcM ()
check_valid_theta _ []
= return ()
check_valid_theta ctxt theta = do
dflags <- getDynFlags
warnTc (notNull dups) (dupPredWarn dups)
mapM_ (check_pred_ty dflags ctxt) theta
check_valid_theta ctxt theta
= do { dflags <- getDynFlags
; warnTc (wopt Opt_WarnDuplicateConstraints dflags &&
notNull dups) (dupPredWarn dups)
; mapM_ (check_pred_ty dflags ctxt) theta }
where
(_,dups) = removeDups cmpPred theta
......
......@@ -1235,6 +1235,13 @@
<entry><option>-fno-warn-deprecated-flags</option></entry>
</row>
<row>
<entry><option>-fwarn-duplicate-constraints</option></entry>
<entry>warn when a constraint appears duplicated in a type signature</entry>
<entry>dynamic</entry>
<entry><option>-fno-warn-duplicate-constraints</option></entry>
</row>
<row>
<entry><option>-fwarn-duplicate-exports</option></entry>
<entry>warn when an entity is exported multiple times</entry>
......
......@@ -950,6 +950,7 @@ test.hs:(5,4)-(6,7):
<option>-fwarn-overlapping-patterns</option>,
<option>-fwarn-warnings-deprecations</option>,
<option>-fwarn-deprecated-flags</option>,
<option>-fwarn-duplicate-constraints</option>,
<option>-fwarn-duplicate-exports</option>,
<option>-fwarn-missing-fields</option>,
<option>-fwarn-missing-methods</option>,
......@@ -1194,6 +1195,24 @@ foreign import "&amp;f" f :: FunPtr t
</listitem>
</varlistentry>
<varlistentry>
<term><option>-fwarn-duplicate-constraints</option>:</term>
<listitem>
<indexterm><primary><option>-fwarn-duplicate-constraints</option></primary></indexterm>
<indexterm><primary>duplicate constraints, warning</primary></indexterm>
<para>Have the compiler warn about duplicate constraints in a type signature. For
example
<programlisting>
f :: (Eq a, Show a, Eq a) => a -> a
</programlisting>
The warning will indicate the duplicated <literal>Eq a</literal> constraint.
</para>
<para>This option is on by default.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-fwarn-duplicate-exports</option>:</term>
<listitem>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment