| 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}
| Opt_WarnDuplicateExports
| Opt_WarnHiShadows
| Opt_WarnIncompletePatterns
+ | Opt_WarnIncompletePatternsRecUpd
| Opt_WarnMissingFields
| Opt_WarnMissingMethods
| Opt_WarnMissingSigs
( "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 ),
</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>
<entry>dynamic</entry>
</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>:
<indexterm><primary><option>-fwarn-misc</option></primary></indexterm>