Hi,

I like to keep my programs warning free, but I don't know of a sensible
way of silencing

    Warning: Pattern match(es) are non-exhaustive
             In a record-update construct: Patterns not matched: Bar

(which is generally intentional) without also silencing useful warnings.
The attached patch adds a -fwarn-incomplete-record-updates that takes
over control of this warning from -fwarn-incomplete-patterns.


Thanks
Ian

Index: ghc/compiler/deSugar/Match.lhs
===================================================================
RCS file: /home/cvs/root/fptools/ghc/compiler/deSugar/Match.lhs,v
retrieving revision 1.67
diff -u -r1.67 Match.lhs
--- ghc/compiler/deSugar/Match.lhs      15 Oct 2004 15:28:51 -0000      1.67
+++ ghc/compiler/deSugar/Match.lhs      18 Oct 2004 01:58:04 -0000
@@ -67,8 +67,12 @@
   | 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}
Index: ghc/compiler/main/CmdLineOpts.lhs
===================================================================
RCS file: /home/cvs/root/fptools/ghc/compiler/main/CmdLineOpts.lhs,v
retrieving revision 1.190
diff -u -r1.190 CmdLineOpts.lhs
--- ghc/compiler/main/CmdLineOpts.lhs   7 Oct 2004 15:54:08 -0000       1.190
+++ ghc/compiler/main/CmdLineOpts.lhs   18 Oct 2004 01:58:04 -0000
@@ -256,6 +256,7 @@
    | Opt_WarnDuplicateExports
    | Opt_WarnHiShadows
    | Opt_WarnIncompletePatterns
+   | Opt_WarnIncompletePatternsRecUpd
    | Opt_WarnMissingFields
    | Opt_WarnMissingMethods
    | Opt_WarnMissingSigs
Index: ghc/compiler/main/DriverFlags.hs
===================================================================
RCS file: /home/cvs/root/fptools/ghc/compiler/main/DriverFlags.hs,v
retrieving revision 1.138
diff -u -r1.138 DriverFlags.hs
--- ghc/compiler/main/DriverFlags.hs    7 Oct 2004 15:54:10 -0000       1.138
+++ ghc/compiler/main/DriverFlags.hs    18 Oct 2004 01:58:05 -0000
@@ -441,6 +441,7 @@
   ( "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 ),
Index: ghc/docs/users_guide/flags.xml
===================================================================
RCS file: /home/cvs/root/fptools/ghc/docs/users_guide/flags.xml,v
retrieving revision 1.3
diff -u -r1.3 flags.xml
--- ghc/docs/users_guide/flags.xml      5 Oct 2004 13:56:31 -0000       1.3
+++ ghc/docs/users_guide/flags.xml      18 Oct 2004 01:58:05 -0000
@@ -591,6 +591,13 @@
          </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>
_______________________________________________
Cvs-ghc mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to