Commit 79d7a7c0 authored by igloo's avatar igloo
Browse files

[project @ 2004-10-18 18:24:59 by igloo]

Implement -fwarn-incomplete-record-updates
parent d18f6b1e
......@@ -67,8 +67,12 @@ matchCheck_really dflags ctx vars ty qs
| otherwise =
match vars ty qs
where (pats, eqns_shadow) = check qs
incomplete = dopt Opt_WarnIncompletePatterns dflags
&& (notNull pats)
incomplete = want_incomplete && (notNull pats)
want_incomplete = case ctx of
DsMatchContext RecUpd _ _ ->
dopt Opt_WarnIncompletePatternsRecUpd dflags
_ ->
dopt Opt_WarnIncompletePatterns dflags
shadow = dopt Opt_WarnOverlappingPatterns dflags
&& not (null eqns_shadow)
\end{code}
......
......@@ -256,6 +256,7 @@ data DynFlag
| Opt_WarnDuplicateExports
| Opt_WarnHiShadows
| Opt_WarnIncompletePatterns
| Opt_WarnIncompletePatternsRecUpd
| Opt_WarnMissingFields
| Opt_WarnMissingMethods
| Opt_WarnMissingSigs
......
......@@ -441,6 +441,7 @@ fFlags = [
( "warn-duplicate-exports", Opt_WarnDuplicateExports ),
( "warn-hi-shadowing", Opt_WarnHiShadows ),
( "warn-incomplete-patterns", Opt_WarnIncompletePatterns ),
( "warn-incomplete-record-updates", Opt_WarnIncompletePatternsRecUpd ),
( "warn-missing-fields", Opt_WarnMissingFields ),
( "warn-missing-methods", Opt_WarnMissingMethods ),
( "warn-missing-signatures", Opt_WarnMissingSigs ),
......
......@@ -590,6 +590,13 @@
<entry><option>-fno-warn-incomplete-patterns</option></entry>
</row>
<row>
<entry><option>-fwarn-incomplete-record-updates</option></entry>
<entry>warn when a record update could fail</entry>
<entry>dynamic</entry>
<entry><option>-fno-warn-incomplete-record-updates</option></entry>
</row>
<row>
<entry><option>-fwarn-misc</option></entry>
<entry>enable miscellaneous warnings</entry>
......
......@@ -834,6 +834,33 @@ g [] = 2
</listitem>
</varlistentry>
<varlistentry>
<term><option>-fwarn-incomplete-record-updates</option>:</term>
<listitem>
<indexterm><primary><option>-fwarn-incomplete-record-updates</option></primary></indexterm>
<indexterm><primary>incomplete record updates, warning</primary></indexterm>
<indexterm><primary>record updates, incomplete</primary></indexterm>
<para>The function
<function>f</function> below will fail when applied to
<literal>Bar</literal>, so the compiler will emit a warning about
this when <option>-fwarn-incomplete-record-updates</option> is
enabled.</para>
<programlisting>
data Foo = Foo { x :: Int }
| Bar
f :: Foo -> Foo
f foo = foo { x = 6 }
</programlisting>
<para>This option isn't enabled be default because it can be
very noisy, and it often doesn't indicate a bug in the
program.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>-fwarn-misc</option>:
......
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